sendlit 0.2.0 → 0.4.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/README.md +42 -3
- package/dist/index.d.mts +8659 -2966
- package/dist/index.d.ts +8659 -2966
- package/dist/index.js +1059 -206
- package/dist/index.mjs +1058 -207
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -230,6 +230,151 @@ statuses({ skip: "pending_confirmation" }, [
|
|
|
230
230
|
"awaiting_confirmation",
|
|
231
231
|
"not_confirmed"
|
|
232
232
|
]);
|
|
233
|
+
var organizationRoleSchema = zod.z.enum(["owner", "admin", "member"]);
|
|
234
|
+
var organizationSchema = zod.z.object({
|
|
235
|
+
organizationId: zod.z.string(),
|
|
236
|
+
name: zod.z.string(),
|
|
237
|
+
status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
|
|
238
|
+
createdAt: zod.z.string(),
|
|
239
|
+
updatedAt: zod.z.string()
|
|
240
|
+
});
|
|
241
|
+
var organizationListItemSchema = organizationSchema.extend({
|
|
242
|
+
role: organizationRoleSchema
|
|
243
|
+
});
|
|
244
|
+
var organizationMemberSchema = zod.z.object({
|
|
245
|
+
userId: zod.z.string(),
|
|
246
|
+
email: zod.z.string().email(),
|
|
247
|
+
name: zod.z.string(),
|
|
248
|
+
image: zod.z.string().nullable(),
|
|
249
|
+
role: organizationRoleSchema,
|
|
250
|
+
createdAt: zod.z.string(),
|
|
251
|
+
updatedAt: zod.z.string()
|
|
252
|
+
});
|
|
253
|
+
var createOrganizationBodySchema = zod.z.object({
|
|
254
|
+
name: zod.z.string().trim().min(1)
|
|
255
|
+
});
|
|
256
|
+
var updateOrganizationBodySchema = zod.z.object({
|
|
257
|
+
name: zod.z.string().trim().min(1)
|
|
258
|
+
});
|
|
259
|
+
var addOrganizationMemberBodySchema = zod.z.object({
|
|
260
|
+
/** Existing Better Auth user only. This is a membership lookup, never an
|
|
261
|
+
* authentication or account-creation flow. */
|
|
262
|
+
email: zod.z.string().trim().email(),
|
|
263
|
+
role: organizationRoleSchema
|
|
264
|
+
});
|
|
265
|
+
var updateOrganizationMemberBodySchema = zod.z.object({
|
|
266
|
+
role: organizationRoleSchema
|
|
267
|
+
});
|
|
268
|
+
var organizationKeyScopes = [
|
|
269
|
+
"organization:read",
|
|
270
|
+
"delivery:read",
|
|
271
|
+
"delivery:manage",
|
|
272
|
+
"teams:provision",
|
|
273
|
+
"teams:read",
|
|
274
|
+
"teams:manage",
|
|
275
|
+
"teams:keys",
|
|
276
|
+
"esps:read",
|
|
277
|
+
"esps:manage",
|
|
278
|
+
"grants:manage",
|
|
279
|
+
"usage:read"
|
|
280
|
+
];
|
|
281
|
+
var organizationApiKeySchema = zod.z.object({
|
|
282
|
+
keyId: zod.z.string(),
|
|
283
|
+
name: zod.z.string(),
|
|
284
|
+
keyPrefix: zod.z.string(),
|
|
285
|
+
scopes: zod.z.array(zod.z.enum(organizationKeyScopes)),
|
|
286
|
+
expiresAt: zod.z.string().nullable(),
|
|
287
|
+
lastUsedAt: zod.z.string().nullable(),
|
|
288
|
+
revokedAt: zod.z.string().nullable(),
|
|
289
|
+
createdAt: zod.z.string()
|
|
290
|
+
});
|
|
291
|
+
var createOrganizationApiKeyBodySchema = zod.z.object({
|
|
292
|
+
name: zod.z.string().trim().min(1),
|
|
293
|
+
scopes: zod.z.array(zod.z.enum(organizationKeyScopes)).min(1),
|
|
294
|
+
expiresAt: zod.z.string().datetime().nullable().optional()
|
|
295
|
+
});
|
|
296
|
+
var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
|
|
297
|
+
key: zod.z.string()
|
|
298
|
+
});
|
|
299
|
+
var organizationUsageWindowSchema = zod.z.object({
|
|
300
|
+
limit: zod.z.number().int().nullable(),
|
|
301
|
+
accepted: zod.z.number().int().nonnegative(),
|
|
302
|
+
reserved: zod.z.number().int().nonnegative(),
|
|
303
|
+
remaining: zod.z.number().int().nullable(),
|
|
304
|
+
resetsAt: zod.z.string()
|
|
305
|
+
});
|
|
306
|
+
var organizationUsageSchema = zod.z.object({
|
|
307
|
+
day: organizationUsageWindowSchema,
|
|
308
|
+
month: organizationUsageWindowSchema
|
|
309
|
+
});
|
|
310
|
+
var organizationMailActivityQuerySchema = zod.z.object({
|
|
311
|
+
rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
312
|
+
});
|
|
313
|
+
var organizationMailCountsSchema = zod.z.object({
|
|
314
|
+
sent: zod.z.number().int().nonnegative(),
|
|
315
|
+
queued: zod.z.number().int().nonnegative(),
|
|
316
|
+
failed: zod.z.number().int().nonnegative(),
|
|
317
|
+
bounced: zod.z.number().int().nonnegative()
|
|
318
|
+
});
|
|
319
|
+
var organizationMailActivityTeamSchema = zod.z.object({
|
|
320
|
+
teamId: zod.z.string(),
|
|
321
|
+
name: zod.z.string(),
|
|
322
|
+
status: zod.z.enum(["active", "sending_suspended", "archived"]),
|
|
323
|
+
externalId: zod.z.string().nullable(),
|
|
324
|
+
mail: organizationMailCountsSchema
|
|
325
|
+
});
|
|
326
|
+
var organizationMailActivitySchema = zod.z.object({
|
|
327
|
+
rangeDays: zod.z.union([zod.z.literal(1), zod.z.literal(3), zod.z.literal(7), zod.z.literal(30)]),
|
|
328
|
+
totals: organizationMailCountsSchema,
|
|
329
|
+
teams: zod.z.array(organizationMailActivityTeamSchema)
|
|
330
|
+
});
|
|
331
|
+
var organizationEnterTeamBodySchema = zod.z.object({});
|
|
332
|
+
var organizationEnterTeamResponseSchema = zod.z.object({
|
|
333
|
+
teamId: zod.z.string(),
|
|
334
|
+
role: zod.z.enum(["admin", "member"]),
|
|
335
|
+
created: zod.z.boolean()
|
|
336
|
+
});
|
|
337
|
+
var organizationAuditEventSchema = zod.z.object({
|
|
338
|
+
action: zod.z.string(),
|
|
339
|
+
actorType: zod.z.enum(["user", "organization_key", "team_key", "system"]),
|
|
340
|
+
teamId: zod.z.string().nullable(),
|
|
341
|
+
espId: zod.z.string().nullable(),
|
|
342
|
+
grantId: zod.z.string().nullable(),
|
|
343
|
+
metadata: zod.z.record(zod.z.any()),
|
|
344
|
+
createdAt: zod.z.string()
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// ../api-contract/src/schemas/account.ts
|
|
348
|
+
var accountDeletionBlockerSchema = zod.z.enum([
|
|
349
|
+
"active_subscription_exists",
|
|
350
|
+
"billing_checkout_pending",
|
|
351
|
+
"last_organization_owner",
|
|
352
|
+
"billing_manager_required"
|
|
353
|
+
]);
|
|
354
|
+
var accountDeletionOrganizationSchema = zod.z.object({
|
|
355
|
+
organizationId: zod.z.string(),
|
|
356
|
+
name: zod.z.string(),
|
|
357
|
+
status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
|
|
358
|
+
role: organizationRoleSchema,
|
|
359
|
+
/** `delete`: they are its last owner, so it is deleted with its contacts'
|
|
360
|
+
* data. `leave`: someone else stays in charge; only their membership goes. */
|
|
361
|
+
action: zod.z.enum(["delete", "leave"]),
|
|
362
|
+
teamCount: zod.z.number().int(),
|
|
363
|
+
/** What has to happen before the account can be deleted, if anything. */
|
|
364
|
+
blocker: accountDeletionBlockerSchema.nullable()
|
|
365
|
+
});
|
|
366
|
+
var accountDeletionPreviewSchema = zod.z.object({
|
|
367
|
+
email: zod.z.string(),
|
|
368
|
+
organizations: zod.z.array(accountDeletionOrganizationSchema),
|
|
369
|
+
blocked: zod.z.boolean()
|
|
370
|
+
});
|
|
371
|
+
var deleteAccountBodySchema = zod.z.object({
|
|
372
|
+
/** The account's email, typed to confirm. */
|
|
373
|
+
email: zod.z.string().trim().min(1),
|
|
374
|
+
/** The code sent by `POST /account/deletion/code`. */
|
|
375
|
+
code: zod.z.string().trim().min(1)
|
|
376
|
+
});
|
|
377
|
+
var accountDeletionBlockedSchema = accountDeletionPreviewSchema.omit({ email: true }).extend({ error: zod.z.literal("account_deletion_blocked") });
|
|
233
378
|
var paidPlans = ["starter", "pro", "business"];
|
|
234
379
|
var billingPlans = ["oss", "free", ...paidPlans];
|
|
235
380
|
var billingCatalogKeys = paidPlans.flatMap(
|
|
@@ -462,6 +607,50 @@ var emailBlockInputSchema = zod.z.discriminatedUnion("blockType", [
|
|
|
462
607
|
settings: zod.z.object({ src: zod.z.string().min(1) }).passthrough()
|
|
463
608
|
}),
|
|
464
609
|
blockBaseSchema.extend({ blockType: zod.z.literal("separator") }),
|
|
610
|
+
blockBaseSchema.extend({
|
|
611
|
+
blockType: zod.z.literal("spacer"),
|
|
612
|
+
settings: zod.z.object({ height: pixelSchema.optional() }).passthrough()
|
|
613
|
+
}),
|
|
614
|
+
blockBaseSchema.extend({
|
|
615
|
+
blockType: zod.z.literal("columns"),
|
|
616
|
+
settings: zod.z.object({
|
|
617
|
+
left: zod.z.string(),
|
|
618
|
+
right: zod.z.string(),
|
|
619
|
+
ratio: zod.z.enum(["11", "12", "21"]).optional(),
|
|
620
|
+
stack: zod.z.boolean().optional()
|
|
621
|
+
}).passthrough()
|
|
622
|
+
}),
|
|
623
|
+
blockBaseSchema.extend({
|
|
624
|
+
blockType: zod.z.literal("social"),
|
|
625
|
+
settings: zod.z.object({
|
|
626
|
+
links: zod.z.array(
|
|
627
|
+
zod.z.object({
|
|
628
|
+
network: zod.z.enum([
|
|
629
|
+
"website",
|
|
630
|
+
"instagram",
|
|
631
|
+
"linkedin",
|
|
632
|
+
"youtube",
|
|
633
|
+
"x",
|
|
634
|
+
"facebook",
|
|
635
|
+
"tiktok"
|
|
636
|
+
]),
|
|
637
|
+
url: zod.z.string().regex(/^(?:https?:\/\/\S+)?$/i, "Expected an http(s) URL")
|
|
638
|
+
})
|
|
639
|
+
)
|
|
640
|
+
}).passthrough()
|
|
641
|
+
}),
|
|
642
|
+
blockBaseSchema.extend({
|
|
643
|
+
blockType: zod.z.literal("html"),
|
|
644
|
+
settings: zod.z.object({ code: zod.z.string() }).passthrough()
|
|
645
|
+
}),
|
|
646
|
+
blockBaseSchema.extend({
|
|
647
|
+
blockType: zod.z.literal("conditional"),
|
|
648
|
+
settings: zod.z.object({
|
|
649
|
+
tag: zod.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9 _.-]{0,39}$/, "Expected a plain tag name"),
|
|
650
|
+
has: zod.z.boolean().optional(),
|
|
651
|
+
content: zod.z.string()
|
|
652
|
+
}).passthrough()
|
|
653
|
+
}),
|
|
465
654
|
blockBaseSchema.extend({ blockType: zod.z.literal("footer") })
|
|
466
655
|
]);
|
|
467
656
|
var emailMetaInputSchema = zod.z.object({
|
|
@@ -588,10 +777,204 @@ var sendingOptionSchema = zod.z.discriminatedUnion("type", [
|
|
|
588
777
|
countsAgainstQuota: zod.z.literal(false)
|
|
589
778
|
})
|
|
590
779
|
]);
|
|
780
|
+
var EVENT_NAME_MAX_LENGTH = 128;
|
|
781
|
+
var EVENT_PROPERTIES_MAX_BYTES = 32 * 1024;
|
|
782
|
+
var EVENT_PROPERTIES_MAX_KEYS = 100;
|
|
783
|
+
var EVENT_PROPERTIES_MAX_DEPTH = 3;
|
|
784
|
+
var EVENT_FILTER_MAX_CONDITIONS = 10;
|
|
785
|
+
var EVENT_MAX_FUTURE_MS = 24 * 60 * 60 * 1e3;
|
|
786
|
+
var eventPropertyKeyPattern = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
787
|
+
var controlCharacters = /[\u0000-\u001f\u007f]/;
|
|
788
|
+
var eventNameSchema = zod.z.string().trim().min(1).max(EVENT_NAME_MAX_LENGTH).refine((name) => !controlCharacters.test(name), {
|
|
789
|
+
message: "Event names can't contain control characters"
|
|
790
|
+
}).refine((name) => !name.startsWith("$"), {
|
|
791
|
+
message: "Event names can't start with $"
|
|
792
|
+
});
|
|
793
|
+
function propertiesProblem(value, depth) {
|
|
794
|
+
if (Array.isArray(value)) {
|
|
795
|
+
for (const item of value) {
|
|
796
|
+
const problem = propertiesProblem(item, depth + 1);
|
|
797
|
+
if (problem)
|
|
798
|
+
return problem;
|
|
799
|
+
}
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
if (value && typeof value === "object") {
|
|
803
|
+
if (depth >= EVENT_PROPERTIES_MAX_DEPTH) {
|
|
804
|
+
return `Properties can be nested at most ${EVENT_PROPERTIES_MAX_DEPTH} levels`;
|
|
805
|
+
}
|
|
806
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
807
|
+
if (!eventPropertyKeyPattern.test(key)) {
|
|
808
|
+
return `Property key "${key}" must start with a letter or _ and contain only letters, digits and _ (max 64)`;
|
|
809
|
+
}
|
|
810
|
+
const problem = propertiesProblem(nested, depth + 1);
|
|
811
|
+
if (problem)
|
|
812
|
+
return problem;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
var eventPropertiesSchema = zod.z.record(zod.z.unknown()).superRefine((properties, ctx) => {
|
|
818
|
+
if (Object.keys(properties).length > EVENT_PROPERTIES_MAX_KEYS) {
|
|
819
|
+
ctx.addIssue({
|
|
820
|
+
code: zod.z.ZodIssueCode.custom,
|
|
821
|
+
message: `At most ${EVENT_PROPERTIES_MAX_KEYS} top-level properties`
|
|
822
|
+
});
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const bytes = new TextEncoder().encode(JSON.stringify(properties)).length;
|
|
826
|
+
if (bytes > EVENT_PROPERTIES_MAX_BYTES) {
|
|
827
|
+
ctx.addIssue({
|
|
828
|
+
code: zod.z.ZodIssueCode.custom,
|
|
829
|
+
message: `Properties can be at most ${EVENT_PROPERTIES_MAX_BYTES} bytes as JSON`
|
|
830
|
+
});
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
const problem = propertiesProblem(properties, 0);
|
|
834
|
+
if (problem)
|
|
835
|
+
ctx.addIssue({ code: zod.z.ZodIssueCode.custom, message: problem });
|
|
836
|
+
});
|
|
837
|
+
var trackEventFieldsSchema = zod.z.object({
|
|
838
|
+
email: zod.z.string().email().optional(),
|
|
839
|
+
contactId: zod.z.string().min(1).optional(),
|
|
840
|
+
eventName: eventNameSchema,
|
|
841
|
+
properties: eventPropertiesSchema.optional(),
|
|
842
|
+
occurredAt: zod.z.string().datetime({ offset: true }).optional().describe("When it happened. At most 24 h in the future; defaults to now."),
|
|
843
|
+
idempotencyKey: zod.z.string().min(1).max(256).optional().describe("The same key within 30 days stores one event and enrolls once."),
|
|
844
|
+
backfill: zod.z.boolean().optional().describe("Record only: the event never starts a sequence."),
|
|
845
|
+
createContact: zod.z.boolean().optional().describe(
|
|
846
|
+
"Create the contact when the email is unknown (default true). Ignored with contactId."
|
|
847
|
+
),
|
|
848
|
+
contact: zod.z.object({
|
|
849
|
+
name: zod.z.string().optional(),
|
|
850
|
+
customFields: customFieldsSchema.optional()
|
|
851
|
+
}).strict().optional().describe(
|
|
852
|
+
"Applied to the contact. Custom fields are merged into the existing ones."
|
|
853
|
+
)
|
|
854
|
+
}).strict();
|
|
855
|
+
var trackEventBodySchema = trackEventFieldsSchema.refine((body) => !!body.email !== !!body.contactId, {
|
|
856
|
+
message: "Provide exactly one of email or contactId"
|
|
857
|
+
}).refine(
|
|
858
|
+
(body) => !body.occurredAt || new Date(body.occurredAt).getTime() <= Date.now() + EVENT_MAX_FUTURE_MS,
|
|
859
|
+
{ message: "occurredAt can be at most 24 hours in the future" }
|
|
860
|
+
);
|
|
861
|
+
var trackEventResponseSchema = zod.z.object({
|
|
862
|
+
eventId: zod.z.string(),
|
|
863
|
+
contactId: zod.z.string(),
|
|
864
|
+
duplicate: zod.z.boolean(),
|
|
865
|
+
contactCreated: zod.z.boolean()
|
|
866
|
+
});
|
|
867
|
+
var eventSources = ["api", "session", "mcp"];
|
|
868
|
+
var contactEventSchema = zod.z.object({
|
|
869
|
+
eventId: zod.z.string(),
|
|
870
|
+
name: zod.z.string(),
|
|
871
|
+
properties: zod.z.record(zod.z.unknown()),
|
|
872
|
+
occurredAt: zod.z.string(),
|
|
873
|
+
receivedAt: zod.z.string(),
|
|
874
|
+
source: zod.z.enum(eventSources),
|
|
875
|
+
backfill: zod.z.boolean(),
|
|
876
|
+
triggers: zod.z.boolean(),
|
|
877
|
+
enrolledSequences: zod.z.array(zod.z.object({ sequenceId: zod.z.string(), title: zod.z.string() }))
|
|
878
|
+
});
|
|
879
|
+
var listContactEventsQuerySchema = zod.z.object({
|
|
880
|
+
page: zod.z.coerce.number().int().min(1).optional(),
|
|
881
|
+
limit: zod.z.coerce.number().int().min(1).max(50).optional(),
|
|
882
|
+
name: eventNameSchema.optional()
|
|
883
|
+
});
|
|
884
|
+
var eventPropertyTypes = [
|
|
885
|
+
"string",
|
|
886
|
+
"number",
|
|
887
|
+
"boolean",
|
|
888
|
+
"date",
|
|
889
|
+
"object",
|
|
890
|
+
"array"
|
|
891
|
+
];
|
|
892
|
+
var eventDefinitionPropertySchema = zod.z.object({
|
|
893
|
+
key: zod.z.string().regex(eventPropertyKeyPattern),
|
|
894
|
+
type: zod.z.enum(eventPropertyTypes),
|
|
895
|
+
declared: zod.z.boolean()
|
|
896
|
+
});
|
|
897
|
+
var eventDefinitionSchema = zod.z.object({
|
|
898
|
+
name: zod.z.string(),
|
|
899
|
+
origin: zod.z.enum(["received", "manual"]),
|
|
900
|
+
description: zod.z.string().nullable(),
|
|
901
|
+
properties: zod.z.array(eventDefinitionPropertySchema),
|
|
902
|
+
firstSeenAt: zod.z.string().nullable(),
|
|
903
|
+
lastSeenAt: zod.z.string().nullable(),
|
|
904
|
+
createdAt: zod.z.string(),
|
|
905
|
+
/** Non-deleted sequences whose trigger is this event. */
|
|
906
|
+
sequenceCount: zod.z.number().int()
|
|
907
|
+
});
|
|
908
|
+
var eventDefinitionDetailSchema = eventDefinitionSchema.extend({
|
|
909
|
+
lastProperties: zod.z.record(zod.z.unknown()).nullable()
|
|
910
|
+
});
|
|
911
|
+
var declaredPropertiesSchema = zod.z.array(
|
|
912
|
+
zod.z.object({
|
|
913
|
+
key: zod.z.string().regex(eventPropertyKeyPattern),
|
|
914
|
+
type: zod.z.enum(eventPropertyTypes)
|
|
915
|
+
})
|
|
916
|
+
).max(EVENT_PROPERTIES_MAX_KEYS).refine((props) => new Set(props.map((p) => p.key)).size === props.length, {
|
|
917
|
+
message: "Property keys must be unique"
|
|
918
|
+
});
|
|
919
|
+
var createEventDefinitionBodySchema = zod.z.object({
|
|
920
|
+
name: eventNameSchema,
|
|
921
|
+
description: zod.z.string().max(500).optional(),
|
|
922
|
+
properties: declaredPropertiesSchema.optional()
|
|
923
|
+
}).strict();
|
|
924
|
+
var updateEventDefinitionBodySchema = zod.z.object({
|
|
925
|
+
description: zod.z.string().max(500).nullable().optional(),
|
|
926
|
+
properties: declaredPropertiesSchema.optional().describe("Replaces the declared properties. Observed keys stay.")
|
|
927
|
+
}).strict();
|
|
928
|
+
var filterScalarSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]);
|
|
929
|
+
var eventFilterConditions = [
|
|
930
|
+
"is",
|
|
931
|
+
"is_not",
|
|
932
|
+
"contains",
|
|
933
|
+
"not_contains",
|
|
934
|
+
"gt",
|
|
935
|
+
"gte",
|
|
936
|
+
"lt",
|
|
937
|
+
"lte",
|
|
938
|
+
"exists",
|
|
939
|
+
"not_exists"
|
|
940
|
+
];
|
|
941
|
+
var eventFilterKeySchema = zod.z.string().refine(
|
|
942
|
+
(key) => {
|
|
943
|
+
const parts = key.split(".");
|
|
944
|
+
return parts.length <= EVENT_PROPERTIES_MAX_DEPTH && parts.every((part) => eventPropertyKeyPattern.test(part));
|
|
945
|
+
},
|
|
946
|
+
{ message: "Use a property key, or a dot path up to 3 levels" }
|
|
947
|
+
);
|
|
948
|
+
var eventPropertyFilterSchema = zod.z.object({
|
|
949
|
+
aggregator: zod.z.enum(["and", "or"]),
|
|
950
|
+
filters: zod.z.array(
|
|
951
|
+
zod.z.object({
|
|
952
|
+
key: eventFilterKeySchema,
|
|
953
|
+
condition: zod.z.enum(eventFilterConditions),
|
|
954
|
+
value: filterScalarSchema.optional()
|
|
955
|
+
}).refine(
|
|
956
|
+
(f) => f.condition === "exists" || f.condition === "not_exists" || f.value !== void 0,
|
|
957
|
+
{ message: "This condition needs a value" }
|
|
958
|
+
)
|
|
959
|
+
).min(1).max(EVENT_FILTER_MAX_CONDITIONS)
|
|
960
|
+
});
|
|
961
|
+
var propertyChangeFilterSchema = zod.z.object({
|
|
962
|
+
from: filterScalarSchema.nullable().optional(),
|
|
963
|
+
to: filterScalarSchema.nullable().optional()
|
|
964
|
+
}).strict();
|
|
591
965
|
|
|
592
966
|
// ../api-contract/src/schemas/sequences.ts
|
|
593
967
|
var mailTypes = ["broadcast", "sequence"];
|
|
594
968
|
var emailActionTypes = ["tag:add", "tag:remove"];
|
|
969
|
+
var triggerTypes = [
|
|
970
|
+
"subscriber:added",
|
|
971
|
+
"tag:added",
|
|
972
|
+
"tag:removed",
|
|
973
|
+
"date:occurred",
|
|
974
|
+
"event:custom",
|
|
975
|
+
"contact:property_changed"
|
|
976
|
+
];
|
|
977
|
+
var reentryModes = ["every_time", "once", "once_per_period"];
|
|
595
978
|
var sequenceEmailSchema = zod.z.object({
|
|
596
979
|
// NOTE: intentionally no `id`/`sequenceId` here — `sequence_emails.id` is
|
|
597
980
|
// internal-only, and its `sequence_id` column holds the *parent*
|
|
@@ -610,6 +993,15 @@ var sequenceEmailSchema = zod.z.object({
|
|
|
610
993
|
/** Hosted content check: `clean`, `review` (held for SendLit's review),
|
|
611
994
|
* `blocked`, or `approved` after review; `null` when not scanned. */
|
|
612
995
|
contentScanVerdict: zod.z.string().nullable().optional(),
|
|
996
|
+
/** Unpublished edits saved while the broadcast or sequence is active. `subject` and
|
|
997
|
+
* `content` above are the published version that sends use. */
|
|
998
|
+
draft: zod.z.object({
|
|
999
|
+
subject: zod.z.string(),
|
|
1000
|
+
content: emailContentSchema,
|
|
1001
|
+
updatedAt: zod.z.string().nullable()
|
|
1002
|
+
}).nullable().optional(),
|
|
1003
|
+
/** Whether `draft` holds changes that aren't published yet. */
|
|
1004
|
+
hasUnpublishedChanges: zod.z.boolean().optional(),
|
|
613
1005
|
createdAt: zod.z.string().nullable(),
|
|
614
1006
|
updatedAt: zod.z.string().nullable()
|
|
615
1007
|
});
|
|
@@ -688,8 +1080,14 @@ var sequenceSchema = zod.z.object({
|
|
|
688
1080
|
title: zod.z.string(),
|
|
689
1081
|
status: zod.z.string(),
|
|
690
1082
|
deliverySource: deliverySourceSelectionSchema.nullable(),
|
|
691
|
-
triggerType: zod.z.
|
|
1083
|
+
triggerType: zod.z.enum(triggerTypes).nullable().optional(),
|
|
692
1084
|
triggerData: zod.z.string().nullable().optional(),
|
|
1085
|
+
/** Property filter (`event:custom`) or from/to filter
|
|
1086
|
+
* (`contact:property_changed`). */
|
|
1087
|
+
triggerFilter: zod.z.any().nullable().optional(),
|
|
1088
|
+
/** Who can enter again: sequences only. */
|
|
1089
|
+
reentry: zod.z.enum(reentryModes).optional(),
|
|
1090
|
+
reentryPeriodDays: zod.z.number().int().nullable().optional(),
|
|
693
1091
|
filter: zod.z.any().nullable().optional(),
|
|
694
1092
|
excludeFilter: zod.z.any().nullable().optional(),
|
|
695
1093
|
/** Active enrollments for a sequence or its locked recipient count for a broadcast. */
|
|
@@ -697,9 +1095,16 @@ var sequenceSchema = zod.z.object({
|
|
|
697
1095
|
emailsOrder: zod.z.array(zod.z.string()),
|
|
698
1096
|
entrants: zod.z.array(zod.z.string()),
|
|
699
1097
|
report: zod.z.any(),
|
|
1098
|
+
/** Whether sends link a hosted web version ("View in browser"). On for
|
|
1099
|
+
* new broadcasts, off for new sequences. */
|
|
1100
|
+
viewInBrowser: zod.z.boolean(),
|
|
1101
|
+
/** When a sent broadcast was archived; `null` when it isn't. */
|
|
1102
|
+
archivedAt: zod.z.string().nullable().optional(),
|
|
700
1103
|
createdAt: zod.z.string().nullable(),
|
|
701
1104
|
updatedAt: zod.z.string().nullable(),
|
|
702
1105
|
emails: zod.z.array(sequenceEmailSchema),
|
|
1106
|
+
/** Whether any of its emails has unpublished changes. */
|
|
1107
|
+
hasUnpublishedChanges: zod.z.boolean().optional(),
|
|
703
1108
|
/** Set while a running broadcast of a new hosted organization is sent
|
|
704
1109
|
* gradually (`get` only). */
|
|
705
1110
|
pacing: zod.z.object({
|
|
@@ -710,8 +1115,12 @@ var sequenceSchema = zod.z.object({
|
|
|
710
1115
|
estimatedCompletionAt: zod.z.string()
|
|
711
1116
|
}).nullable().optional()
|
|
712
1117
|
});
|
|
1118
|
+
var archivedFilters = ["exclude", "only", "include"];
|
|
713
1119
|
var listSequencesQuerySchema = zod.z.object({
|
|
714
1120
|
type: zod.z.enum(mailTypes),
|
|
1121
|
+
archived: zod.z.enum(archivedFilters).optional().describe(
|
|
1122
|
+
"Archived broadcasts: exclude (default) hides them, only lists just them, include lists both"
|
|
1123
|
+
),
|
|
715
1124
|
offset: zod.z.coerce.number().int().min(1).optional(),
|
|
716
1125
|
itemsPerPage: zod.z.coerce.number().int().min(1).max(50).optional()
|
|
717
1126
|
});
|
|
@@ -722,8 +1131,19 @@ var createSequenceBodySchema = zod.z.object({
|
|
|
722
1131
|
});
|
|
723
1132
|
var updateSequenceBodySchema = zod.z.object({
|
|
724
1133
|
title: zod.z.string().optional(),
|
|
725
|
-
triggerType: zod.z.
|
|
726
|
-
|
|
1134
|
+
triggerType: zod.z.enum(triggerTypes).optional().describe(
|
|
1135
|
+
"Broadcasts use date:occurred. Sequences: subscriber:added, tag:added, tag:removed, event:custom or contact:property_changed."
|
|
1136
|
+
),
|
|
1137
|
+
triggerData: zod.z.string().optional().describe(
|
|
1138
|
+
"Tag name for tag triggers, event name for event:custom, custom field key for contact:property_changed."
|
|
1139
|
+
),
|
|
1140
|
+
triggerFilter: zod.z.union([eventPropertyFilterSchema, propertyChangeFilterSchema]).nullable().optional().describe(
|
|
1141
|
+
"event:custom: { aggregator, filters: [{ key, condition, value }] }. contact:property_changed: { from?, to? }. null clears it."
|
|
1142
|
+
),
|
|
1143
|
+
reentry: zod.z.enum(reentryModes).optional().describe(
|
|
1144
|
+
"Sequences only. every_time (default), once, or once_per_period with reentryPeriodDays."
|
|
1145
|
+
),
|
|
1146
|
+
reentryPeriodDays: zod.z.number().int().min(1).max(365).nullable().optional(),
|
|
727
1147
|
filter: contactFilterSchema.optional().describe(
|
|
728
1148
|
"Audience: subscribed contacts matching this filter; empty means everyone"
|
|
729
1149
|
),
|
|
@@ -732,7 +1152,10 @@ var updateSequenceBodySchema = zod.z.object({
|
|
|
732
1152
|
),
|
|
733
1153
|
emailsOrder: zod.z.array(zod.z.string()).optional(),
|
|
734
1154
|
/** `null` clears the intent so the default is resolved on next start. */
|
|
735
|
-
deliverySource: deliverySourceSelectionSchema.nullable().optional()
|
|
1155
|
+
deliverySource: deliverySourceSelectionSchema.nullable().optional(),
|
|
1156
|
+
viewInBrowser: zod.z.boolean().optional().describe(
|
|
1157
|
+
'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.'
|
|
1158
|
+
)
|
|
736
1159
|
});
|
|
737
1160
|
var addSequenceEmailBodySchema = zod.z.object({
|
|
738
1161
|
templateId: zod.z.string().min(1)
|
|
@@ -746,6 +1169,24 @@ var updateSequenceEmailBodySchema = zod.z.object({
|
|
|
746
1169
|
actionData: zod.z.record(zod.z.any()).optional(),
|
|
747
1170
|
published: zod.z.boolean().optional()
|
|
748
1171
|
});
|
|
1172
|
+
var publishScopes = ["in_flight", "new_entrants"];
|
|
1173
|
+
var emailIdsSchema = zod.z.array(zod.z.string()).min(1).optional().describe("The emails to act on; omit for every email with unpublished changes");
|
|
1174
|
+
var publishSequenceChangesBodySchema = zod.z.object({
|
|
1175
|
+
emailIds: emailIdsSchema,
|
|
1176
|
+
scope: zod.z.enum(publishScopes).optional().describe(
|
|
1177
|
+
"Sequences only. in_flight (default): contacts already in the sequence get the new version at their next step. new_entrants: they keep the version they entered with; only contacts who enter from now on get the new one."
|
|
1178
|
+
)
|
|
1179
|
+
});
|
|
1180
|
+
var discardSequenceChangesBodySchema = zod.z.object({
|
|
1181
|
+
emailIds: emailIdsSchema
|
|
1182
|
+
});
|
|
1183
|
+
var sequenceEmailVersionSchema = zod.z.object({
|
|
1184
|
+
versionId: zod.z.string(),
|
|
1185
|
+
subject: zod.z.string(),
|
|
1186
|
+
content: emailContentSchema,
|
|
1187
|
+
publishedAt: zod.z.string().describe("When this version last went live"),
|
|
1188
|
+
live: zod.z.boolean().describe("Whether sends use this version now")
|
|
1189
|
+
});
|
|
749
1190
|
var sendSequenceEmailTestBodySchema = zod.z.object({
|
|
750
1191
|
to: zod.z.array(zod.z.string().email()).max(5).optional().describe(
|
|
751
1192
|
"Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
|
|
@@ -754,7 +1195,10 @@ var sendSequenceEmailTestBodySchema = zod.z.object({
|
|
|
754
1195
|
var sequenceEmailTestResultSchema = zod.z.object({
|
|
755
1196
|
sent: zod.z.array(zod.z.string()).describe("Addresses the test was sent to"),
|
|
756
1197
|
skipped: zod.z.array(zod.z.object({ email: zod.z.string(), reason: zod.z.enum(["suppressed"]) })).describe("Addresses on the suppression list, which never get mail"),
|
|
757
|
-
lastTestSentAt: zod.z.string().nullable()
|
|
1198
|
+
lastTestSentAt: zod.z.string().nullable(),
|
|
1199
|
+
/** Event-triggered sequences: `last_event` when `{{ event.* }}` used the
|
|
1200
|
+
* last payload received for the event, `none` when there is none yet. */
|
|
1201
|
+
eventSample: zod.z.enum(["last_event", "none"]).optional()
|
|
758
1202
|
});
|
|
759
1203
|
var sequenceStatsSchema = zod.z.object({
|
|
760
1204
|
sent: zod.z.number(),
|
|
@@ -765,6 +1209,42 @@ var sequenceStatsSchema = zod.z.object({
|
|
|
765
1209
|
bounceRate: zod.z.number().optional(),
|
|
766
1210
|
complaintRate: zod.z.number().optional()
|
|
767
1211
|
});
|
|
1212
|
+
var sequenceScheduleSchema = zod.z.object({
|
|
1213
|
+
waiting: zod.z.number().describe("Contacts in the sequence who are waiting for their next email"),
|
|
1214
|
+
emails: zod.z.array(
|
|
1215
|
+
zod.z.object({
|
|
1216
|
+
emailId: zod.z.string(),
|
|
1217
|
+
waiting: zod.z.number().describe("Contacts whose next email is this one"),
|
|
1218
|
+
nextSendAt: zod.z.number().nullable().describe(
|
|
1219
|
+
"The earliest due time among them (epoch millis), not a time they share: each contact's delay counts from their own entry. null when no one is waiting"
|
|
1220
|
+
)
|
|
1221
|
+
})
|
|
1222
|
+
)
|
|
1223
|
+
});
|
|
1224
|
+
var waitingContactSchema = zod.z.object({
|
|
1225
|
+
contactId: zod.z.string(),
|
|
1226
|
+
email: zod.z.string(),
|
|
1227
|
+
name: zod.z.string().nullable(),
|
|
1228
|
+
nextSendAt: zod.z.number().describe("When this contact is due to get the email (epoch millis)")
|
|
1229
|
+
});
|
|
1230
|
+
var listWaitingContactsQuerySchema = zod.z.object({
|
|
1231
|
+
after: zod.z.string().optional().describe("The previous page's `nextCursor`; omit for the first page"),
|
|
1232
|
+
limit: zod.z.coerce.number().int().min(1).max(100).optional(),
|
|
1233
|
+
q: zod.z.string().optional().describe("Matches the contact's email or name")
|
|
1234
|
+
});
|
|
1235
|
+
var waitingContactsPageSchema = zod.z.object({
|
|
1236
|
+
items: zod.z.array(waitingContactSchema),
|
|
1237
|
+
total: zod.z.number().describe("Every waiting contact that matches, across all pages"),
|
|
1238
|
+
nextCursor: zod.z.string().nullable().describe("Pass as `after` for the next page; null on the last page")
|
|
1239
|
+
});
|
|
1240
|
+
var sequenceDeletionPreviewSchema = zod.z.object({
|
|
1241
|
+
status: zod.z.string().describe("The broadcast or sequence's current status"),
|
|
1242
|
+
blocker: zod.z.enum(["sequence_active", "broadcast_sent"]).nullable().describe(
|
|
1243
|
+
"Why it can't be deleted right now (sequence_active: pause it first; broadcast_sent: archive the broadcast instead), or null when it can"
|
|
1244
|
+
),
|
|
1245
|
+
enrolledCount: zod.z.number().int().describe("Contacts currently in the sequence; deleting it stops their emails"),
|
|
1246
|
+
emailsSentCount: zod.z.number().int().describe("Emails it has sent; their delivery, open and click history is deleted")
|
|
1247
|
+
});
|
|
768
1248
|
var listSubscribersQuerySchema = zod.z.object({
|
|
769
1249
|
page: zod.z.coerce.number().int().min(1).optional(),
|
|
770
1250
|
limit: zod.z.coerce.number().int().min(1).optional()
|
|
@@ -862,6 +1342,46 @@ var exportContactsQuerySchema = zod.z.object({
|
|
|
862
1342
|
segmentId: zod.z.string().optional().describe("Only export this saved segment"),
|
|
863
1343
|
filter: zod.z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
|
|
864
1344
|
});
|
|
1345
|
+
var contactSelectionObjectSchema = zod.z.object({
|
|
1346
|
+
contactIds: zod.z.array(zod.z.string().min(1)).min(1).max(1e3).optional().describe("Contact IDs, up to 1000. Unknown IDs are ignored."),
|
|
1347
|
+
match: zod.z.object({
|
|
1348
|
+
q: zod.z.string().optional().describe("Search term matched against email or name"),
|
|
1349
|
+
segmentId: zod.z.string().optional().describe("Only contacts in this saved segment"),
|
|
1350
|
+
filter: contactFilterSchema.optional().describe("Inline ContactFilterWithAggregator; combines with q and segmentId")
|
|
1351
|
+
}).optional().describe(
|
|
1352
|
+
"Every contact matching q, segmentId and filter (AND). `{}` selects every contact in the team."
|
|
1353
|
+
)
|
|
1354
|
+
});
|
|
1355
|
+
var exactlyOneSelection = (body) => Boolean(body.contactIds) !== Boolean(body.match);
|
|
1356
|
+
var exactlyOneSelectionMessage = {
|
|
1357
|
+
message: "Pass exactly one of contactIds or match"
|
|
1358
|
+
};
|
|
1359
|
+
var contactSelectionSchema = contactSelectionObjectSchema.refine(
|
|
1360
|
+
exactlyOneSelection,
|
|
1361
|
+
exactlyOneSelectionMessage
|
|
1362
|
+
);
|
|
1363
|
+
var previewContactDeletionResultSchema = zod.z.object({
|
|
1364
|
+
count: zod.z.number().int().describe("Contacts that would be deleted right now"),
|
|
1365
|
+
unsubscribed: zod.z.number().int().describe(
|
|
1366
|
+
"How many of them are unsubscribed; their addresses are added to the suppression list"
|
|
1367
|
+
)
|
|
1368
|
+
});
|
|
1369
|
+
var deleteContactsObjectSchema = contactSelectionObjectSchema.extend({
|
|
1370
|
+
expectedCount: zod.z.number().int().min(0).optional().describe(
|
|
1371
|
+
"The count from the preview. Required with match: if the live count differs, nothing is deleted and the response is 409 count_changed."
|
|
1372
|
+
)
|
|
1373
|
+
});
|
|
1374
|
+
var deleteContactsBodySchema = deleteContactsObjectSchema.refine(exactlyOneSelection, exactlyOneSelectionMessage).refine((body) => !body.match || body.expectedCount !== void 0, {
|
|
1375
|
+
message: "expectedCount is required with match",
|
|
1376
|
+
path: ["expectedCount"]
|
|
1377
|
+
});
|
|
1378
|
+
var contactDeletionSchema = zod.z.object({
|
|
1379
|
+
deletionId: zod.z.string().nullable().describe("Background job id for large deletions; null when it ran inline"),
|
|
1380
|
+
status: zod.z.enum(["queued", "running", "completed", "failed"]),
|
|
1381
|
+
count: zod.z.number().int().describe("Contacts selected for deletion"),
|
|
1382
|
+
deleted: zod.z.number().int().describe("Contacts deleted so far"),
|
|
1383
|
+
suppressed: zod.z.number().int().describe("Unsubscribed addresses newly added to the suppression list")
|
|
1384
|
+
});
|
|
865
1385
|
var deliveryEventType = [
|
|
866
1386
|
"accepted",
|
|
867
1387
|
"delivered",
|
|
@@ -1081,6 +1601,14 @@ var testFeedbackConnectionResponseSchema = zod.z.object({
|
|
|
1081
1601
|
success: zod.z.boolean(),
|
|
1082
1602
|
error: zod.z.string().optional()
|
|
1083
1603
|
});
|
|
1604
|
+
var feedbackRequirementSchema = zod.z.object({
|
|
1605
|
+
/** False on self-hosted SendLit, where the rule doesn't apply. */
|
|
1606
|
+
required: zod.z.boolean(),
|
|
1607
|
+
/** Emails the organization can send before the rule applies. */
|
|
1608
|
+
requiredAfterSends: zod.z.number().int(),
|
|
1609
|
+
/** Emails the organization has sent so far, across all its teams. */
|
|
1610
|
+
sentSoFar: zod.z.number().int()
|
|
1611
|
+
});
|
|
1084
1612
|
var signupFormSchema = zod.z.object({
|
|
1085
1613
|
formId: zod.z.string(),
|
|
1086
1614
|
name: zod.z.string(),
|
|
@@ -1099,158 +1627,48 @@ var signupFormSenderErrorSchema = zod.z.object({
|
|
|
1099
1627
|
message: zod.z.string()
|
|
1100
1628
|
});
|
|
1101
1629
|
var createSignupFormBodySchema = zod.z.object({
|
|
1102
|
-
name: zod.z.string().trim().min(1).max(200),
|
|
1103
|
-
tags: zod.z.array(zod.z.string().min(1)).max(20).optional().describe("Added to everyone who subscribes through the form"),
|
|
1104
|
-
doubleOptIn: zod.z.boolean().optional().describe(
|
|
1105
|
-
"Send a confirmation email and subscribe only once it's clicked (default true)"
|
|
1106
|
-
),
|
|
1107
|
-
redirectUrl: zod.z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL").nullable().optional().describe("Where to send people after they submit the hosted or embedded form")
|
|
1108
|
-
});
|
|
1109
|
-
var updateSignupFormBodySchema = createSignupFormBodySchema.partial();
|
|
1110
|
-
var mediaSchema = zod.z.object({
|
|
1111
|
-
mediaId: zod.z.string(),
|
|
1112
|
-
url: zod.z.string(),
|
|
1113
|
-
thumbnailUrl: zod.z.string().nullable().optional(),
|
|
1114
|
-
mediaLitId: zod.z.string(),
|
|
1115
|
-
fileName: zod.z.string().nullable().optional(),
|
|
1116
|
-
mimeType: zod.z.string().nullable().optional(),
|
|
1117
|
-
size: zod.z.number().nullable().optional(),
|
|
1118
|
-
width: zod.z.number().nullable().optional(),
|
|
1119
|
-
height: zod.z.number().nullable().optional(),
|
|
1120
|
-
alt: zod.z.string().nullable().optional(),
|
|
1121
|
-
caption: zod.z.string().nullable().optional(),
|
|
1122
|
-
createdAt: zod.z.string().or(zod.z.date()).nullable().optional(),
|
|
1123
|
-
updatedAt: zod.z.string().or(zod.z.date()).nullable().optional()
|
|
1124
|
-
});
|
|
1125
|
-
var mediaReferenceSchema = zod.z.object({
|
|
1126
|
-
resourceType: zod.z.enum(["TEMPLATE", "SEQUENCE_EMAIL"]),
|
|
1127
|
-
resourcePublicId: zod.z.string(),
|
|
1128
|
-
parentResourcePublicId: zod.z.string().nullable().optional(),
|
|
1129
|
-
createdAt: zod.z.string().or(zod.z.date()).nullable().optional(),
|
|
1130
|
-
updatedAt: zod.z.string().or(zod.z.date()).nullable().optional()
|
|
1131
|
-
});
|
|
1132
|
-
var listMediaQuerySchema = zod.z.object({
|
|
1133
|
-
page: zod.z.coerce.number().int().min(1).optional(),
|
|
1134
|
-
pageSize: zod.z.coerce.number().int().min(1).max(100).optional(),
|
|
1135
|
-
query: zod.z.string().optional()
|
|
1136
|
-
});
|
|
1137
|
-
var updateMediaBodySchema = zod.z.object({
|
|
1138
|
-
alt: zod.z.string().nullable().optional(),
|
|
1139
|
-
caption: zod.z.string().nullable().optional()
|
|
1140
|
-
});
|
|
1141
|
-
var mediaUploadSignatureSchema = zod.z.object({
|
|
1142
|
-
signature: zod.z.string(),
|
|
1143
|
-
endpoint: zod.z.string()
|
|
1144
|
-
});
|
|
1145
|
-
var organizationRoleSchema = zod.z.enum(["owner", "admin", "member"]);
|
|
1146
|
-
var organizationSchema = zod.z.object({
|
|
1147
|
-
organizationId: zod.z.string(),
|
|
1148
|
-
name: zod.z.string(),
|
|
1149
|
-
status: zod.z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
|
|
1150
|
-
createdAt: zod.z.string(),
|
|
1151
|
-
updatedAt: zod.z.string()
|
|
1152
|
-
});
|
|
1153
|
-
var organizationMemberSchema = zod.z.object({
|
|
1154
|
-
userId: zod.z.string(),
|
|
1155
|
-
email: zod.z.string().email(),
|
|
1156
|
-
name: zod.z.string(),
|
|
1157
|
-
image: zod.z.string().nullable(),
|
|
1158
|
-
role: organizationRoleSchema,
|
|
1159
|
-
createdAt: zod.z.string(),
|
|
1160
|
-
updatedAt: zod.z.string()
|
|
1161
|
-
});
|
|
1162
|
-
var createOrganizationBodySchema = zod.z.object({
|
|
1163
|
-
name: zod.z.string().trim().min(1)
|
|
1164
|
-
});
|
|
1165
|
-
var updateOrganizationBodySchema = zod.z.object({
|
|
1166
|
-
name: zod.z.string().trim().min(1)
|
|
1167
|
-
});
|
|
1168
|
-
var addOrganizationMemberBodySchema = zod.z.object({
|
|
1169
|
-
/** Existing Better Auth user only. This is a membership lookup, never an
|
|
1170
|
-
* authentication or account-creation flow. */
|
|
1171
|
-
email: zod.z.string().trim().email(),
|
|
1172
|
-
role: organizationRoleSchema
|
|
1173
|
-
});
|
|
1174
|
-
var updateOrganizationMemberBodySchema = zod.z.object({
|
|
1175
|
-
role: organizationRoleSchema
|
|
1176
|
-
});
|
|
1177
|
-
var organizationKeyScopes = [
|
|
1178
|
-
"organization:read",
|
|
1179
|
-
"delivery:read",
|
|
1180
|
-
"delivery:manage",
|
|
1181
|
-
"teams:provision",
|
|
1182
|
-
"teams:read",
|
|
1183
|
-
"teams:manage",
|
|
1184
|
-
"teams:keys",
|
|
1185
|
-
"esps:read",
|
|
1186
|
-
"esps:manage",
|
|
1187
|
-
"grants:manage",
|
|
1188
|
-
"usage:read"
|
|
1189
|
-
];
|
|
1190
|
-
var organizationApiKeySchema = zod.z.object({
|
|
1191
|
-
keyId: zod.z.string(),
|
|
1192
|
-
name: zod.z.string(),
|
|
1193
|
-
keyPrefix: zod.z.string(),
|
|
1194
|
-
scopes: zod.z.array(zod.z.enum(organizationKeyScopes)),
|
|
1195
|
-
expiresAt: zod.z.string().nullable(),
|
|
1196
|
-
lastUsedAt: zod.z.string().nullable(),
|
|
1197
|
-
revokedAt: zod.z.string().nullable(),
|
|
1198
|
-
createdAt: zod.z.string()
|
|
1199
|
-
});
|
|
1200
|
-
var createOrganizationApiKeyBodySchema = zod.z.object({
|
|
1201
|
-
name: zod.z.string().trim().min(1),
|
|
1202
|
-
scopes: zod.z.array(zod.z.enum(organizationKeyScopes)).min(1),
|
|
1203
|
-
expiresAt: zod.z.string().datetime().nullable().optional()
|
|
1204
|
-
});
|
|
1205
|
-
var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
|
|
1206
|
-
key: zod.z.string()
|
|
1207
|
-
});
|
|
1208
|
-
var organizationUsageWindowSchema = zod.z.object({
|
|
1209
|
-
limit: zod.z.number().int().nullable(),
|
|
1210
|
-
accepted: zod.z.number().int().nonnegative(),
|
|
1211
|
-
reserved: zod.z.number().int().nonnegative(),
|
|
1212
|
-
remaining: zod.z.number().int().nullable(),
|
|
1213
|
-
resetsAt: zod.z.string()
|
|
1214
|
-
});
|
|
1215
|
-
var organizationUsageSchema = zod.z.object({
|
|
1216
|
-
day: organizationUsageWindowSchema,
|
|
1217
|
-
month: organizationUsageWindowSchema
|
|
1218
|
-
});
|
|
1219
|
-
var organizationMailActivityQuerySchema = zod.z.object({
|
|
1220
|
-
rangeDays: zod.z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
|
|
1630
|
+
name: zod.z.string().trim().min(1).max(200),
|
|
1631
|
+
tags: zod.z.array(zod.z.string().min(1)).max(20).optional().describe("Added to everyone who subscribes through the form"),
|
|
1632
|
+
doubleOptIn: zod.z.boolean().optional().describe(
|
|
1633
|
+
"Send a confirmation email and subscribe only once it's clicked (default true)"
|
|
1634
|
+
),
|
|
1635
|
+
redirectUrl: zod.z.string().url().refine((value) => /^https?:\/\//i.test(value), "Must be an http(s) URL").nullable().optional().describe("Where to send people after they submit the hosted or embedded form")
|
|
1221
1636
|
});
|
|
1222
|
-
var
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1637
|
+
var updateSignupFormBodySchema = createSignupFormBodySchema.partial();
|
|
1638
|
+
var mediaSchema = zod.z.object({
|
|
1639
|
+
mediaId: zod.z.string(),
|
|
1640
|
+
url: zod.z.string(),
|
|
1641
|
+
thumbnailUrl: zod.z.string().nullable().optional(),
|
|
1642
|
+
mediaLitId: zod.z.string(),
|
|
1643
|
+
fileName: zod.z.string().nullable().optional(),
|
|
1644
|
+
mimeType: zod.z.string().nullable().optional(),
|
|
1645
|
+
size: zod.z.number().nullable().optional(),
|
|
1646
|
+
width: zod.z.number().nullable().optional(),
|
|
1647
|
+
height: zod.z.number().nullable().optional(),
|
|
1648
|
+
alt: zod.z.string().nullable().optional(),
|
|
1649
|
+
caption: zod.z.string().nullable().optional(),
|
|
1650
|
+
createdAt: zod.z.string().or(zod.z.date()).nullable().optional(),
|
|
1651
|
+
updatedAt: zod.z.string().or(zod.z.date()).nullable().optional()
|
|
1227
1652
|
});
|
|
1228
|
-
var
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1653
|
+
var mediaReferenceSchema = zod.z.object({
|
|
1654
|
+
resourceType: zod.z.enum(["TEMPLATE", "SEQUENCE_EMAIL", "BROADCAST_WEB_PAGE"]),
|
|
1655
|
+
resourcePublicId: zod.z.string(),
|
|
1656
|
+
parentResourcePublicId: zod.z.string().nullable().optional(),
|
|
1657
|
+
createdAt: zod.z.string().or(zod.z.date()).nullable().optional(),
|
|
1658
|
+
updatedAt: zod.z.string().or(zod.z.date()).nullable().optional()
|
|
1234
1659
|
});
|
|
1235
|
-
var
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1660
|
+
var listMediaQuerySchema = zod.z.object({
|
|
1661
|
+
page: zod.z.coerce.number().int().min(1).optional(),
|
|
1662
|
+
pageSize: zod.z.coerce.number().int().min(1).max(100).optional(),
|
|
1663
|
+
query: zod.z.string().optional()
|
|
1239
1664
|
});
|
|
1240
|
-
var
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
role: zod.z.enum(["admin", "member"]),
|
|
1244
|
-
created: zod.z.boolean()
|
|
1665
|
+
var updateMediaBodySchema = zod.z.object({
|
|
1666
|
+
alt: zod.z.string().nullable().optional(),
|
|
1667
|
+
caption: zod.z.string().nullable().optional()
|
|
1245
1668
|
});
|
|
1246
|
-
var
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
teamId: zod.z.string().nullable(),
|
|
1250
|
-
espId: zod.z.string().nullable(),
|
|
1251
|
-
grantId: zod.z.string().nullable(),
|
|
1252
|
-
metadata: zod.z.record(zod.z.any()),
|
|
1253
|
-
createdAt: zod.z.string()
|
|
1669
|
+
var mediaUploadSignatureSchema = zod.z.object({
|
|
1670
|
+
signature: zod.z.string(),
|
|
1671
|
+
endpoint: zod.z.string()
|
|
1254
1672
|
});
|
|
1255
1673
|
var overviewQuerySchema = zod.z.object({
|
|
1256
1674
|
/** Delivery activity window, in days. Defaults to the last 7 days. */
|
|
@@ -1414,6 +1832,47 @@ var createSuppressionBodySchema = zod.z.object({
|
|
|
1414
1832
|
"Why the address is blocked, e.g. a legal request; kept in the audit trail"
|
|
1415
1833
|
)
|
|
1416
1834
|
});
|
|
1835
|
+
var tagSummarySchema = zod.z.object({
|
|
1836
|
+
tag: zod.z.string(),
|
|
1837
|
+
contactCount: zod.z.number().int()
|
|
1838
|
+
});
|
|
1839
|
+
var tagSequenceUsageSchema = zod.z.enum([
|
|
1840
|
+
"filter",
|
|
1841
|
+
"exclude_filter",
|
|
1842
|
+
"trigger",
|
|
1843
|
+
"email_action"
|
|
1844
|
+
]);
|
|
1845
|
+
var tagReferencesSchema = zod.z.object({
|
|
1846
|
+
tag: zod.z.string(),
|
|
1847
|
+
contactCount: zod.z.number().int(),
|
|
1848
|
+
segments: zod.z.array(zod.z.object({ segmentId: zod.z.string(), name: zod.z.string() })),
|
|
1849
|
+
sequences: zod.z.array(
|
|
1850
|
+
zod.z.object({
|
|
1851
|
+
sequenceId: zod.z.string(),
|
|
1852
|
+
title: zod.z.string(),
|
|
1853
|
+
type: zod.z.enum(["broadcast", "sequence"]),
|
|
1854
|
+
status: zod.z.string(),
|
|
1855
|
+
usages: zod.z.array(tagSequenceUsageSchema)
|
|
1856
|
+
})
|
|
1857
|
+
),
|
|
1858
|
+
signupForms: zod.z.array(zod.z.object({ formId: zod.z.string(), name: zod.z.string() }))
|
|
1859
|
+
});
|
|
1860
|
+
var renameTagBodySchema = zod.z.object({
|
|
1861
|
+
name: zod.z.string().trim().min(1).describe("The tag's new name")
|
|
1862
|
+
});
|
|
1863
|
+
var renameTagResultSchema = zod.z.object({
|
|
1864
|
+
tag: zod.z.string(),
|
|
1865
|
+
previousTag: zod.z.string(),
|
|
1866
|
+
contactsUpdated: zod.z.number().int(),
|
|
1867
|
+
segmentsUpdated: zod.z.number().int(),
|
|
1868
|
+
sequencesUpdated: zod.z.number().int(),
|
|
1869
|
+
signupFormsUpdated: zod.z.number().int()
|
|
1870
|
+
});
|
|
1871
|
+
var deleteTagResultSchema = zod.z.object({
|
|
1872
|
+
tag: zod.z.string(),
|
|
1873
|
+
contactsUpdated: zod.z.number().int(),
|
|
1874
|
+
references: tagReferencesSchema
|
|
1875
|
+
});
|
|
1417
1876
|
var teamSchema = zod.z.object({
|
|
1418
1877
|
teamId: zod.z.string(),
|
|
1419
1878
|
/** Public organization identifier. Present when an end user lists the
|
|
@@ -1667,7 +2126,7 @@ var webPublishingSchema = zod.z.object({
|
|
|
1667
2126
|
ogImage: zod.z.string().nullable(),
|
|
1668
2127
|
noindex: zod.z.boolean(),
|
|
1669
2128
|
canonicalUrl: zod.z.string().nullable(),
|
|
1670
|
-
/** Published and
|
|
2129
|
+
/** Published, already sent and not archived, so the page is public. */
|
|
1671
2130
|
live: zod.z.boolean(),
|
|
1672
2131
|
/** When the issue was sent; `null` until then. */
|
|
1673
2132
|
publishedAt: zod.z.string().nullable(),
|
|
@@ -1679,7 +2138,9 @@ var updateWebPublishingBodySchema = zod.z.object({
|
|
|
1679
2138
|
slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
|
|
1680
2139
|
seoTitle: zod.z.string().trim().max(200).nullable().optional(),
|
|
1681
2140
|
seoDescription: zod.z.string().trim().max(500).nullable().optional(),
|
|
1682
|
-
ogImage: httpUrl.nullable().optional().describe(
|
|
2141
|
+
ogImage: httpUrl.nullable().optional().describe(
|
|
2142
|
+
"Image for social previews. An image uploaded to MediaLit is added to the media library and can't be deleted while the page uses it"
|
|
2143
|
+
),
|
|
1683
2144
|
noindex: zod.z.boolean().optional().describe("Ask search engines not to index the page"),
|
|
1684
2145
|
canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
|
|
1685
2146
|
});
|
|
@@ -1773,6 +2234,39 @@ var contactsContract = c.router(
|
|
|
1773
2234
|
summary: "Export contacts as CSV",
|
|
1774
2235
|
description: "Returns every contact, or those matching segmentId and/or filter, as CSV: email, name, status (subscribed, unsubscribed, bounced or complained), tags, created_at, suppression_reason, then one column per custom field."
|
|
1775
2236
|
},
|
|
2237
|
+
previewBulkDelete: {
|
|
2238
|
+
method: "POST",
|
|
2239
|
+
path: "/contacts/bulk-delete/preview",
|
|
2240
|
+
body: contactSelectionSchema,
|
|
2241
|
+
responses: {
|
|
2242
|
+
200: previewContactDeletionResultSchema,
|
|
2243
|
+
400: errorSchema,
|
|
2244
|
+
404: errorSchema
|
|
2245
|
+
},
|
|
2246
|
+
summary: "Preview a bulk contact deletion",
|
|
2247
|
+
description: "Counts the contacts a bulk delete would remove (and how many are unsubscribed) without deleting anything. Pass the count to bulkDelete as expectedCount. 404 when segmentId doesn't exist."
|
|
2248
|
+
},
|
|
2249
|
+
bulkDelete: {
|
|
2250
|
+
method: "POST",
|
|
2251
|
+
path: "/contacts/bulk-delete",
|
|
2252
|
+
body: deleteContactsBodySchema,
|
|
2253
|
+
responses: {
|
|
2254
|
+
200: contactDeletionSchema,
|
|
2255
|
+
202: contactDeletionSchema,
|
|
2256
|
+
400: errorSchema,
|
|
2257
|
+
404: errorSchema,
|
|
2258
|
+
409: errorSchema.extend({ count: zod.z.number().int().optional() })
|
|
2259
|
+
},
|
|
2260
|
+
summary: "Delete contacts in bulk",
|
|
2261
|
+
description: "Permanently deletes up to 1000 contacts by id, or every contact matching q, segmentId and filter. With match, pass the preview's count as expectedCount; if the live count differs nothing is deleted (409 count_changed, with the new count). Only contacts that existed when the request arrived are deleted. Up to 1000 contacts are deleted before the response (200, status completed); larger selections run in the background (202, status queued) and report progress at GET /contacts/bulk-delete/{deletionId}. Each contact's custom field values, sequence progress, events and delivery records are deleted with it, and no sequence triggers fire. Suppressions are kept, and the address of every deleted unsubscribed contact is added to the suppression list (reason manual), so re-importing or re-adding it never mails it again. This is not a full privacy erasure: delivery logs and the suppression list keep the address."
|
|
2262
|
+
},
|
|
2263
|
+
bulkDeleteStatus: {
|
|
2264
|
+
method: "GET",
|
|
2265
|
+
path: "/contacts/bulk-delete/:deletionId",
|
|
2266
|
+
responses: { 200: contactDeletionSchema, 404: errorSchema },
|
|
2267
|
+
summary: "Get a bulk contact deletion",
|
|
2268
|
+
description: "Progress of a background bulk delete. Finished deletions are kept for 24 hours."
|
|
2269
|
+
},
|
|
1776
2270
|
get: {
|
|
1777
2271
|
method: "GET",
|
|
1778
2272
|
path: "/contacts/:contactId",
|
|
@@ -1813,6 +2307,14 @@ var contactsContract = c.router(
|
|
|
1813
2307
|
},
|
|
1814
2308
|
summary: "List broadcasts/sequence emails delivered to a contact"
|
|
1815
2309
|
},
|
|
2310
|
+
events: {
|
|
2311
|
+
method: "GET",
|
|
2312
|
+
path: "/contacts/:contactId/events",
|
|
2313
|
+
query: listContactEventsQuerySchema,
|
|
2314
|
+
responses: { 200: paginated(contactEventSchema), 404: errorSchema },
|
|
2315
|
+
summary: "List the custom events received for a contact",
|
|
2316
|
+
description: "Newest first by occurredAt. `enrolledSequences` lists the sequences each event started."
|
|
2317
|
+
},
|
|
1816
2318
|
remove: {
|
|
1817
2319
|
method: "DELETE",
|
|
1818
2320
|
path: "/contacts/:contactId",
|
|
@@ -1822,6 +2324,45 @@ var contactsContract = c.router(
|
|
|
1822
2324
|
},
|
|
1823
2325
|
{ metadata: { tag: "Contacts" } }
|
|
1824
2326
|
);
|
|
2327
|
+
var tagsContract = c.router(
|
|
2328
|
+
{
|
|
2329
|
+
list: {
|
|
2330
|
+
method: "GET",
|
|
2331
|
+
path: "/tags",
|
|
2332
|
+
responses: { 200: itemsList(tagSummarySchema) },
|
|
2333
|
+
summary: "List tags",
|
|
2334
|
+
description: "Returns every tag carried by at least one of the team's contacts, sorted by name, with the number of contacts that carry it."
|
|
2335
|
+
},
|
|
2336
|
+
references: {
|
|
2337
|
+
method: "GET",
|
|
2338
|
+
path: "/tags/:tag/references",
|
|
2339
|
+
responses: { 200: tagReferencesSchema },
|
|
2340
|
+
summary: "List where a tag is used",
|
|
2341
|
+
description: "Returns how many contacts carry the tag and the segments, broadcasts, sequences (audience filters, tag triggers, email tag actions) and signup forms that name it. Call it before deleting a tag."
|
|
2342
|
+
},
|
|
2343
|
+
rename: {
|
|
2344
|
+
method: "PATCH",
|
|
2345
|
+
path: "/tags/:tag",
|
|
2346
|
+
body: renameTagBodySchema,
|
|
2347
|
+
responses: {
|
|
2348
|
+
200: renameTagResultSchema,
|
|
2349
|
+
400: errorSchema,
|
|
2350
|
+
404: errorSchema
|
|
2351
|
+
},
|
|
2352
|
+
summary: "Rename a tag",
|
|
2353
|
+
description: "Renames the tag on every contact, and in segments, broadcast and sequence filters and tag triggers, sequence email tag actions and signup forms. Renaming to a tag that already exists merges the two. Sent broadcasts keep their original filters. Renaming doesn't trigger tag-added or tag-removed sequences. 404 `tag_not_found` when nothing uses the tag; 400 `tag_unchanged` when the new name is the same."
|
|
2354
|
+
},
|
|
2355
|
+
remove: {
|
|
2356
|
+
method: "DELETE",
|
|
2357
|
+
path: "/tags/:tag",
|
|
2358
|
+
body: c.noBody(),
|
|
2359
|
+
responses: { 200: deleteTagResultSchema, 404: errorSchema },
|
|
2360
|
+
summary: "Delete a tag from every contact",
|
|
2361
|
+
description: "Removes the tag from every contact of the team. Segments, filters, triggers, email actions and signup forms that name the tag are left as they are and returned in `references`: a filter on a deleted tag matches nobody, and a trigger or form can add it again. Check `GET /tags/:tag/references` first. Deleting doesn't trigger tag-removed sequences. 404 `tag_not_found` when nothing uses the tag."
|
|
2362
|
+
}
|
|
2363
|
+
},
|
|
2364
|
+
{ metadata: { tag: "Tags" } }
|
|
2365
|
+
);
|
|
1825
2366
|
var segmentsContract = c.router(
|
|
1826
2367
|
{
|
|
1827
2368
|
create: {
|
|
@@ -1987,7 +2528,8 @@ var templatesContract = c.router(
|
|
|
1987
2528
|
method: "DELETE",
|
|
1988
2529
|
path: "/templates/:templateId",
|
|
1989
2530
|
responses: { 204: c.noBody() },
|
|
1990
|
-
summary: "Delete an email template"
|
|
2531
|
+
summary: "Delete an email template",
|
|
2532
|
+
description: "Permanently deletes the template. Its images that no other template or email uses are deleted from the media library and storage, unless a transactional email was sent with the template."
|
|
1991
2533
|
}
|
|
1992
2534
|
},
|
|
1993
2535
|
{ metadata: { tag: "Templates" } }
|
|
@@ -2011,7 +2553,8 @@ var sequencesContract = c.router(
|
|
|
2011
2553
|
path: "/sequences",
|
|
2012
2554
|
query: listSequencesQuerySchema,
|
|
2013
2555
|
responses: { 200: paginated(sequenceSchema) },
|
|
2014
|
-
summary: "List broadcasts or sequences"
|
|
2556
|
+
summary: "List broadcasts or sequences",
|
|
2557
|
+
description: "Archived broadcasts are left out unless `archived` is `only` or `include`."
|
|
2015
2558
|
},
|
|
2016
2559
|
get: {
|
|
2017
2560
|
method: "GET",
|
|
@@ -2029,13 +2572,37 @@ var sequencesContract = c.router(
|
|
|
2029
2572
|
404: errorSchema
|
|
2030
2573
|
},
|
|
2031
2574
|
summary: "Update a broadcast or sequence",
|
|
2032
|
-
description:
|
|
2575
|
+
description: "A broadcast's title is its email's published subject. While it's scheduled, a new title is saved as the email's draft subject (see `draft`) and becomes the title when the changes are published. 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."
|
|
2033
2576
|
},
|
|
2034
2577
|
remove: {
|
|
2035
2578
|
method: "DELETE",
|
|
2036
2579
|
path: "/sequences/:sequenceId",
|
|
2037
|
-
responses: { 204: c.noBody(), 404: errorSchema },
|
|
2038
|
-
summary: "Delete a broadcast or sequence"
|
|
2580
|
+
responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
|
|
2581
|
+
summary: "Delete a broadcast or sequence",
|
|
2582
|
+
description: "Permanently deletes the broadcast or sequence, its emails and triggers. An active sequence or a sending broadcast can't be deleted: pause it first (409 `sequence_active`). A draft or scheduled broadcast can be deleted; one that has started sending can't (409 `broadcast_sent`): archive it instead with POST /sequences/{sequenceId}/archive. Contacts still enrolled in a paused sequence leave it, and its delivery, open and click history is deleted too, so its stats are gone; check GET /sequences/{sequenceId}/deletion-preview first. The outbound message log and suppressions are kept. Images it uses that nothing else uses are deleted from the media library and storage; images used by sent mail are kept."
|
|
2583
|
+
},
|
|
2584
|
+
deletionPreview: {
|
|
2585
|
+
method: "GET",
|
|
2586
|
+
path: "/sequences/:sequenceId/deletion-preview",
|
|
2587
|
+
responses: { 200: sequenceDeletionPreviewSchema, 404: errorSchema },
|
|
2588
|
+
summary: "Preview what deleting a broadcast or sequence removes",
|
|
2589
|
+
description: "How many contacts are enrolled and how many emails it has sent, and whether it can be deleted right now. Nothing is changed."
|
|
2590
|
+
},
|
|
2591
|
+
archive: {
|
|
2592
|
+
method: "POST",
|
|
2593
|
+
path: "/sequences/:sequenceId/archive",
|
|
2594
|
+
body: c.noBody(),
|
|
2595
|
+
responses: { 200: sequenceSchema, 404: errorSchema, 409: errorSchema },
|
|
2596
|
+
summary: "Archive a sent broadcast",
|
|
2597
|
+
description: 'Hides a sent broadcast from the broadcasts list (see `archived` on GET /sequences) and from the public web archive, its feed and sitemap. Its report, delivery history and images are kept, and recipients\' "view in browser" links keep working. 409 `broadcast_not_sent` for a draft or scheduled broadcast (delete it instead) and `sequence_active` while it is sending. Archiving an archived broadcast changes nothing. 404 for sequences.'
|
|
2598
|
+
},
|
|
2599
|
+
unarchive: {
|
|
2600
|
+
method: "POST",
|
|
2601
|
+
path: "/sequences/:sequenceId/unarchive",
|
|
2602
|
+
body: c.noBody(),
|
|
2603
|
+
responses: { 200: sequenceSchema, 404: errorSchema },
|
|
2604
|
+
summary: "Restore an archived broadcast",
|
|
2605
|
+
description: "Puts an archived broadcast back in the broadcasts list, and back on the web archive when it is published there."
|
|
2039
2606
|
},
|
|
2040
2607
|
addEmail: {
|
|
2041
2608
|
method: "POST",
|
|
@@ -2061,7 +2628,50 @@ var sequencesContract = c.router(
|
|
|
2061
2628
|
422: templateNotMarketingErrorSchema
|
|
2062
2629
|
},
|
|
2063
2630
|
summary: "Update an email within a sequence",
|
|
2064
|
-
description:
|
|
2631
|
+
description: "When templateId is supplied, it must identify a marketing template; transactional templates return 422 template_not_marketing. While a broadcast or sequence is active (a running sequence or a scheduled broadcast), `subject` and `content` are saved as a draft (returned as the email's `draft`) and sends keep using the published version until the changes are published with POST /sequences/{sequenceId}/publish-changes. Otherwise nothing is sending, so they're saved directly, along with any open draft. Delay, published and tag action changes always apply right away. The \"view in browser\" page of an email already sent keeps showing what was sent. A sent broadcast can't be edited; the request returns it unchanged."
|
|
2632
|
+
},
|
|
2633
|
+
publishChanges: {
|
|
2634
|
+
method: "POST",
|
|
2635
|
+
path: "/sequences/:sequenceId/publish-changes",
|
|
2636
|
+
body: publishSequenceChangesBodySchema,
|
|
2637
|
+
responses: {
|
|
2638
|
+
200: sequenceSchema,
|
|
2639
|
+
400: errorSchema,
|
|
2640
|
+
404: errorSchema,
|
|
2641
|
+
409: errorSchema
|
|
2642
|
+
},
|
|
2643
|
+
summary: "Publish the unpublished changes of a broadcast or sequence",
|
|
2644
|
+
description: "Makes the drafts of the given emails (or all of them) the version that sends use. Emails without unpublished changes are left alone, so publishing twice changes nothing. For a sequence, `scope` says whether contacts already in it get the new version at their next step (`in_flight`, the default) or keep the version they entered with (`new_entrants`). Each published version is kept in the email's history (GET /sequences/{sequenceId}/emails/{emailId}/versions), including the one it replaces. On SendLit Cloud the content is checked first, as when a sequence starts. 404 `email_not_found` for an email the sequence doesn't have; 409 `mail_already_sent` for a broadcast that has started sending (its unpublished changes are dropped then); 409 `draft_changed` when the draft was edited during the publish (publish again)."
|
|
2645
|
+
},
|
|
2646
|
+
discardChanges: {
|
|
2647
|
+
method: "POST",
|
|
2648
|
+
path: "/sequences/:sequenceId/discard-changes",
|
|
2649
|
+
body: discardSequenceChangesBodySchema,
|
|
2650
|
+
responses: { 200: sequenceSchema, 404: errorSchema },
|
|
2651
|
+
summary: "Discard the unpublished changes of a broadcast or sequence",
|
|
2652
|
+
description: "Deletes the drafts of the given emails (or all of them), so they show the published version again. A broadcast's title goes back to its published subject. Sends are not affected."
|
|
2653
|
+
},
|
|
2654
|
+
emailVersions: {
|
|
2655
|
+
method: "GET",
|
|
2656
|
+
path: "/sequences/:sequenceId/emails/:emailId/versions",
|
|
2657
|
+
responses: {
|
|
2658
|
+
200: itemsList(sequenceEmailVersionSchema),
|
|
2659
|
+
404: errorSchema
|
|
2660
|
+
},
|
|
2661
|
+
summary: "List the published versions of a broadcast or sequence email",
|
|
2662
|
+
description: "The live version first, then the versions the email was published with before, newest first (at most 20). Restore one with POST /sequences/{sequenceId}/emails/{emailId}/versions/{versionId}/restore."
|
|
2663
|
+
},
|
|
2664
|
+
restoreEmailVersion: {
|
|
2665
|
+
method: "POST",
|
|
2666
|
+
path: "/sequences/:sequenceId/emails/:emailId/versions/:versionId/restore",
|
|
2667
|
+
body: c.noBody(),
|
|
2668
|
+
responses: {
|
|
2669
|
+
200: sequenceSchema,
|
|
2670
|
+
404: errorSchema,
|
|
2671
|
+
409: errorSchema
|
|
2672
|
+
},
|
|
2673
|
+
summary: "Restore an earlier version of a broadcast or sequence email",
|
|
2674
|
+
description: "Loads a published version's subject and content into the email's draft; publish it to roll back. Unless the broadcast or sequence is active, it's restored directly. Restoring the live version discards the draft. A broadcast's title follows the restored subject once it's published. 404 `version_not_found` for a version that isn't one of this email's published versions; 409 `mail_already_sent` for a broadcast that has started sending."
|
|
2065
2675
|
},
|
|
2066
2676
|
sendEmailTest: {
|
|
2067
2677
|
method: "POST",
|
|
@@ -2074,7 +2684,7 @@ var sequencesContract = c.router(
|
|
|
2074
2684
|
429: errorSchema
|
|
2075
2685
|
},
|
|
2076
2686
|
summary: "Send a test of a broadcast or sequence email",
|
|
2077
|
-
description: "Renders the email exactly like a real send (merge tags, footer, tracking) and sends it with a `[Test]` subject prefix through the delivery source the real send would use. Its \"view in browser\" link shows the email as it was when tested, not later edits. Merge tags use the recipient's contact data when they are a contact. Opens, clicks and the unsubscribe link in a test change nothing. Suppressed addresses are skipped. Every recipient counts as one test: by default a team can send 100 test emails in any 24 hours (50 in any 3 hours) and 20 per email per 24 hours, after which this returns 429 `test_send_limit_reached` or `test_send_email_limit_reached`. Tests through an organization's shared mailbox also count against the team's shared-delivery quota (429 `organization_team_quota_exhausted` or `organization_quota_exhausted`)."
|
|
2687
|
+
description: "Renders the email exactly like a real send (merge tags, footer, tracking) and sends it with a `[Test]` subject prefix through the delivery source the real send would use. When the email has unpublished changes, the test sends the draft, so they can be checked before they're published. Its \"view in browser\" link shows the email as it was when tested, not later edits. Merge tags use the recipient's contact data when they are a contact. Opens, clicks and the unsubscribe link in a test change nothing. Suppressed addresses are skipped. Every recipient counts as one test: by default a team can send 100 test emails in any 24 hours (50 in any 3 hours) and 20 per email per 24 hours, after which this returns 429 `test_send_limit_reached` or `test_send_email_limit_reached`. Tests through an organization's shared mailbox also count against the team's shared-delivery quota (429 `organization_team_quota_exhausted` or `organization_quota_exhausted`)."
|
|
2078
2688
|
},
|
|
2079
2689
|
removeEmail: {
|
|
2080
2690
|
method: "DELETE",
|
|
@@ -2084,7 +2694,8 @@ var sequencesContract = c.router(
|
|
|
2084
2694
|
400: errorSchema,
|
|
2085
2695
|
404: errorSchema
|
|
2086
2696
|
},
|
|
2087
|
-
summary: "Remove an email from a sequence"
|
|
2697
|
+
summary: "Remove an email from a sequence",
|
|
2698
|
+
description: "Removes the email. Images it uses that nothing else uses are deleted from the media library and storage; images used by sent mail are kept."
|
|
2088
2699
|
},
|
|
2089
2700
|
start: {
|
|
2090
2701
|
method: "POST",
|
|
@@ -2130,6 +2741,25 @@ var sequencesContract = c.router(
|
|
|
2130
2741
|
responses: { 200: sequenceStatsSchema, 404: errorSchema },
|
|
2131
2742
|
summary: "Delivery / open-rate / click-through-rate stats for a sequence"
|
|
2132
2743
|
},
|
|
2744
|
+
schedule: {
|
|
2745
|
+
method: "GET",
|
|
2746
|
+
path: "/sequences/:sequenceId/schedule",
|
|
2747
|
+
responses: { 200: sequenceScheduleSchema, 404: errorSchema },
|
|
2748
|
+
summary: "Contacts waiting for each email of a sequence",
|
|
2749
|
+
description: "For each email, in send order: how many contacts in the sequence will get it next and the earliest of their due times. A contact counts once, against the email they're waiting for, so emails they've had or will get later don't count them. Each contact's delay counts from their own entry, so their due times differ; list them with `GET /sequences/{sequenceId}/emails/{emailId}/waiting`. Due times are the earliest a contact can get the email; pauses and sending limits can make it later."
|
|
2750
|
+
},
|
|
2751
|
+
waitingContacts: {
|
|
2752
|
+
method: "GET",
|
|
2753
|
+
path: "/sequences/:sequenceId/emails/:emailId/waiting",
|
|
2754
|
+
query: listWaitingContactsQuerySchema,
|
|
2755
|
+
responses: {
|
|
2756
|
+
200: waitingContactsPageSchema,
|
|
2757
|
+
400: errorSchema,
|
|
2758
|
+
404: errorSchema
|
|
2759
|
+
},
|
|
2760
|
+
summary: "Contacts waiting for a sequence email",
|
|
2761
|
+
description: "The contacts whose next email in the sequence is this one, soonest due first, each with their own due time. `q` matches email or name. Pages hold `limit` contacts (default 10, at most 100); pass `nextCursor` as `after` for the next page. `total` counts every match. A cursor that can't be read returns 400 `invalid_cursor`."
|
|
2762
|
+
},
|
|
2133
2763
|
subscribers: {
|
|
2134
2764
|
method: "GET",
|
|
2135
2765
|
path: "/sequences/:sequenceId/subscribers",
|
|
@@ -2180,6 +2810,70 @@ var transactionalContract = c.router(
|
|
|
2180
2810
|
},
|
|
2181
2811
|
{ metadata: { tag: "Transactional Emails" } }
|
|
2182
2812
|
);
|
|
2813
|
+
var eventsContract = c.router(
|
|
2814
|
+
{
|
|
2815
|
+
track: {
|
|
2816
|
+
method: "POST",
|
|
2817
|
+
path: "/events",
|
|
2818
|
+
body: trackEventBodySchema,
|
|
2819
|
+
responses: {
|
|
2820
|
+
202: trackEventResponseSchema,
|
|
2821
|
+
400: errorSchema,
|
|
2822
|
+
402: errorSchema,
|
|
2823
|
+
404: errorSchema,
|
|
2824
|
+
409: errorSchema,
|
|
2825
|
+
422: errorSchema,
|
|
2826
|
+
429: errorSchema
|
|
2827
|
+
},
|
|
2828
|
+
summary: "Track a custom event",
|
|
2829
|
+
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."
|
|
2830
|
+
},
|
|
2831
|
+
definitions: {
|
|
2832
|
+
method: "GET",
|
|
2833
|
+
path: "/events/definitions",
|
|
2834
|
+
responses: { 200: itemsList(eventDefinitionSchema) },
|
|
2835
|
+
summary: "List the team's events"
|
|
2836
|
+
},
|
|
2837
|
+
definition: {
|
|
2838
|
+
method: "GET",
|
|
2839
|
+
path: "/events/definitions/:name",
|
|
2840
|
+
responses: { 200: eventDefinitionDetailSchema, 404: errorSchema },
|
|
2841
|
+
summary: "Get an event, with its last payload"
|
|
2842
|
+
},
|
|
2843
|
+
createDefinition: {
|
|
2844
|
+
method: "POST",
|
|
2845
|
+
path: "/events/definitions",
|
|
2846
|
+
body: createEventDefinitionBodySchema,
|
|
2847
|
+
responses: {
|
|
2848
|
+
201: eventDefinitionDetailSchema,
|
|
2849
|
+
400: errorSchema,
|
|
2850
|
+
409: errorSchema,
|
|
2851
|
+
422: errorSchema
|
|
2852
|
+
},
|
|
2853
|
+
summary: "Register an event before it is sent"
|
|
2854
|
+
},
|
|
2855
|
+
updateDefinition: {
|
|
2856
|
+
method: "PATCH",
|
|
2857
|
+
path: "/events/definitions/:name",
|
|
2858
|
+
body: updateEventDefinitionBodySchema,
|
|
2859
|
+
responses: {
|
|
2860
|
+
200: eventDefinitionDetailSchema,
|
|
2861
|
+
400: errorSchema,
|
|
2862
|
+
404: errorSchema
|
|
2863
|
+
},
|
|
2864
|
+
summary: "Update an event's description or declared properties"
|
|
2865
|
+
},
|
|
2866
|
+
deleteDefinition: {
|
|
2867
|
+
method: "DELETE",
|
|
2868
|
+
path: "/events/definitions/:name",
|
|
2869
|
+
body: c.noBody(),
|
|
2870
|
+
responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
|
|
2871
|
+
summary: "Remove an event from the list",
|
|
2872
|
+
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."
|
|
2873
|
+
}
|
|
2874
|
+
},
|
|
2875
|
+
{ metadata: { tag: "Events" } }
|
|
2876
|
+
);
|
|
2183
2877
|
var espCollectionContract = c.router(
|
|
2184
2878
|
{
|
|
2185
2879
|
list: {
|
|
@@ -2228,7 +2922,7 @@ var espCollectionContract = c.router(
|
|
|
2228
2922
|
409: errorSchema
|
|
2229
2923
|
},
|
|
2230
2924
|
summary: "Remove a user-managed ESP configuration",
|
|
2231
|
-
description: "
|
|
2925
|
+
description: "Deletes an ESP that has never carried delivery history; delivery history is never deleted. Draft, paused, and completed sequences are detached first. 409 explains a blocked delete: `esp_is_default` (the team's live default; pick another default or retire it first), `delivery_source_in_use` (a sending sequence or broadcast, or queued email, needs it), or `esp_has_delivery_history` (transactional email, delivery feedback, or grants point at it; retire it instead)."
|
|
2232
2926
|
},
|
|
2233
2927
|
domainAuthentication: {
|
|
2234
2928
|
method: "GET",
|
|
@@ -2623,7 +3317,7 @@ var organizationsContract = c.router(
|
|
|
2623
3317
|
path: "/organizations",
|
|
2624
3318
|
responses: {
|
|
2625
3319
|
200: zod.z.object({
|
|
2626
|
-
items: zod.z.array(
|
|
3320
|
+
items: zod.z.array(organizationListItemSchema),
|
|
2627
3321
|
ownsFreeOrganization: zod.z.boolean()
|
|
2628
3322
|
}),
|
|
2629
3323
|
403: errorSchema
|
|
@@ -2673,7 +3367,8 @@ var organizationsContract = c.router(
|
|
|
2673
3367
|
409: errorSchema,
|
|
2674
3368
|
503: errorSchema
|
|
2675
3369
|
},
|
|
2676
|
-
summary: "
|
|
3370
|
+
summary: "Delete an organization",
|
|
3371
|
+
description: "Owner only, from a dashboard session. Fails with `409 active_subscription_exists` while a subscription is active or paid through a future date (cancel it in billing first), and with `409 billing_checkout_pending` while a checkout is open. Deleting closes the organization, archives its teams, revokes organization and team API keys and sending domains, retires every ESP config with its credentials wiped, and deletes its teams' MediaLit files. Billing history, audit events, delivery reporting and suppressions are kept."
|
|
2677
3372
|
},
|
|
2678
3373
|
abandon: {
|
|
2679
3374
|
method: "POST",
|
|
@@ -2921,7 +3616,8 @@ var organizationsContract = c.router(
|
|
|
2921
3616
|
404: errorSchema,
|
|
2922
3617
|
409: errorSchema
|
|
2923
3618
|
},
|
|
2924
|
-
summary: "Delete an eligible never-activated organization ESP"
|
|
3619
|
+
summary: "Delete an eligible never-activated organization ESP",
|
|
3620
|
+
description: "Only a never-activated draft with no history is deleted. 409 explains a blocked delete: `esp_retire_instead` (it has been activated; retire it instead), `esp_has_delivery_history`, or `delivery_source_in_use`."
|
|
2925
3621
|
},
|
|
2926
3622
|
getEspFeedback: {
|
|
2927
3623
|
method: "GET",
|
|
@@ -3171,6 +3867,13 @@ var overviewContract = c.router(
|
|
|
3171
3867
|
);
|
|
3172
3868
|
var feedbackContract = c.router(
|
|
3173
3869
|
{
|
|
3870
|
+
requirement: {
|
|
3871
|
+
method: "GET",
|
|
3872
|
+
path: "/settings/feedback-requirement",
|
|
3873
|
+
responses: { 200: feedbackRequirementSchema },
|
|
3874
|
+
summary: "Get when ESPs need a delivery-feedback connection",
|
|
3875
|
+
description: "On SendLit Cloud, once the organization has sent `requiredAfterSends` emails, SendLit only sends through ESPs with a healthy bounce/complaint feedback connection. `required` is false on self-hosted SendLit."
|
|
3876
|
+
},
|
|
3174
3877
|
get: {
|
|
3175
3878
|
method: "GET",
|
|
3176
3879
|
path: "/settings/esps/:espId/feedback",
|
|
@@ -3475,13 +4178,56 @@ var billingContract = c.router(
|
|
|
3475
4178
|
},
|
|
3476
4179
|
{ metadata: { tag: "Billing" } }
|
|
3477
4180
|
);
|
|
4181
|
+
var accountContract = c.router({
|
|
4182
|
+
getDeletion: {
|
|
4183
|
+
method: "GET",
|
|
4184
|
+
path: "/account/deletion",
|
|
4185
|
+
responses: {
|
|
4186
|
+
200: accountDeletionPreviewSchema,
|
|
4187
|
+
401: errorSchema,
|
|
4188
|
+
403: errorSchema
|
|
4189
|
+
},
|
|
4190
|
+
summary: "Preview deleting your account",
|
|
4191
|
+
description: "Dashboard session only. Lists every organization you belong to and what deleting your account does to it: `delete` when you are its last owner (it is deleted and its contacts' personal data erased), `leave` otherwise. `blocker` says what has to happen first: `active_subscription_exists` or `billing_checkout_pending` (cancel billing), `last_organization_owner` (other people are members: make one of them an owner or remove them), `billing_manager_required` (you pay for a running subscription of an organization you would leave)."
|
|
4192
|
+
},
|
|
4193
|
+
sendDeletionCode: {
|
|
4194
|
+
method: "POST",
|
|
4195
|
+
path: "/account/deletion/code",
|
|
4196
|
+
body: c.noBody(),
|
|
4197
|
+
responses: {
|
|
4198
|
+
204: c.noBody(),
|
|
4199
|
+
401: errorSchema,
|
|
4200
|
+
403: errorSchema,
|
|
4201
|
+
429: errorSchema
|
|
4202
|
+
},
|
|
4203
|
+
summary: "Email a code to confirm deleting your account",
|
|
4204
|
+
description: "Dashboard session only. Sends a one-time code, valid for 5 minutes, to the account's email. `POST /account/deletion` needs it."
|
|
4205
|
+
},
|
|
4206
|
+
delete: {
|
|
4207
|
+
method: "POST",
|
|
4208
|
+
path: "/account/deletion",
|
|
4209
|
+
body: deleteAccountBodySchema,
|
|
4210
|
+
responses: {
|
|
4211
|
+
204: c.noBody(),
|
|
4212
|
+
400: errorSchema,
|
|
4213
|
+
401: errorSchema,
|
|
4214
|
+
403: errorSchema,
|
|
4215
|
+
409: accountDeletionBlockedSchema
|
|
4216
|
+
},
|
|
4217
|
+
summary: "Delete your account",
|
|
4218
|
+
description: "Dashboard session only, with the account's email typed to confirm and the code from `POST /account/deletion/code` (`400 email_mismatch`, `400 invalid_code`). Fails with `409 account_deletion_blocked`, listing the blocking organizations, while any blocker from `GET /account/deletion` remains; nothing changes then. Otherwise every organization you are the last owner of is deleted like `DELETE /organizations/:organizationId` and its contacts, signup confirmations, recipient addresses and raw webhook payloads are erased (suppression hashes stay); you leave every other organization and team; your sessions, sign-in methods, OAuth tokens and consents end; and your name and email are erased. Billing records and audit events keep an anonymous id. Signing in again with the same email creates a new, empty account."
|
|
4219
|
+
}
|
|
4220
|
+
});
|
|
3478
4221
|
var contract = c.router({
|
|
4222
|
+
account: accountContract,
|
|
3479
4223
|
contacts: contactsContract,
|
|
3480
4224
|
segments: segmentsContract,
|
|
4225
|
+
tags: tagsContract,
|
|
3481
4226
|
media: mediaContract,
|
|
3482
4227
|
templates: templatesContract,
|
|
3483
4228
|
sequences: sequencesContract,
|
|
3484
4229
|
transactional: transactionalContract,
|
|
4230
|
+
events: eventsContract,
|
|
3485
4231
|
settings: settingsContract,
|
|
3486
4232
|
teams: teamsContract,
|
|
3487
4233
|
organizations: organizationsContract,
|
|
@@ -3580,6 +4326,14 @@ var Contacts = class {
|
|
|
3580
4326
|
params: { contactId: assertId(contactId, "contactId") }
|
|
3581
4327
|
});
|
|
3582
4328
|
}
|
|
4329
|
+
/** Custom events received for this contact, newest first, with the
|
|
4330
|
+
* sequences each one started. */
|
|
4331
|
+
async events(contactId, query = {}) {
|
|
4332
|
+
return this.http.request(routes.events, {
|
|
4333
|
+
params: { contactId: assertId(contactId, "contactId") },
|
|
4334
|
+
query
|
|
4335
|
+
});
|
|
4336
|
+
}
|
|
3583
4337
|
};
|
|
3584
4338
|
|
|
3585
4339
|
// src/resources/delivery-events.ts
|
|
@@ -3631,8 +4385,67 @@ var Emails = class {
|
|
|
3631
4385
|
}
|
|
3632
4386
|
};
|
|
3633
4387
|
|
|
4388
|
+
// src/resources/events.ts
|
|
4389
|
+
var routes4 = contract.events;
|
|
4390
|
+
var EventDefinitions = class {
|
|
4391
|
+
constructor(http) {
|
|
4392
|
+
this.http = http;
|
|
4393
|
+
}
|
|
4394
|
+
async list() {
|
|
4395
|
+
return this.http.request(routes4.definitions);
|
|
4396
|
+
}
|
|
4397
|
+
/** One event with its last received payload. Names are case-sensitive. */
|
|
4398
|
+
async get(name) {
|
|
4399
|
+
return this.http.request(routes4.definition, {
|
|
4400
|
+
params: { name: encodeSegment(name, "name") }
|
|
4401
|
+
});
|
|
4402
|
+
}
|
|
4403
|
+
async create(input) {
|
|
4404
|
+
return this.http.request(routes4.createDefinition, { body: input });
|
|
4405
|
+
}
|
|
4406
|
+
/** `properties` replaces the declared set; observed keys stay. */
|
|
4407
|
+
async update(name, input) {
|
|
4408
|
+
return this.http.request(routes4.updateDefinition, {
|
|
4409
|
+
params: { name: encodeSegment(name, "name") },
|
|
4410
|
+
body: input
|
|
4411
|
+
});
|
|
4412
|
+
}
|
|
4413
|
+
/** Removes the event from the list. Stored events are kept, and the API
|
|
4414
|
+
* refuses (409 `event_definition_in_use`) while a sequence uses it. */
|
|
4415
|
+
async delete(name) {
|
|
4416
|
+
await this.http.request(routes4.deleteDefinition, {
|
|
4417
|
+
params: { name: encodeSegment(name, "name") }
|
|
4418
|
+
});
|
|
4419
|
+
}
|
|
4420
|
+
};
|
|
4421
|
+
var Events = class {
|
|
4422
|
+
constructor(http) {
|
|
4423
|
+
this.http = http;
|
|
4424
|
+
this.definitions = new EventDefinitions(http);
|
|
4425
|
+
}
|
|
4426
|
+
/**
|
|
4427
|
+
* Records an event for one contact (by `email` or `contactId`) and starts
|
|
4428
|
+
* every active sequence listening for `eventName`.
|
|
4429
|
+
*
|
|
4430
|
+
* - An unknown `email` creates the contact, since `createContact`
|
|
4431
|
+
* defaults to `true`. Pass `false` to get a 404 instead. An unknown
|
|
4432
|
+
* `contactId` is always a 404.
|
|
4433
|
+
* - The same `idempotencyKey` within 30 days stores one event and
|
|
4434
|
+
* returns the original with `duplicate: true`. With a key, the SDK
|
|
4435
|
+
* also retries the call on 5xx and network errors.
|
|
4436
|
+
* - `backfill: true` stores history without starting sequences. Events
|
|
4437
|
+
* whose `occurredAt` is more than 72 hours old never start one either.
|
|
4438
|
+
*/
|
|
4439
|
+
async track(input) {
|
|
4440
|
+
return this.http.request(routes4.track, {
|
|
4441
|
+
body: input,
|
|
4442
|
+
retrySafe: !!input.idempotencyKey
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
|
+
};
|
|
4446
|
+
|
|
3634
4447
|
// src/resources/provisioning.ts
|
|
3635
|
-
var
|
|
4448
|
+
var routes5 = contract.provisioning;
|
|
3636
4449
|
var Provisioning = class {
|
|
3637
4450
|
constructor(http) {
|
|
3638
4451
|
this.http = http;
|
|
@@ -3643,20 +4456,20 @@ var Provisioning = class {
|
|
|
3643
4456
|
* `created: false, apiKey: null`, so it's safe to retry.
|
|
3644
4457
|
*/
|
|
3645
4458
|
async provisionTeam(input) {
|
|
3646
|
-
return this.http.request(
|
|
4459
|
+
return this.http.request(routes5.provisionTeam, {
|
|
3647
4460
|
body: input,
|
|
3648
4461
|
retrySafe: true
|
|
3649
4462
|
});
|
|
3650
4463
|
}
|
|
3651
4464
|
/** `teams:read` */
|
|
3652
4465
|
async getTeam(teamId) {
|
|
3653
|
-
return this.http.request(
|
|
4466
|
+
return this.http.request(routes5.getTeam, {
|
|
3654
4467
|
params: { teamId: assertId(teamId, "teamId") }
|
|
3655
4468
|
});
|
|
3656
4469
|
}
|
|
3657
4470
|
/** `teams:manage` */
|
|
3658
4471
|
async updateTeam(teamId, input) {
|
|
3659
|
-
return this.http.request(
|
|
4472
|
+
return this.http.request(routes5.updateTeam, {
|
|
3660
4473
|
params: { teamId: assertId(teamId, "teamId") },
|
|
3661
4474
|
body: input
|
|
3662
4475
|
});
|
|
@@ -3664,106 +4477,106 @@ var Provisioning = class {
|
|
|
3664
4477
|
/** Replaces the team's integration key (`teams:keys`); keys previously
|
|
3665
4478
|
* issued through provisioning are revoked. */
|
|
3666
4479
|
async createTeamKey(teamId, input) {
|
|
3667
|
-
return this.http.request(
|
|
4480
|
+
return this.http.request(routes5.createTeamKey, {
|
|
3668
4481
|
params: { teamId: assertId(teamId, "teamId") },
|
|
3669
4482
|
body: input
|
|
3670
4483
|
});
|
|
3671
4484
|
}
|
|
3672
4485
|
/** `teams:manage` */
|
|
3673
4486
|
async suspendTeam(teamId) {
|
|
3674
|
-
return this.http.request(
|
|
4487
|
+
return this.http.request(routes5.suspendTeam, {
|
|
3675
4488
|
params: { teamId: assertId(teamId, "teamId") }
|
|
3676
4489
|
});
|
|
3677
4490
|
}
|
|
3678
4491
|
/** `teams:manage` */
|
|
3679
4492
|
async resumeTeam(teamId) {
|
|
3680
|
-
return this.http.request(
|
|
4493
|
+
return this.http.request(routes5.resumeTeam, {
|
|
3681
4494
|
params: { teamId: assertId(teamId, "teamId") }
|
|
3682
4495
|
});
|
|
3683
4496
|
}
|
|
3684
4497
|
/** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
|
|
3685
4498
|
async archiveTeam(teamId) {
|
|
3686
|
-
await this.http.request(
|
|
4499
|
+
await this.http.request(routes5.archiveTeam, {
|
|
3687
4500
|
params: { teamId: assertId(teamId, "teamId") }
|
|
3688
4501
|
});
|
|
3689
4502
|
}
|
|
3690
4503
|
/** `usage:read` */
|
|
3691
4504
|
async getTeamUsage(teamId) {
|
|
3692
|
-
return this.http.request(
|
|
4505
|
+
return this.http.request(routes5.getTeamUsage, {
|
|
3693
4506
|
params: { teamId: assertId(teamId, "teamId") }
|
|
3694
4507
|
});
|
|
3695
4508
|
}
|
|
3696
4509
|
};
|
|
3697
4510
|
|
|
3698
4511
|
// src/resources/segments.ts
|
|
3699
|
-
var
|
|
4512
|
+
var routes6 = contract.segments;
|
|
3700
4513
|
var Segments = class {
|
|
3701
4514
|
constructor(http) {
|
|
3702
4515
|
this.http = http;
|
|
3703
4516
|
}
|
|
3704
4517
|
async create(input) {
|
|
3705
|
-
return this.http.request(
|
|
4518
|
+
return this.http.request(routes6.create, { body: input });
|
|
3706
4519
|
}
|
|
3707
4520
|
async list() {
|
|
3708
|
-
return this.http.request(
|
|
4521
|
+
return this.http.request(routes6.list);
|
|
3709
4522
|
}
|
|
3710
4523
|
async get(segmentId) {
|
|
3711
|
-
return this.http.request(
|
|
4524
|
+
return this.http.request(routes6.get, {
|
|
3712
4525
|
params: { segmentId: assertId(segmentId, "segmentId") }
|
|
3713
4526
|
});
|
|
3714
4527
|
}
|
|
3715
4528
|
async update(segmentId, input) {
|
|
3716
|
-
return this.http.request(
|
|
4529
|
+
return this.http.request(routes6.update, {
|
|
3717
4530
|
params: { segmentId: assertId(segmentId, "segmentId") },
|
|
3718
4531
|
body: input
|
|
3719
4532
|
});
|
|
3720
4533
|
}
|
|
3721
4534
|
async remove(segmentId) {
|
|
3722
|
-
await this.http.request(
|
|
4535
|
+
await this.http.request(routes6.remove, {
|
|
3723
4536
|
params: { segmentId: assertId(segmentId, "segmentId") }
|
|
3724
4537
|
});
|
|
3725
4538
|
}
|
|
3726
4539
|
};
|
|
3727
4540
|
|
|
3728
4541
|
// src/resources/sequences.ts
|
|
3729
|
-
var
|
|
4542
|
+
var routes7 = contract.sequences;
|
|
3730
4543
|
var Sequences = class {
|
|
3731
4544
|
constructor(http) {
|
|
3732
4545
|
this.http = http;
|
|
3733
4546
|
}
|
|
3734
4547
|
async create(input) {
|
|
3735
|
-
return this.http.request(
|
|
4548
|
+
return this.http.request(routes7.create, { body: input });
|
|
3736
4549
|
}
|
|
3737
4550
|
async list(query) {
|
|
3738
|
-
return this.http.request(
|
|
4551
|
+
return this.http.request(routes7.list, { query });
|
|
3739
4552
|
}
|
|
3740
4553
|
listAll(query) {
|
|
3741
4554
|
return paginate((offset) => this.list({ ...query, offset }));
|
|
3742
4555
|
}
|
|
3743
4556
|
async get(sequenceId) {
|
|
3744
|
-
return this.http.request(
|
|
4557
|
+
return this.http.request(routes7.get, {
|
|
3745
4558
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
3746
4559
|
});
|
|
3747
4560
|
}
|
|
3748
4561
|
async update(sequenceId, input) {
|
|
3749
|
-
return this.http.request(
|
|
4562
|
+
return this.http.request(routes7.update, {
|
|
3750
4563
|
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
3751
4564
|
body: input
|
|
3752
4565
|
});
|
|
3753
4566
|
}
|
|
3754
4567
|
async remove(sequenceId) {
|
|
3755
|
-
await this.http.request(
|
|
4568
|
+
await this.http.request(routes7.remove, {
|
|
3756
4569
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
3757
4570
|
});
|
|
3758
4571
|
}
|
|
3759
4572
|
async addEmail(sequenceId, input) {
|
|
3760
|
-
return this.http.request(
|
|
4573
|
+
return this.http.request(routes7.addEmail, {
|
|
3761
4574
|
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
3762
4575
|
body: input
|
|
3763
4576
|
});
|
|
3764
4577
|
}
|
|
3765
4578
|
async updateEmail(sequenceId, emailId, input) {
|
|
3766
|
-
return this.http.request(
|
|
4579
|
+
return this.http.request(routes7.updateEmail, {
|
|
3767
4580
|
params: {
|
|
3768
4581
|
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
3769
4582
|
emailId: assertId(emailId, "emailId")
|
|
@@ -3771,8 +4584,45 @@ var Sequences = class {
|
|
|
3771
4584
|
body: input
|
|
3772
4585
|
});
|
|
3773
4586
|
}
|
|
4587
|
+
/** Publishes unpublished email changes (drafts) of a broadcast or
|
|
4588
|
+
* sequence, so sends use them. While it's active, `updateEmail` saves
|
|
4589
|
+
* subject and content changes as a draft. */
|
|
4590
|
+
async publishChanges(sequenceId, input = {}) {
|
|
4591
|
+
return this.http.request(routes7.publishChanges, {
|
|
4592
|
+
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
4593
|
+
body: input
|
|
4594
|
+
});
|
|
4595
|
+
}
|
|
4596
|
+
/** Throws away unpublished email changes. Sends are not affected. */
|
|
4597
|
+
async discardChanges(sequenceId, input = {}) {
|
|
4598
|
+
return this.http.request(routes7.discardChanges, {
|
|
4599
|
+
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
4600
|
+
body: input
|
|
4601
|
+
});
|
|
4602
|
+
}
|
|
4603
|
+
/** The versions an email has been published with, live one first. */
|
|
4604
|
+
async emailVersions(sequenceId, emailId) {
|
|
4605
|
+
const { items } = await this.http.request(routes7.emailVersions, {
|
|
4606
|
+
params: {
|
|
4607
|
+
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
4608
|
+
emailId: assertId(emailId, "emailId")
|
|
4609
|
+
}
|
|
4610
|
+
});
|
|
4611
|
+
return items;
|
|
4612
|
+
}
|
|
4613
|
+
/** Loads an earlier published version into the email's draft; publish
|
|
4614
|
+
* it with `publishChanges` to roll back. */
|
|
4615
|
+
async restoreEmailVersion(sequenceId, emailId, versionId) {
|
|
4616
|
+
return this.http.request(routes7.restoreEmailVersion, {
|
|
4617
|
+
params: {
|
|
4618
|
+
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
4619
|
+
emailId: assertId(emailId, "emailId"),
|
|
4620
|
+
versionId: assertId(versionId, "versionId")
|
|
4621
|
+
}
|
|
4622
|
+
});
|
|
4623
|
+
}
|
|
3774
4624
|
async removeEmail(sequenceId, emailId) {
|
|
3775
|
-
return this.http.request(
|
|
4625
|
+
return this.http.request(routes7.removeEmail, {
|
|
3776
4626
|
params: {
|
|
3777
4627
|
sequenceId: assertId(sequenceId, "sequenceId"),
|
|
3778
4628
|
emailId: assertId(emailId, "emailId")
|
|
@@ -3782,23 +4632,23 @@ var Sequences = class {
|
|
|
3782
4632
|
/** Sends a broadcast, or activates a sequence so its trigger starts
|
|
3783
4633
|
* enrolling contacts. Requires a mailing address in general settings. */
|
|
3784
4634
|
async start(sequenceId) {
|
|
3785
|
-
return this.http.request(
|
|
4635
|
+
return this.http.request(routes7.start, {
|
|
3786
4636
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
3787
4637
|
});
|
|
3788
4638
|
}
|
|
3789
4639
|
async pause(sequenceId) {
|
|
3790
|
-
return this.http.request(
|
|
4640
|
+
return this.http.request(routes7.pause, {
|
|
3791
4641
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
3792
4642
|
});
|
|
3793
4643
|
}
|
|
3794
4644
|
async stats(sequenceId) {
|
|
3795
|
-
return this.http.request(
|
|
4645
|
+
return this.http.request(routes7.stats, {
|
|
3796
4646
|
params: { sequenceId: assertId(sequenceId, "sequenceId") }
|
|
3797
4647
|
});
|
|
3798
4648
|
}
|
|
3799
4649
|
/** IDs of contacts that have received this broadcast or sequence. */
|
|
3800
4650
|
async subscribers(sequenceId, query = {}) {
|
|
3801
|
-
return this.http.request(
|
|
4651
|
+
return this.http.request(routes7.subscribers, {
|
|
3802
4652
|
params: { sequenceId: assertId(sequenceId, "sequenceId") },
|
|
3803
4653
|
query
|
|
3804
4654
|
});
|
|
@@ -3806,26 +4656,26 @@ var Sequences = class {
|
|
|
3806
4656
|
};
|
|
3807
4657
|
|
|
3808
4658
|
// src/resources/suppressions.ts
|
|
3809
|
-
var
|
|
4659
|
+
var routes8 = contract.suppressions;
|
|
3810
4660
|
var Suppressions = class {
|
|
3811
4661
|
constructor(http) {
|
|
3812
4662
|
this.http = http;
|
|
3813
4663
|
}
|
|
3814
4664
|
async list(query = {}) {
|
|
3815
|
-
return this.http.request(
|
|
4665
|
+
return this.http.request(routes8.list, { query });
|
|
3816
4666
|
}
|
|
3817
4667
|
listAll(query = {}) {
|
|
3818
4668
|
return paginate((offset) => this.list({ ...query, offset }));
|
|
3819
4669
|
}
|
|
3820
4670
|
async get(suppressionId) {
|
|
3821
|
-
return this.http.request(
|
|
4671
|
+
return this.http.request(routes8.get, {
|
|
3822
4672
|
params: { suppressionId: assertId(suppressionId, "suppressionId") }
|
|
3823
4673
|
});
|
|
3824
4674
|
}
|
|
3825
4675
|
/** Complaint suppressions can't be released (409
|
|
3826
4676
|
* `suppression_not_releasable`). */
|
|
3827
4677
|
async release(suppressionId, input = {}) {
|
|
3828
|
-
return this.http.request(
|
|
4678
|
+
return this.http.request(routes8.release, {
|
|
3829
4679
|
params: { suppressionId: assertId(suppressionId, "suppressionId") },
|
|
3830
4680
|
body: input
|
|
3831
4681
|
});
|
|
@@ -3833,41 +4683,41 @@ var Suppressions = class {
|
|
|
3833
4683
|
};
|
|
3834
4684
|
|
|
3835
4685
|
// src/resources/templates.ts
|
|
3836
|
-
var
|
|
4686
|
+
var routes9 = contract.templates;
|
|
3837
4687
|
var Templates = class {
|
|
3838
4688
|
constructor(http) {
|
|
3839
4689
|
this.http = http;
|
|
3840
4690
|
}
|
|
3841
4691
|
async list(query = {}) {
|
|
3842
|
-
return this.http.request(
|
|
4692
|
+
return this.http.request(routes9.list, { query });
|
|
3843
4693
|
}
|
|
3844
4694
|
/** Built-in starters, shared by every team. Duplicate one into the team
|
|
3845
4695
|
* before using it for transactional sends. */
|
|
3846
4696
|
async listSystem(query = {}) {
|
|
3847
|
-
return this.http.request(
|
|
4697
|
+
return this.http.request(routes9.listSystem, { query });
|
|
3848
4698
|
}
|
|
3849
4699
|
async get(templateId) {
|
|
3850
|
-
return this.http.request(
|
|
4700
|
+
return this.http.request(routes9.get, {
|
|
3851
4701
|
params: { templateId: assertId(templateId, "templateId") }
|
|
3852
4702
|
});
|
|
3853
4703
|
}
|
|
3854
4704
|
async create(input) {
|
|
3855
|
-
return this.http.request(
|
|
4705
|
+
return this.http.request(routes9.create, { body: input });
|
|
3856
4706
|
}
|
|
3857
4707
|
async update(templateId, input) {
|
|
3858
|
-
return this.http.request(
|
|
4708
|
+
return this.http.request(routes9.update, {
|
|
3859
4709
|
params: { templateId: assertId(templateId, "templateId") },
|
|
3860
4710
|
body: input
|
|
3861
4711
|
});
|
|
3862
4712
|
}
|
|
3863
4713
|
async duplicate(templateId, input = {}) {
|
|
3864
|
-
return this.http.request(
|
|
4714
|
+
return this.http.request(routes9.duplicate, {
|
|
3865
4715
|
params: { templateId: assertId(templateId, "templateId") },
|
|
3866
4716
|
body: input
|
|
3867
4717
|
});
|
|
3868
4718
|
}
|
|
3869
4719
|
async remove(templateId) {
|
|
3870
|
-
await this.http.request(
|
|
4720
|
+
await this.http.request(routes9.remove, {
|
|
3871
4721
|
params: { templateId: assertId(templateId, "templateId") }
|
|
3872
4722
|
});
|
|
3873
4723
|
}
|
|
@@ -3931,6 +4781,7 @@ var SendLit = class {
|
|
|
3931
4781
|
this.templates = new Templates(http);
|
|
3932
4782
|
this.sequences = new Sequences(http);
|
|
3933
4783
|
this.emails = new Emails(http);
|
|
4784
|
+
this.events = new Events(http);
|
|
3934
4785
|
this.provisioning = new Provisioning(http);
|
|
3935
4786
|
this.suppressions = new Suppressions(http);
|
|
3936
4787
|
this.deliveryEvents = new DeliveryEvents(http);
|
|
@@ -3941,6 +4792,8 @@ exports.Contacts = Contacts;
|
|
|
3941
4792
|
exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
|
|
3942
4793
|
exports.DeliveryEvents = DeliveryEvents;
|
|
3943
4794
|
exports.Emails = Emails;
|
|
4795
|
+
exports.EventDefinitions = EventDefinitions;
|
|
4796
|
+
exports.Events = Events;
|
|
3944
4797
|
exports.Provisioning = Provisioning;
|
|
3945
4798
|
exports.Segments = Segments;
|
|
3946
4799
|
exports.SendLit = SendLit;
|