@marlinjai/mail-contract 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +133 -17
- package/dist/index.d.ts +133 -17
- package/dist/index.js +367 -331
- package/dist/index.mjs +363 -331
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ __export(index_exports, {
|
|
|
43
43
|
AbTestState: () => AbTestState,
|
|
44
44
|
AbVariant: () => AbVariant,
|
|
45
45
|
AbWinnerRequest: () => AbWinnerRequest,
|
|
46
|
+
AcceptTerms: () => AcceptTerms,
|
|
46
47
|
ApiKey: () => ApiKey,
|
|
47
48
|
ApiKeyCreate: () => ApiKeyCreate,
|
|
48
49
|
ApiKeyCreated: () => ApiKeyCreated,
|
|
@@ -214,6 +215,7 @@ __export(index_exports, {
|
|
|
214
215
|
InviteListQuery: () => InviteListQuery,
|
|
215
216
|
InviteStatus: () => InviteStatus,
|
|
216
217
|
JsonValue: () => JsonValue,
|
|
218
|
+
LEGAL_TERMS_VERSION: () => LEGAL_TERMS_VERSION,
|
|
217
219
|
LETTER_ONLY_MERGE_FIELDS: () => LETTER_ONLY_MERGE_FIELDS,
|
|
218
220
|
LETTER_RECIPIENT_REFUSAL: () => LETTER_RECIPIENT_REFUSAL,
|
|
219
221
|
LIST_UNSUBSCRIBE_POST_VALUE: () => LIST_UNSUBSCRIBE_POST_VALUE,
|
|
@@ -460,6 +462,8 @@ __export(index_exports, {
|
|
|
460
462
|
TemplateUpdatedData: () => TemplateUpdatedData,
|
|
461
463
|
TemplateVersion: () => TemplateVersion,
|
|
462
464
|
TemplateVersionParams: () => TemplateVersionParams,
|
|
465
|
+
TermsAcceptance: () => TermsAcceptance,
|
|
466
|
+
TermsStatus: () => TermsStatus,
|
|
463
467
|
TimeOfDay: () => TimeOfDay,
|
|
464
468
|
Timestamp: () => Timestamp,
|
|
465
469
|
TimezoneName: () => TimezoneName,
|
|
@@ -805,7 +809,7 @@ var API_VERSION_PREFIX = "/v1";
|
|
|
805
809
|
var HEALTH_PATH = "/healthz";
|
|
806
810
|
|
|
807
811
|
// src/workspace.ts
|
|
808
|
-
var
|
|
812
|
+
var import_zod12 = require("zod");
|
|
809
813
|
|
|
810
814
|
// src/automations.ts
|
|
811
815
|
var import_zod10 = require("zod");
|
|
@@ -3437,16 +3441,23 @@ var EventListQuery = PageQuery.extend({
|
|
|
3437
3441
|
contact_id: Id.optional()
|
|
3438
3442
|
});
|
|
3439
3443
|
|
|
3444
|
+
// src/legal.ts
|
|
3445
|
+
var import_zod11 = require("zod");
|
|
3446
|
+
var LEGAL_TERMS_VERSION = "2026-10-23";
|
|
3447
|
+
var AcceptTerms = import_zod11.z.literal(LEGAL_TERMS_VERSION, {
|
|
3448
|
+
errorMap: () => ({ message: `must be "${LEGAL_TERMS_VERSION}": accept the current terms of service and processing agreement` })
|
|
3449
|
+
});
|
|
3450
|
+
|
|
3440
3451
|
// src/workspace.ts
|
|
3441
|
-
var CompanyId =
|
|
3452
|
+
var CompanyId = import_zod12.z.string().min(1).max(64);
|
|
3442
3453
|
var ASSET_POLICIES = ["any", "service_only"];
|
|
3443
|
-
var AssetPolicy =
|
|
3454
|
+
var AssetPolicy = import_zod12.z.enum(ASSET_POLICIES);
|
|
3444
3455
|
var MAX_ALLOWED_ASSET_HOSTS = 20;
|
|
3445
|
-
var AssetHost =
|
|
3446
|
-
var MergeDefaults =
|
|
3456
|
+
var AssetHost = import_zod12.z.string().trim().toLowerCase().min(1).max(253).regex(/^(?=.{1,253}(?::\d{1,5})?$)[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+(:\d{1,5})?$/, "a host name such as example.com");
|
|
3457
|
+
var MergeDefaults = import_zod12.z.record(MergeFieldName, MergeDefaultValue).refine((m) => Object.keys(m).length <= MAX_MERGE_DEFAULTS, `at most ${MAX_MERGE_DEFAULTS} merge defaults`).refine((m) => !Object.keys(m).some((k) => k in RESERVED_MERGE_FIELDS), {
|
|
3447
3458
|
message: `a reserved merge field (${Object.keys(RESERVED_MERGE_FIELDS).join(", ")}) cannot have a workspace default`
|
|
3448
3459
|
});
|
|
3449
|
-
var WorkspaceSettings =
|
|
3460
|
+
var WorkspaceSettings = import_zod12.z.object({
|
|
3450
3461
|
/**
|
|
3451
3462
|
* The workspace's main language (a {@link LocaleTag}, e.g. "de"): the main
|
|
3452
3463
|
* language of a new template, and of the hosted pages when nothing else
|
|
@@ -3459,9 +3470,9 @@ var WorkspaceSettings = import_zod11.z.object({
|
|
|
3459
3470
|
* each; the hosted pages are offered in those of them they support (English,
|
|
3460
3471
|
* German, French, Italian, Spanish). The service stores canonical casing.
|
|
3461
3472
|
*/
|
|
3462
|
-
locales:
|
|
3473
|
+
locales: import_zod12.z.array(LocaleTag).min(1).max(20).refine((l) => new Set(l.map((t) => t.toLowerCase())).size === l.length, "a language appears twice"),
|
|
3463
3474
|
/** Open and click tracking. Off by default, opt-in per workspace. */
|
|
3464
|
-
tracking_enabled:
|
|
3475
|
+
tracking_enabled: import_zod12.z.boolean(),
|
|
3465
3476
|
/** Where images, stylesheets and fonts in a mail may load from. `any` by default. */
|
|
3466
3477
|
asset_policy: AssetPolicy,
|
|
3467
3478
|
/**
|
|
@@ -3469,7 +3480,7 @@ var WorkspaceSettings = import_zod11.z.object({
|
|
|
3469
3480
|
* the workspace's website, typically. Empty by default. Ignored under `any`,
|
|
3470
3481
|
* which allows everything already.
|
|
3471
3482
|
*/
|
|
3472
|
-
allowed_asset_hosts:
|
|
3483
|
+
allowed_asset_hosts: import_zod12.z.array(AssetHost).max(MAX_ALLOWED_ASSET_HOSTS),
|
|
3473
3484
|
/** Merge values every mail of the workspace can use (see `MergeDefaults`). Empty by default. */
|
|
3474
3485
|
merge_defaults: MergeDefaults,
|
|
3475
3486
|
/**
|
|
@@ -3478,10 +3489,10 @@ var WorkspaceSettings = import_zod11.z.object({
|
|
|
3478
3489
|
*/
|
|
3479
3490
|
default_timezone: TimezoneName.nullable()
|
|
3480
3491
|
});
|
|
3481
|
-
var Workspace =
|
|
3492
|
+
var Workspace = import_zod12.z.object({
|
|
3482
3493
|
id: Id,
|
|
3483
3494
|
slug: Slug,
|
|
3484
|
-
name:
|
|
3495
|
+
name: import_zod12.z.string().min(1).max(120),
|
|
3485
3496
|
settings: WorkspaceSettings,
|
|
3486
3497
|
/**
|
|
3487
3498
|
* The auth-brain company (tenant) the workspace was created for, or null for
|
|
@@ -3492,13 +3503,13 @@ var Workspace = import_zod11.z.object({
|
|
|
3492
3503
|
created_at: Timestamp,
|
|
3493
3504
|
updated_at: Timestamp
|
|
3494
3505
|
});
|
|
3495
|
-
var WorkspaceCreate =
|
|
3506
|
+
var WorkspaceCreate = import_zod12.z.object({
|
|
3496
3507
|
slug: Slug,
|
|
3497
|
-
name:
|
|
3508
|
+
name: import_zod12.z.string().min(1).max(120),
|
|
3498
3509
|
settings: WorkspaceSettings.partial().optional(),
|
|
3499
|
-
owner:
|
|
3510
|
+
owner: import_zod12.z.object({
|
|
3500
3511
|
email: Email,
|
|
3501
|
-
name:
|
|
3512
|
+
name: import_zod12.z.string().max(200).nullable().optional()
|
|
3502
3513
|
}),
|
|
3503
3514
|
/**
|
|
3504
3515
|
* The auth-brain company the workspace is created in. Required since 0.14.0:
|
|
@@ -3507,27 +3518,33 @@ var WorkspaceCreate = import_zod11.z.object({
|
|
|
3507
3518
|
* invitation (`members.syncCompanyRole`). A workspace created before, without
|
|
3508
3519
|
* one, keeps working and simply has no such inheritance.
|
|
3509
3520
|
*/
|
|
3510
|
-
company_id: CompanyId
|
|
3521
|
+
company_id: CompanyId,
|
|
3522
|
+
/**
|
|
3523
|
+
* The person creating the workspace accepts the terms of service and the
|
|
3524
|
+
* processing agreement for its company, of this version (required since
|
|
3525
|
+
* 0.19.0): the workspace processes recipients' data from its first contact.
|
|
3526
|
+
*/
|
|
3527
|
+
accept_terms: AcceptTerms
|
|
3511
3528
|
});
|
|
3512
|
-
var WorkspaceUpdate =
|
|
3513
|
-
name:
|
|
3529
|
+
var WorkspaceUpdate = import_zod12.z.object({
|
|
3530
|
+
name: import_zod12.z.string().min(1).max(120),
|
|
3514
3531
|
settings: WorkspaceSettings.partial()
|
|
3515
3532
|
}).partial().refine((v) => Object.keys(v).length > 0, "at least one field");
|
|
3516
|
-
var WorkspaceMove =
|
|
3533
|
+
var WorkspaceMove = import_zod12.z.object({ company_id: CompanyId });
|
|
3517
3534
|
var MEMBER_ROLES = ["owner", "admin", "editor", "viewer"];
|
|
3518
|
-
var MemberRole =
|
|
3535
|
+
var MemberRole = import_zod12.z.enum(MEMBER_ROLES);
|
|
3519
3536
|
var WorkspaceMembership = Workspace.extend({ role: MemberRole });
|
|
3520
3537
|
var MEMBER_SOURCES = ["invited", "company"];
|
|
3521
|
-
var MemberSource =
|
|
3538
|
+
var MemberSource = import_zod12.z.enum(MEMBER_SOURCES);
|
|
3522
3539
|
var COMPANY_GRANT_ROLES = ["owner", "admin"];
|
|
3523
|
-
var CompanyGrantRole =
|
|
3540
|
+
var CompanyGrantRole = import_zod12.z.enum(COMPANY_GRANT_ROLES);
|
|
3524
3541
|
var COMPANY_ROLE_MAX_AGE_HOURS = 24;
|
|
3525
|
-
var Member =
|
|
3542
|
+
var Member = import_zod12.z.object({
|
|
3526
3543
|
id: Id,
|
|
3527
3544
|
/** The person's auth-brain subject. */
|
|
3528
|
-
subject:
|
|
3545
|
+
subject: import_zod12.z.string().min(1).max(255),
|
|
3529
3546
|
email: Email,
|
|
3530
|
-
name:
|
|
3547
|
+
name: import_zod12.z.string().max(200).nullable(),
|
|
3531
3548
|
/**
|
|
3532
3549
|
* The role in force: the higher of the person's own role in the workspace
|
|
3533
3550
|
* and the one a confirmed company role carries. For a `company` row that is
|
|
@@ -3554,48 +3571,48 @@ var Member = import_zod11.z.object({
|
|
|
3554
3571
|
* false is one whose company role has not been confirmed within
|
|
3555
3572
|
* `COMPANY_ROLE_MAX_AGE_HOURS`; it grants nothing and an admin may remove it.
|
|
3556
3573
|
*/
|
|
3557
|
-
inherited:
|
|
3574
|
+
inherited: import_zod12.z.boolean().optional()
|
|
3558
3575
|
});
|
|
3559
3576
|
var MAX_SYNC_COMPANIES = 100;
|
|
3560
|
-
var MemberCompanySync =
|
|
3577
|
+
var MemberCompanySync = import_zod12.z.object({
|
|
3561
3578
|
email: Email,
|
|
3562
|
-
name:
|
|
3563
|
-
companies:
|
|
3579
|
+
name: import_zod12.z.string().max(200).nullable().optional(),
|
|
3580
|
+
companies: import_zod12.z.array(import_zod12.z.object({ company_id: CompanyId, role: CompanyGrantRole })).max(MAX_SYNC_COMPANIES).refine((list2) => new Set(list2.map((c) => c.company_id)).size === list2.length, "each company at most once")
|
|
3564
3581
|
});
|
|
3565
|
-
var MemberCompanySyncResult =
|
|
3582
|
+
var MemberCompanySyncResult = import_zod12.z.object({
|
|
3566
3583
|
/** Workspaces in which the person now holds a company role they did not hold, or held differently, before this call. */
|
|
3567
|
-
granted:
|
|
3584
|
+
granted: import_zod12.z.array(Id),
|
|
3568
3585
|
/** Workspaces in which a company role was taken away by this call. */
|
|
3569
|
-
revoked:
|
|
3586
|
+
revoked: import_zod12.z.array(Id),
|
|
3570
3587
|
/** Workspaces in which the person's company role was already as stated. */
|
|
3571
|
-
unchanged:
|
|
3588
|
+
unchanged: import_zod12.z.array(Id)
|
|
3572
3589
|
});
|
|
3573
|
-
var MemberCreate =
|
|
3574
|
-
subject:
|
|
3590
|
+
var MemberCreate = import_zod12.z.object({
|
|
3591
|
+
subject: import_zod12.z.string().min(1).max(255),
|
|
3575
3592
|
email: Email,
|
|
3576
|
-
name:
|
|
3593
|
+
name: import_zod12.z.string().max(200).nullable().optional(),
|
|
3577
3594
|
role: MemberRole
|
|
3578
3595
|
});
|
|
3579
|
-
var MemberUpdate =
|
|
3596
|
+
var MemberUpdate = import_zod12.z.object({ role: MemberRole });
|
|
3580
3597
|
var API_KEY_SCOPES = ["full", "read", "send"];
|
|
3581
|
-
var ApiKeyScope =
|
|
3582
|
-
var ApiKey =
|
|
3598
|
+
var ApiKeyScope = import_zod12.z.enum(API_KEY_SCOPES);
|
|
3599
|
+
var ApiKey = import_zod12.z.object({
|
|
3583
3600
|
id: Id,
|
|
3584
|
-
name:
|
|
3601
|
+
name: import_zod12.z.string().min(1).max(120),
|
|
3585
3602
|
/** The first characters of the key, for recognising it in a list. */
|
|
3586
|
-
prefix:
|
|
3603
|
+
prefix: import_zod12.z.string().min(4).max(32),
|
|
3587
3604
|
scope: ApiKeyScope,
|
|
3588
3605
|
last_used_at: Timestamp.nullable(),
|
|
3589
3606
|
revoked_at: Timestamp.nullable(),
|
|
3590
3607
|
created_at: Timestamp
|
|
3591
3608
|
});
|
|
3592
|
-
var ApiKeyCreate =
|
|
3593
|
-
name:
|
|
3609
|
+
var ApiKeyCreate = import_zod12.z.object({
|
|
3610
|
+
name: import_zod12.z.string().min(1).max(120),
|
|
3594
3611
|
/** Omitted means `full`. */
|
|
3595
3612
|
scope: ApiKeyScope.optional()
|
|
3596
3613
|
});
|
|
3597
|
-
var ApiKeyCreated =
|
|
3598
|
-
key:
|
|
3614
|
+
var ApiKeyCreated = import_zod12.z.object({
|
|
3615
|
+
key: import_zod12.z.string().min(20),
|
|
3599
3616
|
api_key: ApiKey
|
|
3600
3617
|
});
|
|
3601
3618
|
var AUDIT_ACTIONS = [
|
|
@@ -3678,6 +3695,7 @@ var AUDIT_ACTIONS = [
|
|
|
3678
3695
|
"billing.subscription_changed",
|
|
3679
3696
|
"billing.exemption_changed",
|
|
3680
3697
|
"billing.extra_sending_domains_changed",
|
|
3698
|
+
"billing.terms_accepted",
|
|
3681
3699
|
// A1: automations
|
|
3682
3700
|
"automation.created",
|
|
3683
3701
|
"automation.updated",
|
|
@@ -3691,14 +3709,14 @@ var AUDIT_ACTIONS = [
|
|
|
3691
3709
|
"automation.run_ended",
|
|
3692
3710
|
"event.recorded"
|
|
3693
3711
|
];
|
|
3694
|
-
var AuditAction =
|
|
3712
|
+
var AuditAction = import_zod12.z.enum(AUDIT_ACTIONS);
|
|
3695
3713
|
var TRUSTED_APPS = ["booking"];
|
|
3696
|
-
var TrustedApp =
|
|
3697
|
-
var AuditActor =
|
|
3698
|
-
|
|
3699
|
-
type:
|
|
3714
|
+
var TrustedApp = import_zod12.z.enum(TRUSTED_APPS);
|
|
3715
|
+
var AuditActor = import_zod12.z.discriminatedUnion("type", [
|
|
3716
|
+
import_zod12.z.object({
|
|
3717
|
+
type: import_zod12.z.literal("member"),
|
|
3700
3718
|
member_id: Id,
|
|
3701
|
-
subject:
|
|
3719
|
+
subject: import_zod12.z.string().min(1),
|
|
3702
3720
|
/**
|
|
3703
3721
|
* The application the person acted through, when it was not the dashboard:
|
|
3704
3722
|
* the service set it from the service token the call carried, so it is
|
|
@@ -3706,26 +3724,26 @@ var AuditActor = import_zod11.z.discriminatedUnion("type", [
|
|
|
3706
3724
|
*/
|
|
3707
3725
|
app: TrustedApp.optional()
|
|
3708
3726
|
}),
|
|
3709
|
-
|
|
3710
|
-
type:
|
|
3727
|
+
import_zod12.z.object({
|
|
3728
|
+
type: import_zod12.z.literal("api_key"),
|
|
3711
3729
|
api_key_id: Id,
|
|
3712
3730
|
/**
|
|
3713
3731
|
* Who the client's application said it was acting for, from
|
|
3714
3732
|
* `ON_BEHALF_OF_HEADER`: reported by that application, never verified.
|
|
3715
3733
|
* Absent when the call carried no label.
|
|
3716
3734
|
*/
|
|
3717
|
-
on_behalf_of:
|
|
3735
|
+
on_behalf_of: import_zod12.z.string().min(1).max(ON_BEHALF_OF_MAX_LENGTH).optional()
|
|
3718
3736
|
}),
|
|
3719
3737
|
/** The service itself (the worker, a bounce, the hosted unsubscribe page). */
|
|
3720
|
-
|
|
3738
|
+
import_zod12.z.object({ type: import_zod12.z.literal("system"), reason: import_zod12.z.string().min(1).max(200) })
|
|
3721
3739
|
]);
|
|
3722
|
-
var AuditEntry =
|
|
3740
|
+
var AuditEntry = import_zod12.z.object({
|
|
3723
3741
|
id: Id,
|
|
3724
3742
|
action: AuditAction,
|
|
3725
3743
|
actor: AuditActor,
|
|
3726
|
-
target_type:
|
|
3744
|
+
target_type: import_zod12.z.string().min(1).max(64),
|
|
3727
3745
|
target_id: Id.nullable(),
|
|
3728
|
-
details:
|
|
3746
|
+
details: import_zod12.z.record(import_zod12.z.unknown()),
|
|
3729
3747
|
created_at: Timestamp
|
|
3730
3748
|
});
|
|
3731
3749
|
var AuditQuery = PageQuery.extend({
|
|
@@ -3734,12 +3752,12 @@ var AuditQuery = PageQuery.extend({
|
|
|
3734
3752
|
});
|
|
3735
3753
|
|
|
3736
3754
|
// src/invites.ts
|
|
3737
|
-
var
|
|
3755
|
+
var import_zod13 = require("zod");
|
|
3738
3756
|
var INVITE_STATUSES = ["pending", "accepted", "revoked", "expired"];
|
|
3739
|
-
var InviteStatus =
|
|
3757
|
+
var InviteStatus = import_zod13.z.enum(INVITE_STATUSES);
|
|
3740
3758
|
var DEFAULT_INVITE_TTL_DAYS = 7;
|
|
3741
3759
|
var MAX_INVITE_TTL_DAYS = 30;
|
|
3742
|
-
var Invite =
|
|
3760
|
+
var Invite = import_zod13.z.object({
|
|
3743
3761
|
id: Id,
|
|
3744
3762
|
/** Stored lowercased; only a person signed in with this address can accept. */
|
|
3745
3763
|
email: Email,
|
|
@@ -3747,32 +3765,32 @@ var Invite = import_zod12.z.object({
|
|
|
3747
3765
|
/** Derived from the timestamps below, never stored. */
|
|
3748
3766
|
status: InviteStatus,
|
|
3749
3767
|
/** The member who invited, while they are still one (null after they left). */
|
|
3750
|
-
invited_by:
|
|
3768
|
+
invited_by: import_zod13.z.object({ member_id: Id.nullable(), email: Email.nullable() }),
|
|
3751
3769
|
expires_at: Timestamp,
|
|
3752
3770
|
accepted_at: Timestamp.nullable(),
|
|
3753
3771
|
revoked_at: Timestamp.nullable(),
|
|
3754
3772
|
created_at: Timestamp
|
|
3755
3773
|
});
|
|
3756
|
-
var InviteCreate =
|
|
3774
|
+
var InviteCreate = import_zod13.z.object({
|
|
3757
3775
|
email: Email,
|
|
3758
3776
|
role: MemberRole,
|
|
3759
|
-
expires_in_days:
|
|
3777
|
+
expires_in_days: import_zod13.z.number().int().min(1).max(MAX_INVITE_TTL_DAYS).optional()
|
|
3760
3778
|
});
|
|
3761
|
-
var InviteCreated =
|
|
3779
|
+
var InviteCreated = import_zod13.z.object({
|
|
3762
3780
|
invite: Invite,
|
|
3763
|
-
token:
|
|
3781
|
+
token: import_zod13.z.string().min(32).max(128)
|
|
3764
3782
|
});
|
|
3765
3783
|
var InviteListQuery = PageQuery.extend({
|
|
3766
3784
|
status: InviteStatus.optional()
|
|
3767
3785
|
});
|
|
3768
|
-
var InviteAccept =
|
|
3769
|
-
token:
|
|
3786
|
+
var InviteAccept = import_zod13.z.object({
|
|
3787
|
+
token: import_zod13.z.string().min(32).max(128),
|
|
3770
3788
|
email: Email,
|
|
3771
|
-
name:
|
|
3789
|
+
name: import_zod13.z.string().max(200).nullable().optional()
|
|
3772
3790
|
});
|
|
3773
|
-
var InviteAccepted =
|
|
3791
|
+
var InviteAccepted = import_zod13.z.object({
|
|
3774
3792
|
workspace: WorkspaceMembership,
|
|
3775
|
-
already_member:
|
|
3793
|
+
already_member: import_zod13.z.boolean()
|
|
3776
3794
|
});
|
|
3777
3795
|
var INVITE_REFUSAL_REASONS = ["email_mismatch", "inviter_lacks_role", "expired", "revoked", "accepted"];
|
|
3778
3796
|
|
|
@@ -4402,13 +4420,13 @@ function renameInsertionEverywhere(drafts, from, rawTo) {
|
|
|
4402
4420
|
}
|
|
4403
4421
|
|
|
4404
4422
|
// src/providers.ts
|
|
4405
|
-
var
|
|
4423
|
+
var import_zod14 = require("zod");
|
|
4406
4424
|
var PROVIDER_KINDS = ["smtp", "resend"];
|
|
4407
|
-
var ProviderKind =
|
|
4408
|
-
var ProviderPolicy =
|
|
4409
|
-
daily_recipient_budget:
|
|
4410
|
-
min_interval_ms:
|
|
4411
|
-
max_recipients_per_message:
|
|
4425
|
+
var ProviderKind = import_zod14.z.enum(PROVIDER_KINDS);
|
|
4426
|
+
var ProviderPolicy = import_zod14.z.object({
|
|
4427
|
+
daily_recipient_budget: import_zod14.z.number().int().min(1).max(1e7),
|
|
4428
|
+
min_interval_ms: import_zod14.z.number().int().min(0).max(36e5),
|
|
4429
|
+
max_recipients_per_message: import_zod14.z.number().int().min(1).max(1e3)
|
|
4412
4430
|
});
|
|
4413
4431
|
var ICLOUD_SMTP_POLICY = {
|
|
4414
4432
|
daily_recipient_budget: 800,
|
|
@@ -4416,17 +4434,17 @@ var ICLOUD_SMTP_POLICY = {
|
|
|
4416
4434
|
max_recipients_per_message: 1
|
|
4417
4435
|
};
|
|
4418
4436
|
var SMTP_SECURITY = ["tls", "starttls"];
|
|
4419
|
-
var SmtpConfigBase =
|
|
4420
|
-
host:
|
|
4421
|
-
port:
|
|
4437
|
+
var SmtpConfigBase = import_zod14.z.object({
|
|
4438
|
+
host: import_zod14.z.string().min(1).max(255),
|
|
4439
|
+
port: import_zod14.z.number().int().min(1).max(65535),
|
|
4422
4440
|
/** `tls` connects encrypted (465), `starttls` upgrades (587). Never plaintext. */
|
|
4423
|
-
security:
|
|
4424
|
-
username:
|
|
4441
|
+
security: import_zod14.z.enum(SMTP_SECURITY),
|
|
4442
|
+
username: import_zod14.z.string().min(1).max(255)
|
|
4425
4443
|
});
|
|
4426
|
-
var ResendConfigBase =
|
|
4427
|
-
var ProviderRejections =
|
|
4428
|
-
count:
|
|
4429
|
-
last_error:
|
|
4444
|
+
var ResendConfigBase = import_zod14.z.object({});
|
|
4445
|
+
var ProviderRejections = import_zod14.z.object({
|
|
4446
|
+
count: import_zod14.z.number().int().min(0),
|
|
4447
|
+
last_error: import_zod14.z.string().nullable(),
|
|
4430
4448
|
last_at: Timestamp.nullable(),
|
|
4431
4449
|
/**
|
|
4432
4450
|
* The last time the bounce circuit breaker tripped on one of this provider's
|
|
@@ -4436,59 +4454,59 @@ var ProviderRejections = import_zod13.z.object({
|
|
|
4436
4454
|
* run's bounce blocks were undone and the mailing paused. `sample` is the
|
|
4437
4455
|
* reply that tripped it.
|
|
4438
4456
|
*/
|
|
4439
|
-
anomaly:
|
|
4457
|
+
anomaly: import_zod14.z.object({
|
|
4440
4458
|
at: Timestamp,
|
|
4441
4459
|
/** `mailing`: one mailing was paused. `provider`: 5 refusals in a row with the same reply across the provider's sends (test sends and one-recipient mailings included) within 24 hours. */
|
|
4442
|
-
scope:
|
|
4460
|
+
scope: import_zod14.z.enum(["mailing", "provider"]),
|
|
4443
4461
|
/**
|
|
4444
4462
|
* True while the provider-wide breaker is open: no bounce blocks through
|
|
4445
4463
|
* this provider, test sends refused and mailings not started or resumed
|
|
4446
4464
|
* (`provider_anomaly`), until an admin clears it (`providers.clearAnomaly`).
|
|
4447
4465
|
*/
|
|
4448
|
-
blocking:
|
|
4466
|
+
blocking: import_zod14.z.boolean(),
|
|
4449
4467
|
mailing_id: Id.nullable(),
|
|
4450
|
-
reason:
|
|
4451
|
-
sample:
|
|
4468
|
+
reason: import_zod14.z.string(),
|
|
4469
|
+
sample: import_zod14.z.string()
|
|
4452
4470
|
}).nullable()
|
|
4453
4471
|
});
|
|
4454
|
-
var ProviderEvents =
|
|
4455
|
-
status:
|
|
4456
|
-
source:
|
|
4457
|
-
url:
|
|
4458
|
-
error:
|
|
4472
|
+
var ProviderEvents = import_zod14.z.object({
|
|
4473
|
+
status: import_zod14.z.enum(["active", "needs_secret"]),
|
|
4474
|
+
source: import_zod14.z.enum(["automatic", "manual", "managed"]).nullable(),
|
|
4475
|
+
url: import_zod14.z.string().url(),
|
|
4476
|
+
error: import_zod14.z.string().nullable(),
|
|
4459
4477
|
/**
|
|
4460
4478
|
* Events that named an email this provider never sent through the service
|
|
4461
4479
|
* (another workspace or system sharing the Resend account): counted, never
|
|
4462
4480
|
* acted on.
|
|
4463
4481
|
*/
|
|
4464
|
-
unmatched:
|
|
4482
|
+
unmatched: import_zod14.z.number().int().min(0)
|
|
4465
4483
|
});
|
|
4466
4484
|
var RESEND_EVENT_TYPES = ["email.bounced", "email.complained", "email.delivery_delayed"];
|
|
4467
|
-
var ResendSigningSecret =
|
|
4468
|
-
var ProviderEventsSecret =
|
|
4485
|
+
var ResendSigningSecret = import_zod14.z.string().max(200).regex(/^whsec_[A-Za-z0-9+/]{16,}={0,2}$/, "must be the signing secret Resend shows, starting with whsec_");
|
|
4486
|
+
var ProviderEventsSecret = import_zod14.z.object({ signing_secret: ResendSigningSecret });
|
|
4469
4487
|
var ProviderFields = {
|
|
4470
|
-
name:
|
|
4471
|
-
from_name:
|
|
4488
|
+
name: import_zod14.z.string().min(1).max(120),
|
|
4489
|
+
from_name: import_zod14.z.string().min(1).max(120),
|
|
4472
4490
|
from_email: Email,
|
|
4473
4491
|
reply_to: Email.nullable(),
|
|
4474
4492
|
policy: ProviderPolicy
|
|
4475
4493
|
};
|
|
4476
|
-
var Provider =
|
|
4477
|
-
|
|
4494
|
+
var Provider = import_zod14.z.discriminatedUnion("kind", [
|
|
4495
|
+
import_zod14.z.object({
|
|
4478
4496
|
id: Id,
|
|
4479
|
-
kind:
|
|
4497
|
+
kind: import_zod14.z.literal("smtp"),
|
|
4480
4498
|
config: SmtpConfigBase,
|
|
4481
|
-
has_secret:
|
|
4499
|
+
has_secret: import_zod14.z.boolean(),
|
|
4482
4500
|
...ProviderFields,
|
|
4483
4501
|
rejections: ProviderRejections,
|
|
4484
4502
|
created_at: Timestamp,
|
|
4485
4503
|
updated_at: Timestamp
|
|
4486
4504
|
}),
|
|
4487
|
-
|
|
4505
|
+
import_zod14.z.object({
|
|
4488
4506
|
id: Id,
|
|
4489
|
-
kind:
|
|
4507
|
+
kind: import_zod14.z.literal("resend"),
|
|
4490
4508
|
config: ResendConfigBase,
|
|
4491
|
-
has_secret:
|
|
4509
|
+
has_secret: import_zod14.z.boolean(),
|
|
4492
4510
|
...ProviderFields,
|
|
4493
4511
|
rejections: ProviderRejections,
|
|
4494
4512
|
events: ProviderEvents,
|
|
@@ -4496,31 +4514,31 @@ var Provider = import_zod13.z.discriminatedUnion("kind", [
|
|
|
4496
4514
|
updated_at: Timestamp
|
|
4497
4515
|
})
|
|
4498
4516
|
]);
|
|
4499
|
-
var ProviderCreate =
|
|
4500
|
-
|
|
4501
|
-
kind:
|
|
4502
|
-
config: SmtpConfigBase.extend({ password:
|
|
4517
|
+
var ProviderCreate = import_zod14.z.discriminatedUnion("kind", [
|
|
4518
|
+
import_zod14.z.object({
|
|
4519
|
+
kind: import_zod14.z.literal("smtp"),
|
|
4520
|
+
config: SmtpConfigBase.extend({ password: import_zod14.z.string().min(1).max(1024) }),
|
|
4503
4521
|
...ProviderFields
|
|
4504
4522
|
}),
|
|
4505
|
-
|
|
4506
|
-
kind:
|
|
4507
|
-
config: ResendConfigBase.extend({ api_key:
|
|
4523
|
+
import_zod14.z.object({
|
|
4524
|
+
kind: import_zod14.z.literal("resend"),
|
|
4525
|
+
config: ResendConfigBase.extend({ api_key: import_zod14.z.string().min(1).max(1024) }),
|
|
4508
4526
|
...ProviderFields
|
|
4509
4527
|
})
|
|
4510
4528
|
]);
|
|
4511
|
-
var ProviderUpdate =
|
|
4512
|
-
|
|
4513
|
-
kind:
|
|
4514
|
-
config: SmtpConfigBase.extend({ password:
|
|
4529
|
+
var ProviderUpdate = import_zod14.z.discriminatedUnion("kind", [
|
|
4530
|
+
import_zod14.z.object({
|
|
4531
|
+
kind: import_zod14.z.literal("smtp"),
|
|
4532
|
+
config: SmtpConfigBase.extend({ password: import_zod14.z.string().min(1).max(1024).optional() }).partial().optional(),
|
|
4515
4533
|
name: ProviderFields.name.optional(),
|
|
4516
4534
|
from_name: ProviderFields.from_name.optional(),
|
|
4517
4535
|
from_email: ProviderFields.from_email.optional(),
|
|
4518
4536
|
reply_to: ProviderFields.reply_to.optional(),
|
|
4519
4537
|
policy: ProviderPolicy.partial().optional()
|
|
4520
4538
|
}),
|
|
4521
|
-
|
|
4522
|
-
kind:
|
|
4523
|
-
config: ResendConfigBase.extend({ api_key:
|
|
4539
|
+
import_zod14.z.object({
|
|
4540
|
+
kind: import_zod14.z.literal("resend"),
|
|
4541
|
+
config: ResendConfigBase.extend({ api_key: import_zod14.z.string().min(1).max(1024).optional() }).optional(),
|
|
4524
4542
|
name: ProviderFields.name.optional(),
|
|
4525
4543
|
from_name: ProviderFields.from_name.optional(),
|
|
4526
4544
|
from_email: ProviderFields.from_email.optional(),
|
|
@@ -4528,37 +4546,37 @@ var ProviderUpdate = import_zod13.z.discriminatedUnion("kind", [
|
|
|
4528
4546
|
policy: ProviderPolicy.partial().optional()
|
|
4529
4547
|
})
|
|
4530
4548
|
]);
|
|
4531
|
-
var ProviderUsage =
|
|
4549
|
+
var ProviderUsage = import_zod14.z.object({
|
|
4532
4550
|
provider_id: Id,
|
|
4533
|
-
recipients_last_24h:
|
|
4534
|
-
remaining_budget:
|
|
4551
|
+
recipients_last_24h: import_zod14.z.number().int().min(0),
|
|
4552
|
+
remaining_budget: import_zod14.z.number().int().min(0),
|
|
4535
4553
|
/** When enough of the rolling window frees up to send again, if exhausted. */
|
|
4536
4554
|
next_capacity_at: Timestamp.nullable()
|
|
4537
4555
|
});
|
|
4538
|
-
var ProviderVerifyResult =
|
|
4539
|
-
ok:
|
|
4540
|
-
error:
|
|
4556
|
+
var ProviderVerifyResult = import_zod14.z.object({
|
|
4557
|
+
ok: import_zod14.z.boolean(),
|
|
4558
|
+
error: import_zod14.z.string().nullable()
|
|
4541
4559
|
});
|
|
4542
4560
|
|
|
4543
4561
|
// src/sending-domains.ts
|
|
4544
|
-
var
|
|
4562
|
+
var import_zod15 = require("zod");
|
|
4545
4563
|
var SENDING_DOMAIN_STATUSES = ["pending_dns", "verifying", "verified", "failed", "temporary_failure"];
|
|
4546
|
-
var SendingDomainStatus =
|
|
4564
|
+
var SendingDomainStatus = import_zod15.z.enum(SENDING_DOMAIN_STATUSES);
|
|
4547
4565
|
var SENDING_DOMAIN_DNS_MODES = ["manual", "managed"];
|
|
4548
|
-
var SendingDomainDnsMode =
|
|
4566
|
+
var SendingDomainDnsMode = import_zod15.z.enum(SENDING_DOMAIN_DNS_MODES);
|
|
4549
4567
|
var SENDING_DOMAIN_REGION = "eu-west-1";
|
|
4550
|
-
var SendingDomainName =
|
|
4568
|
+
var SendingDomainName = import_zod15.z.string().trim().toLowerCase().max(253).regex(
|
|
4551
4569
|
/^(?=.{1,253}$)(?!-)[a-z0-9-]{1,63}(?<!-)(\.(?!-)[a-z0-9-]{1,63}(?<!-))*\.[a-z]{2,63}$/,
|
|
4552
4570
|
"must be a domain such as example.com, without https:// or an @"
|
|
4553
4571
|
);
|
|
4554
|
-
var SendingDomainRecord =
|
|
4555
|
-
record:
|
|
4556
|
-
name:
|
|
4557
|
-
type:
|
|
4558
|
-
value:
|
|
4559
|
-
ttl:
|
|
4560
|
-
status:
|
|
4561
|
-
priority:
|
|
4572
|
+
var SendingDomainRecord = import_zod15.z.object({
|
|
4573
|
+
record: import_zod15.z.string().max(40),
|
|
4574
|
+
name: import_zod15.z.string().max(253),
|
|
4575
|
+
type: import_zod15.z.string().max(10),
|
|
4576
|
+
value: import_zod15.z.string().max(4096),
|
|
4577
|
+
ttl: import_zod15.z.string().max(20),
|
|
4578
|
+
status: import_zod15.z.string().max(40),
|
|
4579
|
+
priority: import_zod15.z.number().int().min(0).max(65535).optional()
|
|
4562
4580
|
});
|
|
4563
4581
|
function sendingDomainRecordFullName(domain, name) {
|
|
4564
4582
|
const d = domain.toLowerCase();
|
|
@@ -4571,66 +4589,66 @@ function sendingDomainRecordFullName(domain, name) {
|
|
|
4571
4589
|
}
|
|
4572
4590
|
return `${n}.${d}`;
|
|
4573
4591
|
}
|
|
4574
|
-
var SendingDomain =
|
|
4592
|
+
var SendingDomain = import_zod15.z.object({
|
|
4575
4593
|
id: Id,
|
|
4576
|
-
domain:
|
|
4577
|
-
from_name:
|
|
4594
|
+
domain: import_zod15.z.string(),
|
|
4595
|
+
from_name: import_zod15.z.string(),
|
|
4578
4596
|
from_email: Email,
|
|
4579
4597
|
reply_to: Email.nullable(),
|
|
4580
4598
|
status: SendingDomainStatus,
|
|
4581
4599
|
dns_mode: SendingDomainDnsMode,
|
|
4582
|
-
records:
|
|
4600
|
+
records: import_zod15.z.array(SendingDomainRecord),
|
|
4583
4601
|
provider_id: Id.nullable(),
|
|
4584
4602
|
checked_at: Timestamp.nullable(),
|
|
4585
4603
|
verified_at: Timestamp.nullable(),
|
|
4586
|
-
last_error:
|
|
4604
|
+
last_error: import_zod15.z.string().nullable(),
|
|
4587
4605
|
created_at: Timestamp,
|
|
4588
4606
|
updated_at: Timestamp
|
|
4589
4607
|
});
|
|
4590
4608
|
var SenderFields = {
|
|
4591
|
-
from_name:
|
|
4609
|
+
from_name: import_zod15.z.string().trim().min(1).max(120),
|
|
4592
4610
|
from_email: Email,
|
|
4593
4611
|
reply_to: Email.nullable().optional()
|
|
4594
4612
|
};
|
|
4595
4613
|
function senderOnDomain(input, ctx) {
|
|
4596
4614
|
const at = input.from_email.lastIndexOf("@");
|
|
4597
4615
|
if (at < 0 || input.from_email.slice(at + 1).toLowerCase() !== input.domain) {
|
|
4598
|
-
ctx.addIssue({ code:
|
|
4616
|
+
ctx.addIssue({ code: import_zod15.z.ZodIssueCode.custom, path: ["from_email"], message: `must be an address on ${input.domain}` });
|
|
4599
4617
|
}
|
|
4600
4618
|
}
|
|
4601
|
-
var SendingDomainCreate =
|
|
4602
|
-
var SendingDomainUpdate =
|
|
4619
|
+
var SendingDomainCreate = import_zod15.z.object({ domain: SendingDomainName, ...SenderFields }).superRefine(senderOnDomain);
|
|
4620
|
+
var SendingDomainUpdate = import_zod15.z.object({ from_name: SenderFields.from_name.optional(), from_email: Email.optional(), reply_to: Email.nullable().optional() }).refine((v) => Object.keys(v).length > 0, "nothing to change");
|
|
4603
4621
|
|
|
4604
4622
|
// src/contacts.ts
|
|
4605
|
-
var
|
|
4606
|
-
var Topic =
|
|
4623
|
+
var import_zod16 = require("zod");
|
|
4624
|
+
var Topic = import_zod16.z.object({
|
|
4607
4625
|
id: Id,
|
|
4608
4626
|
slug: Slug,
|
|
4609
|
-
name:
|
|
4627
|
+
name: import_zod16.z.string().min(1).max(120),
|
|
4610
4628
|
/** Shown on the hosted preference page. */
|
|
4611
|
-
description:
|
|
4629
|
+
description: import_zod16.z.string().max(1e3).nullable(),
|
|
4612
4630
|
/** Translations of `name` and `description` per locale, for the hosted page. */
|
|
4613
|
-
translations:
|
|
4614
|
-
|
|
4631
|
+
translations: import_zod16.z.record(
|
|
4632
|
+
import_zod16.z.object({ name: import_zod16.z.string().min(1).max(120), description: import_zod16.z.string().max(1e3).nullable() })
|
|
4615
4633
|
),
|
|
4616
4634
|
created_at: Timestamp,
|
|
4617
4635
|
updated_at: Timestamp
|
|
4618
4636
|
});
|
|
4619
|
-
var TopicCreate =
|
|
4637
|
+
var TopicCreate = import_zod16.z.object({
|
|
4620
4638
|
slug: Slug,
|
|
4621
|
-
name:
|
|
4622
|
-
description:
|
|
4639
|
+
name: import_zod16.z.string().min(1).max(120),
|
|
4640
|
+
description: import_zod16.z.string().max(1e3).optional(),
|
|
4623
4641
|
translations: Topic.shape.translations.optional()
|
|
4624
4642
|
});
|
|
4625
4643
|
var TopicUpdate = TopicCreate.omit({ slug: true }).partial().refine((v) => Object.keys(v).length > 0, "at least one field");
|
|
4626
|
-
var Contact =
|
|
4644
|
+
var Contact = import_zod16.z.object({
|
|
4627
4645
|
id: Id,
|
|
4628
|
-
external_id:
|
|
4646
|
+
external_id: import_zod16.z.string().min(1).max(255).nullable(),
|
|
4629
4647
|
/** Stored lowercased, unique per workspace. */
|
|
4630
4648
|
email: Email,
|
|
4631
|
-
first_name:
|
|
4632
|
-
last_name:
|
|
4633
|
-
locale:
|
|
4649
|
+
first_name: import_zod16.z.string().max(200).nullable(),
|
|
4650
|
+
last_name: import_zod16.z.string().max(200).nullable(),
|
|
4651
|
+
locale: import_zod16.z.string().min(2).max(35).nullable(),
|
|
4634
4652
|
/**
|
|
4635
4653
|
* The person's own time zone, an IANA name such as `Europe/Berlin` (A1).
|
|
4636
4654
|
* Every wall clock an automation waits for is read in it, falling back to the
|
|
@@ -4638,65 +4656,65 @@ var Contact = import_zod15.z.object({
|
|
|
4638
4656
|
*/
|
|
4639
4657
|
timezone: TimezoneName.nullable(),
|
|
4640
4658
|
properties: Properties,
|
|
4641
|
-
topics:
|
|
4659
|
+
topics: import_zod16.z.array(Slug),
|
|
4642
4660
|
/** The slugs of the contact's tags (S4). */
|
|
4643
|
-
tags:
|
|
4661
|
+
tags: import_zod16.z.array(Slug),
|
|
4644
4662
|
created_at: Timestamp,
|
|
4645
4663
|
updated_at: Timestamp
|
|
4646
4664
|
});
|
|
4647
|
-
var ContactUpsert =
|
|
4648
|
-
external_id:
|
|
4665
|
+
var ContactUpsert = import_zod16.z.object({
|
|
4666
|
+
external_id: import_zod16.z.string().min(1).max(255).optional(),
|
|
4649
4667
|
email: Email.optional(),
|
|
4650
|
-
first_name:
|
|
4651
|
-
last_name:
|
|
4652
|
-
locale:
|
|
4668
|
+
first_name: import_zod16.z.string().max(200).nullable().optional(),
|
|
4669
|
+
last_name: import_zod16.z.string().max(200).nullable().optional(),
|
|
4670
|
+
locale: import_zod16.z.string().min(2).max(35).nullable().optional(),
|
|
4653
4671
|
timezone: TimezoneName.nullable().optional(),
|
|
4654
4672
|
properties: Properties.optional(),
|
|
4655
|
-
topics:
|
|
4673
|
+
topics: import_zod16.z.array(Slug).max(100).optional()
|
|
4656
4674
|
}).refine((v) => v.external_id !== void 0 || v.email !== void 0, {
|
|
4657
4675
|
message: "external_id or email is required",
|
|
4658
4676
|
path: ["email"]
|
|
4659
4677
|
});
|
|
4660
|
-
var ContactUpsertResult =
|
|
4678
|
+
var ContactUpsertResult = import_zod16.z.object({
|
|
4661
4679
|
contact: Contact,
|
|
4662
|
-
created:
|
|
4680
|
+
created: import_zod16.z.boolean()
|
|
4663
4681
|
});
|
|
4664
4682
|
var ContactListQuery = PageQuery.extend({
|
|
4665
|
-
email:
|
|
4666
|
-
external_id:
|
|
4683
|
+
email: import_zod16.z.string().min(1).max(254).optional(),
|
|
4684
|
+
external_id: import_zod16.z.string().min(1).max(255).optional(),
|
|
4667
4685
|
topic: Slug.optional()
|
|
4668
4686
|
});
|
|
4669
|
-
var ContactErased =
|
|
4670
|
-
ok:
|
|
4671
|
-
erased_messages:
|
|
4672
|
-
erased_recipients:
|
|
4673
|
-
suppressions_kept:
|
|
4687
|
+
var ContactErased = import_zod16.z.object({
|
|
4688
|
+
ok: import_zod16.z.literal(true),
|
|
4689
|
+
erased_messages: import_zod16.z.number().int().min(0),
|
|
4690
|
+
erased_recipients: import_zod16.z.number().int().min(0),
|
|
4691
|
+
suppressions_kept: import_zod16.z.number().int().min(0)
|
|
4674
4692
|
});
|
|
4675
4693
|
var SUPPRESSION_REASONS = ["unsubscribed", "bounced", "complained", "manual"];
|
|
4676
|
-
var SuppressionReason =
|
|
4677
|
-
var Suppression =
|
|
4694
|
+
var SuppressionReason = import_zod16.z.enum(SUPPRESSION_REASONS);
|
|
4695
|
+
var Suppression = import_zod16.z.object({
|
|
4678
4696
|
id: Id,
|
|
4679
4697
|
email: Email,
|
|
4680
4698
|
reason: SuppressionReason,
|
|
4681
4699
|
topic: Slug.nullable(),
|
|
4682
4700
|
source_message_id: Id.nullable(),
|
|
4683
|
-
note:
|
|
4701
|
+
note: import_zod16.z.string().max(1e3).nullable(),
|
|
4684
4702
|
created_at: Timestamp
|
|
4685
4703
|
});
|
|
4686
|
-
var SuppressionCreate =
|
|
4704
|
+
var SuppressionCreate = import_zod16.z.object({
|
|
4687
4705
|
email: Email,
|
|
4688
|
-
reason:
|
|
4706
|
+
reason: import_zod16.z.enum(["manual", "unsubscribed"]),
|
|
4689
4707
|
topic: Slug.nullable().optional(),
|
|
4690
|
-
note:
|
|
4708
|
+
note: import_zod16.z.string().max(1e3).optional()
|
|
4691
4709
|
});
|
|
4692
4710
|
var SuppressionListQuery = PageQuery.extend({
|
|
4693
|
-
email:
|
|
4711
|
+
email: import_zod16.z.string().min(1).max(254).optional(),
|
|
4694
4712
|
reason: SuppressionReason.optional(),
|
|
4695
4713
|
topic: Slug.optional()
|
|
4696
4714
|
});
|
|
4697
4715
|
|
|
4698
4716
|
// src/webhooks.ts
|
|
4699
|
-
var
|
|
4717
|
+
var import_zod17 = require("zod");
|
|
4700
4718
|
var WEBHOOK_EVENT_TYPES = [
|
|
4701
4719
|
"message.sent",
|
|
4702
4720
|
"message.failed",
|
|
@@ -4740,23 +4758,23 @@ var WEBHOOK_EVENT_TYPES = [
|
|
|
4740
4758
|
"template.updated",
|
|
4741
4759
|
"template.deleted"
|
|
4742
4760
|
];
|
|
4743
|
-
var WebhookEventType =
|
|
4744
|
-
var MessageEventBase =
|
|
4761
|
+
var WebhookEventType = import_zod17.z.enum(WEBHOOK_EVENT_TYPES);
|
|
4762
|
+
var MessageEventBase = import_zod17.z.object({
|
|
4745
4763
|
message_id: Id,
|
|
4746
4764
|
mailing_id: Id.nullable(),
|
|
4747
4765
|
mailing_metadata: MailingMetadata.nullable(),
|
|
4748
4766
|
recipient_id: Id.nullable(),
|
|
4749
4767
|
contact_id: Id.nullable(),
|
|
4750
|
-
external_id:
|
|
4768
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4751
4769
|
email: Email,
|
|
4752
|
-
subject:
|
|
4770
|
+
subject: import_zod17.z.string(),
|
|
4753
4771
|
topic: Slug.nullable(),
|
|
4754
|
-
provider_message_id:
|
|
4755
|
-
is_test:
|
|
4772
|
+
provider_message_id: import_zod17.z.string().nullable(),
|
|
4773
|
+
is_test: import_zod17.z.boolean()
|
|
4756
4774
|
});
|
|
4757
4775
|
var MessageSentData = MessageEventBase.extend({
|
|
4758
4776
|
/** The final HTML as sent, so the client can archive it beside its own records. */
|
|
4759
|
-
html:
|
|
4777
|
+
html: import_zod17.z.string(),
|
|
4760
4778
|
sent_at: Timestamp,
|
|
4761
4779
|
/**
|
|
4762
4780
|
* The choice each insertion made (see `Message.insertions`); absent or null
|
|
@@ -4767,20 +4785,20 @@ var MessageSentData = MessageEventBase.extend({
|
|
|
4767
4785
|
insertions: InsertionChoices.nullish()
|
|
4768
4786
|
});
|
|
4769
4787
|
var MessageFailedData = MessageEventBase.extend({
|
|
4770
|
-
error:
|
|
4788
|
+
error: import_zod17.z.string(),
|
|
4771
4789
|
/** False when the provider rejected permanently; the recipient will not be retried. */
|
|
4772
|
-
retryable:
|
|
4790
|
+
retryable: import_zod17.z.boolean(),
|
|
4773
4791
|
failed_at: Timestamp
|
|
4774
4792
|
});
|
|
4775
4793
|
var UNSUBSCRIBE_SOURCES = ["hosted_page", "one_click", "api", "dashboard", "signup_form"];
|
|
4776
|
-
var ContactUnsubscribedData =
|
|
4794
|
+
var ContactUnsubscribedData = import_zod17.z.object({
|
|
4777
4795
|
contact_id: Id.nullable(),
|
|
4778
|
-
external_id:
|
|
4796
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4779
4797
|
email: Email,
|
|
4780
4798
|
/** The topic unsubscribed from; null means every topic. */
|
|
4781
4799
|
topic: Slug.nullable(),
|
|
4782
4800
|
mailing_id: Id.nullable(),
|
|
4783
|
-
source:
|
|
4801
|
+
source: import_zod17.z.enum(UNSUBSCRIBE_SOURCES),
|
|
4784
4802
|
unsubscribed_at: Timestamp
|
|
4785
4803
|
});
|
|
4786
4804
|
var ContactResubscribedData = ContactUnsubscribedData.omit({ unsubscribed_at: true }).extend({
|
|
@@ -4789,142 +4807,142 @@ var ContactResubscribedData = ContactUnsubscribedData.omit({ unsubscribed_at: tr
|
|
|
4789
4807
|
* breaker undid a `bounced` block it judged false (a `contact.bounced` for the
|
|
4790
4808
|
* same address and mailing went out before); `topic` is null.
|
|
4791
4809
|
*/
|
|
4792
|
-
source:
|
|
4810
|
+
source: import_zod17.z.enum([...UNSUBSCRIBE_SOURCES, "bounce_reverted"]),
|
|
4793
4811
|
resubscribed_at: Timestamp
|
|
4794
4812
|
});
|
|
4795
|
-
var ContactBouncedData =
|
|
4813
|
+
var ContactBouncedData = import_zod17.z.object({
|
|
4796
4814
|
contact_id: Id.nullable(),
|
|
4797
|
-
external_id:
|
|
4815
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4798
4816
|
email: Email,
|
|
4799
4817
|
/** `bounced` for a hard bounce, `complained` for a spam complaint. */
|
|
4800
|
-
reason:
|
|
4818
|
+
reason: import_zod17.z.enum(["bounced", "complained"]),
|
|
4801
4819
|
message_id: Id.nullable(),
|
|
4802
|
-
diagnostic:
|
|
4820
|
+
diagnostic: import_zod17.z.string().nullable(),
|
|
4803
4821
|
bounced_at: Timestamp
|
|
4804
4822
|
});
|
|
4805
|
-
var MailingFinishedData =
|
|
4823
|
+
var MailingFinishedData = import_zod17.z.object({
|
|
4806
4824
|
mailing_id: Id,
|
|
4807
4825
|
mailing_metadata: MailingMetadata,
|
|
4808
|
-
status:
|
|
4826
|
+
status: import_zod17.z.enum(["sent", "partially_failed", "cancelled"]),
|
|
4809
4827
|
counts: MailingCounts,
|
|
4810
4828
|
finished_at: Timestamp
|
|
4811
4829
|
});
|
|
4812
|
-
var ContactSubscribedData =
|
|
4830
|
+
var ContactSubscribedData = import_zod17.z.object({
|
|
4813
4831
|
contact_id: Id,
|
|
4814
|
-
external_id:
|
|
4832
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4815
4833
|
email: Email,
|
|
4816
|
-
topics:
|
|
4817
|
-
source:
|
|
4834
|
+
topics: import_zod17.z.array(Slug),
|
|
4835
|
+
source: import_zod17.z.enum(["signup_form", "api", "dashboard", "automation"]),
|
|
4818
4836
|
signup_form_id: Id.nullable(),
|
|
4819
|
-
signup_form_version:
|
|
4837
|
+
signup_form_version: import_zod17.z.number().int().min(1).nullable(),
|
|
4820
4838
|
subscribed_at: Timestamp
|
|
4821
4839
|
});
|
|
4822
|
-
var ImportFinishedData =
|
|
4840
|
+
var ImportFinishedData = import_zod17.z.object({
|
|
4823
4841
|
import_id: Id,
|
|
4824
|
-
status:
|
|
4842
|
+
status: import_zod17.z.enum(["completed", "cancelled", "failed"]),
|
|
4825
4843
|
result: ImportReport.nullable(),
|
|
4826
|
-
error:
|
|
4844
|
+
error: import_zod17.z.string().nullable(),
|
|
4827
4845
|
finished_at: Timestamp
|
|
4828
4846
|
});
|
|
4829
|
-
var MailingScheduledData =
|
|
4847
|
+
var MailingScheduledData = import_zod17.z.object({
|
|
4830
4848
|
mailing_id: Id,
|
|
4831
4849
|
mailing_metadata: MailingMetadata,
|
|
4832
4850
|
scheduled_at: Timestamp.nullable()
|
|
4833
4851
|
});
|
|
4834
|
-
var MailingStartedData =
|
|
4852
|
+
var MailingStartedData = import_zod17.z.object({
|
|
4835
4853
|
mailing_id: Id,
|
|
4836
4854
|
mailing_metadata: MailingMetadata,
|
|
4837
|
-
trigger:
|
|
4838
|
-
recipients:
|
|
4855
|
+
trigger: import_zod17.z.enum(["send", "schedule"]),
|
|
4856
|
+
recipients: import_zod17.z.number().int().min(0),
|
|
4839
4857
|
started_at: Timestamp
|
|
4840
4858
|
});
|
|
4841
|
-
var MailingScheduleFailedData =
|
|
4859
|
+
var MailingScheduleFailedData = import_zod17.z.object({
|
|
4842
4860
|
mailing_id: Id,
|
|
4843
4861
|
mailing_metadata: MailingMetadata,
|
|
4844
|
-
code:
|
|
4845
|
-
message:
|
|
4862
|
+
code: import_zod17.z.string(),
|
|
4863
|
+
message: import_zod17.z.string(),
|
|
4846
4864
|
failed_at: Timestamp
|
|
4847
4865
|
});
|
|
4848
|
-
var MailingAbWinnerSelectedData =
|
|
4866
|
+
var MailingAbWinnerSelectedData = import_zod17.z.object({
|
|
4849
4867
|
mailing_id: Id,
|
|
4850
4868
|
mailing_metadata: MailingMetadata,
|
|
4851
|
-
winner:
|
|
4852
|
-
decided_by:
|
|
4853
|
-
variants:
|
|
4869
|
+
winner: import_zod17.z.string(),
|
|
4870
|
+
decided_by: import_zod17.z.enum(["metric", "manual"]),
|
|
4871
|
+
variants: import_zod17.z.array(VariantAnalytics),
|
|
4854
4872
|
decided_at: Timestamp
|
|
4855
4873
|
});
|
|
4856
|
-
var ContactTaggedData =
|
|
4874
|
+
var ContactTaggedData = import_zod17.z.object({
|
|
4857
4875
|
contact_id: Id,
|
|
4858
|
-
external_id:
|
|
4876
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4859
4877
|
email: Email,
|
|
4860
4878
|
/** Only the tags the contact did not already have. */
|
|
4861
|
-
tags:
|
|
4862
|
-
source:
|
|
4879
|
+
tags: import_zod17.z.array(Slug).min(1),
|
|
4880
|
+
source: import_zod17.z.enum(["api", "dashboard", "signup_form", "import", "automation"]),
|
|
4863
4881
|
tagged_at: Timestamp
|
|
4864
4882
|
});
|
|
4865
|
-
var ContactUpdatedData =
|
|
4883
|
+
var ContactUpdatedData = import_zod17.z.object({
|
|
4866
4884
|
contact_id: Id,
|
|
4867
|
-
external_id:
|
|
4885
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4868
4886
|
email: Email,
|
|
4869
|
-
changed:
|
|
4887
|
+
changed: import_zod17.z.array(import_zod17.z.string()).min(1),
|
|
4870
4888
|
properties: Properties,
|
|
4871
|
-
source:
|
|
4889
|
+
source: import_zod17.z.enum(["api", "dashboard", "signup_form", "import", "automation"]),
|
|
4872
4890
|
updated_at: Timestamp
|
|
4873
4891
|
});
|
|
4874
|
-
var AutomationRunEventBase =
|
|
4892
|
+
var AutomationRunEventBase = import_zod17.z.object({
|
|
4875
4893
|
automation_id: Id,
|
|
4876
|
-
automation_name:
|
|
4894
|
+
automation_name: import_zod17.z.string(),
|
|
4877
4895
|
run_id: Id,
|
|
4878
|
-
version:
|
|
4896
|
+
version: import_zod17.z.number().int().min(1),
|
|
4879
4897
|
contact_id: Id,
|
|
4880
|
-
external_id:
|
|
4898
|
+
external_id: import_zod17.z.string().nullable(),
|
|
4881
4899
|
email: Email
|
|
4882
4900
|
});
|
|
4883
4901
|
var AutomationRunStartedData = AutomationRunEventBase.extend({
|
|
4884
4902
|
/** What let them in: a trigger kind, or `manual` for an explicit enrolment. */
|
|
4885
|
-
trigger_kind:
|
|
4903
|
+
trigger_kind: import_zod17.z.string(),
|
|
4886
4904
|
entered_at: Timestamp
|
|
4887
4905
|
});
|
|
4888
4906
|
var AutomationRunCompletedData = AutomationRunEventBase.extend({
|
|
4889
|
-
last_step_id:
|
|
4907
|
+
last_step_id: import_zod17.z.string().nullable(),
|
|
4890
4908
|
completed_at: Timestamp
|
|
4891
4909
|
});
|
|
4892
4910
|
var AutomationRunExitedData = AutomationRunEventBase.extend({
|
|
4893
4911
|
reason: AutomationEndReason,
|
|
4894
|
-
step_id:
|
|
4912
|
+
step_id: import_zod17.z.string().nullable(),
|
|
4895
4913
|
exited_at: Timestamp
|
|
4896
4914
|
});
|
|
4897
4915
|
var AutomationRunFailedData = AutomationRunEventBase.extend({
|
|
4898
|
-
reason:
|
|
4899
|
-
step_id:
|
|
4916
|
+
reason: import_zod17.z.string(),
|
|
4917
|
+
step_id: import_zod17.z.string().nullable(),
|
|
4900
4918
|
failed_at: Timestamp
|
|
4901
4919
|
});
|
|
4902
4920
|
var AutomationWebhookData = AutomationRunEventBase.extend({
|
|
4903
|
-
step_id:
|
|
4921
|
+
step_id: import_zod17.z.string(),
|
|
4904
4922
|
/** The step's own label, when it was given one, so a receiver can branch on a name. */
|
|
4905
|
-
step_label:
|
|
4923
|
+
step_label: import_zod17.z.string().nullable(),
|
|
4906
4924
|
/** Whatever the step carries, verbatim. Null when it carries nothing. */
|
|
4907
4925
|
payload: JsonValue.nullable(),
|
|
4908
4926
|
fired_at: Timestamp
|
|
4909
4927
|
});
|
|
4910
|
-
var TemplateEventBase =
|
|
4928
|
+
var TemplateEventBase = import_zod17.z.object({
|
|
4911
4929
|
template_id: Id,
|
|
4912
|
-
name:
|
|
4913
|
-
version:
|
|
4914
|
-
source:
|
|
4930
|
+
name: import_zod17.z.string().min(1).max(200),
|
|
4931
|
+
version: import_zod17.z.number().int().min(1),
|
|
4932
|
+
source: import_zod17.z.enum(["api", "dashboard", "mjml_import"])
|
|
4915
4933
|
});
|
|
4916
4934
|
var TemplateCreatedData = TemplateEventBase.extend({ created_at: Timestamp });
|
|
4917
|
-
var TemplateUpdatedData = TemplateEventBase.extend({ archived:
|
|
4935
|
+
var TemplateUpdatedData = TemplateEventBase.extend({ archived: import_zod17.z.boolean(), updated_at: Timestamp });
|
|
4918
4936
|
var TemplateDeletedData = TemplateEventBase.extend({ deleted_at: Timestamp });
|
|
4919
|
-
var envelope = (type, data) =>
|
|
4937
|
+
var envelope = (type, data) => import_zod17.z.object({
|
|
4920
4938
|
/** Unique per event: a receiver deduplicates on it (deliveries may repeat). */
|
|
4921
4939
|
id: Id,
|
|
4922
|
-
type:
|
|
4940
|
+
type: import_zod17.z.literal(type),
|
|
4923
4941
|
created_at: Timestamp,
|
|
4924
4942
|
workspace_id: Id,
|
|
4925
4943
|
data
|
|
4926
4944
|
});
|
|
4927
|
-
var WebhookEvent =
|
|
4945
|
+
var WebhookEvent = import_zod17.z.discriminatedUnion("type", [
|
|
4928
4946
|
envelope("message.sent", MessageSentData),
|
|
4929
4947
|
envelope("message.failed", MessageFailedData),
|
|
4930
4948
|
envelope("contact.unsubscribed", ContactUnsubscribedData),
|
|
@@ -4948,16 +4966,16 @@ var WebhookEvent = import_zod16.z.discriminatedUnion("type", [
|
|
|
4948
4966
|
envelope("template.updated", TemplateUpdatedData),
|
|
4949
4967
|
envelope("template.deleted", TemplateDeletedData)
|
|
4950
4968
|
]);
|
|
4951
|
-
var WebhookEndpoint =
|
|
4969
|
+
var WebhookEndpoint = import_zod17.z.object({
|
|
4952
4970
|
id: Id,
|
|
4953
|
-
url:
|
|
4954
|
-
description:
|
|
4955
|
-
events:
|
|
4956
|
-
enabled:
|
|
4971
|
+
url: import_zod17.z.string().url(),
|
|
4972
|
+
description: import_zod17.z.string().max(500).nullable(),
|
|
4973
|
+
events: import_zod17.z.array(WebhookEventType).min(1),
|
|
4974
|
+
enabled: import_zod17.z.boolean(),
|
|
4957
4975
|
created_at: Timestamp,
|
|
4958
4976
|
updated_at: Timestamp
|
|
4959
4977
|
});
|
|
4960
|
-
var WebhookUrl =
|
|
4978
|
+
var WebhookUrl = import_zod17.z.string().url().refine((u) => {
|
|
4961
4979
|
try {
|
|
4962
4980
|
const url = new URL(u);
|
|
4963
4981
|
if (url.protocol === "https:") return true;
|
|
@@ -4966,35 +4984,35 @@ var WebhookUrl = import_zod16.z.string().url().refine((u) => {
|
|
|
4966
4984
|
return false;
|
|
4967
4985
|
}
|
|
4968
4986
|
}, "must be https (http only for localhost)");
|
|
4969
|
-
var WebhookEndpointCreate =
|
|
4987
|
+
var WebhookEndpointCreate = import_zod17.z.object({
|
|
4970
4988
|
url: WebhookUrl,
|
|
4971
|
-
description:
|
|
4972
|
-
events:
|
|
4973
|
-
enabled:
|
|
4989
|
+
description: import_zod17.z.string().max(500).optional(),
|
|
4990
|
+
events: import_zod17.z.array(WebhookEventType).min(1),
|
|
4991
|
+
enabled: import_zod17.z.boolean().optional()
|
|
4974
4992
|
});
|
|
4975
|
-
var WebhookEndpointUpdate =
|
|
4993
|
+
var WebhookEndpointUpdate = import_zod17.z.object({
|
|
4976
4994
|
url: WebhookUrl,
|
|
4977
|
-
description:
|
|
4978
|
-
events:
|
|
4979
|
-
enabled:
|
|
4995
|
+
description: import_zod17.z.string().max(500).nullable(),
|
|
4996
|
+
events: import_zod17.z.array(WebhookEventType).min(1),
|
|
4997
|
+
enabled: import_zod17.z.boolean()
|
|
4980
4998
|
}).partial().refine((v) => Object.keys(v).length > 0, "at least one field");
|
|
4981
|
-
var WebhookEndpointWithSecret =
|
|
4999
|
+
var WebhookEndpointWithSecret = import_zod17.z.object({
|
|
4982
5000
|
endpoint: WebhookEndpoint,
|
|
4983
|
-
secret:
|
|
5001
|
+
secret: import_zod17.z.string().min(32)
|
|
4984
5002
|
});
|
|
4985
5003
|
var WEBHOOK_DELIVERY_STATUSES = ["pending", "succeeded", "failed"];
|
|
4986
|
-
var WebhookDeliveryStatus =
|
|
5004
|
+
var WebhookDeliveryStatus = import_zod17.z.enum(WEBHOOK_DELIVERY_STATUSES);
|
|
4987
5005
|
var WEBHOOK_MAX_ATTEMPTS = 8;
|
|
4988
5006
|
var WEBHOOK_RETRY_DELAYS_SECONDS = [30, 120, 600, 1800, 3600, 7200, 21600];
|
|
4989
|
-
var WebhookDelivery =
|
|
5007
|
+
var WebhookDelivery = import_zod17.z.object({
|
|
4990
5008
|
id: Id,
|
|
4991
5009
|
endpoint_id: Id,
|
|
4992
5010
|
event_id: Id,
|
|
4993
5011
|
event_type: WebhookEventType,
|
|
4994
5012
|
status: WebhookDeliveryStatus,
|
|
4995
|
-
attempts:
|
|
4996
|
-
last_status_code:
|
|
4997
|
-
last_error:
|
|
5013
|
+
attempts: import_zod17.z.number().int().min(0),
|
|
5014
|
+
last_status_code: import_zod17.z.number().int().min(100).max(599).nullable(),
|
|
5015
|
+
last_error: import_zod17.z.string().nullable(),
|
|
4998
5016
|
next_attempt_at: Timestamp.nullable(),
|
|
4999
5017
|
delivered_at: Timestamp.nullable(),
|
|
5000
5018
|
created_at: Timestamp
|
|
@@ -5003,7 +5021,7 @@ var WebhookDeliveryListQuery = PageQuery.extend({
|
|
|
5003
5021
|
status: WebhookDeliveryStatus.optional(),
|
|
5004
5022
|
event_type: WebhookEventType.optional()
|
|
5005
5023
|
});
|
|
5006
|
-
var WebhookDeliveryParams =
|
|
5024
|
+
var WebhookDeliveryParams = import_zod17.z.object({ id: Id, delivery_id: Id });
|
|
5007
5025
|
|
|
5008
5026
|
// src/webhook-signing.ts
|
|
5009
5027
|
var WEBHOOK_SIGNATURE_HEADER = "x-mail-signature";
|
|
@@ -5070,94 +5088,99 @@ async function verifyWebhook(input) {
|
|
|
5070
5088
|
}
|
|
5071
5089
|
|
|
5072
5090
|
// src/billing.ts
|
|
5073
|
-
var
|
|
5091
|
+
var import_zod18 = require("zod");
|
|
5074
5092
|
var PLAN_IDS = ["free", "starter", "growth", "design_partner"];
|
|
5075
|
-
var PlanId =
|
|
5076
|
-
var PlanLimits =
|
|
5077
|
-
monthly_messages:
|
|
5078
|
-
contacts:
|
|
5079
|
-
members:
|
|
5080
|
-
providers:
|
|
5081
|
-
webhook_endpoints:
|
|
5093
|
+
var PlanId = import_zod18.z.enum(PLAN_IDS);
|
|
5094
|
+
var PlanLimits = import_zod18.z.object({
|
|
5095
|
+
monthly_messages: import_zod18.z.number().int().min(0).nullable(),
|
|
5096
|
+
contacts: import_zod18.z.number().int().min(0).nullable(),
|
|
5097
|
+
members: import_zod18.z.number().int().min(1).nullable(),
|
|
5098
|
+
providers: import_zod18.z.number().int().min(1).nullable(),
|
|
5099
|
+
webhook_endpoints: import_zod18.z.number().int().min(0).nullable(),
|
|
5082
5100
|
/** Automations that may be live (active or paused) at once (A1). */
|
|
5083
|
-
active_automations:
|
|
5101
|
+
active_automations: import_zod18.z.number().int().min(0).nullable(),
|
|
5084
5102
|
/** Steps one automation may hold. Null is the flow's own cap, not unlimited. */
|
|
5085
|
-
automation_steps:
|
|
5103
|
+
automation_steps: import_zod18.z.number().int().min(1).nullable(),
|
|
5086
5104
|
/** Own domains Lumitra Mail sends from (managed sending domains); 0 when the plan has none. */
|
|
5087
|
-
sending_domains:
|
|
5105
|
+
sending_domains: import_zod18.z.number().int().min(0).nullable()
|
|
5088
5106
|
});
|
|
5089
|
-
var PlanFeatures =
|
|
5107
|
+
var PlanFeatures = import_zod18.z.object({
|
|
5090
5108
|
/** A/B tests of subject and content on a mailing (S4). */
|
|
5091
|
-
ab_testing:
|
|
5109
|
+
ab_testing: import_zod18.z.boolean(),
|
|
5092
5110
|
/** Open and click tracking, still off until a workspace turns it on (`settings.tracking_enabled`). */
|
|
5093
|
-
tracking:
|
|
5111
|
+
tracking: import_zod18.z.boolean(),
|
|
5094
5112
|
/** Automations: flows a person walks through step by step (A1). */
|
|
5095
|
-
automations:
|
|
5113
|
+
automations: import_zod18.z.boolean()
|
|
5096
5114
|
});
|
|
5097
5115
|
var PLAN_FEATURES = ["ab_testing", "tracking", "automations"];
|
|
5098
|
-
var Plan =
|
|
5116
|
+
var Plan = import_zod18.z.object({
|
|
5099
5117
|
id: PlanId,
|
|
5100
|
-
name:
|
|
5118
|
+
name: import_zod18.z.string().min(1),
|
|
5101
5119
|
/** Price in the smallest currency unit per month; null for plans not sold. */
|
|
5102
|
-
monthly_price_cents:
|
|
5103
|
-
currency:
|
|
5120
|
+
monthly_price_cents: import_zod18.z.number().int().min(0).nullable(),
|
|
5121
|
+
currency: import_zod18.z.string().length(3),
|
|
5104
5122
|
limits: PlanLimits,
|
|
5105
5123
|
features: PlanFeatures
|
|
5106
5124
|
});
|
|
5107
|
-
var CatalogPlan = Plan.extend({ sellable:
|
|
5108
|
-
var Subscription =
|
|
5125
|
+
var CatalogPlan = Plan.extend({ sellable: import_zod18.z.boolean() });
|
|
5126
|
+
var Subscription = import_zod18.z.object({
|
|
5109
5127
|
workspace_id: Id,
|
|
5110
5128
|
plan: PlanId,
|
|
5111
|
-
status:
|
|
5129
|
+
status: import_zod18.z.enum(["active", "trialing", "past_due", "cancelled"]),
|
|
5112
5130
|
current_period_start: Timestamp,
|
|
5113
5131
|
current_period_end: Timestamp,
|
|
5114
|
-
cancel_at_period_end:
|
|
5132
|
+
cancel_at_period_end: import_zod18.z.boolean(),
|
|
5115
5133
|
/**
|
|
5116
5134
|
* A design partner outside billing (plan `design_partner`, no limits, no
|
|
5117
5135
|
* checkout). Set only by an operator, never through the API.
|
|
5118
5136
|
*/
|
|
5119
|
-
billing_exempt:
|
|
5137
|
+
billing_exempt: import_zod18.z.boolean(),
|
|
5120
5138
|
/**
|
|
5121
5139
|
* Own sending domains bought on top of the plan's included ones (the
|
|
5122
5140
|
* add-on), each a monthly charge on the same subscription. 0 without the
|
|
5123
5141
|
* add-on; the usage limit `sending_domains` is the plan's plus these.
|
|
5124
5142
|
*/
|
|
5125
|
-
extra_sending_domains:
|
|
5143
|
+
extra_sending_domains: import_zod18.z.number().int().min(0)
|
|
5126
5144
|
});
|
|
5127
|
-
var BillingAddons =
|
|
5128
|
-
sending_domain:
|
|
5129
|
-
monthly_price_cents:
|
|
5130
|
-
currency:
|
|
5131
|
-
sellable:
|
|
5145
|
+
var BillingAddons = import_zod18.z.object({
|
|
5146
|
+
sending_domain: import_zod18.z.object({
|
|
5147
|
+
monthly_price_cents: import_zod18.z.number().int().min(0),
|
|
5148
|
+
currency: import_zod18.z.string().length(3),
|
|
5149
|
+
sellable: import_zod18.z.boolean()
|
|
5132
5150
|
})
|
|
5133
5151
|
});
|
|
5134
5152
|
var MAX_EXTRA_SENDING_DOMAINS = 100;
|
|
5135
|
-
var ExtraSendingDomainsUpdate =
|
|
5153
|
+
var ExtraSendingDomainsUpdate = import_zod18.z.object({ quantity: import_zod18.z.number().int().min(0).max(MAX_EXTRA_SENDING_DOMAINS) });
|
|
5136
5154
|
var USAGE_METRICS = ["messages", "contacts", "members", "providers", "webhook_endpoints", "active_automations", "sending_domains"];
|
|
5137
|
-
var UsageMetric =
|
|
5155
|
+
var UsageMetric = import_zod18.z.enum(USAGE_METRICS);
|
|
5138
5156
|
var USAGE_WARNING_RATIO = 0.8;
|
|
5139
|
-
var UsageWarning =
|
|
5157
|
+
var UsageWarning = import_zod18.z.object({
|
|
5140
5158
|
metric: UsageMetric,
|
|
5141
|
-
used:
|
|
5142
|
-
limit:
|
|
5159
|
+
used: import_zod18.z.number().int().min(0),
|
|
5160
|
+
limit: import_zod18.z.number().int().min(0),
|
|
5143
5161
|
/** `approaching`: at or above USAGE_WARNING_RATIO of the limit; `reached`: at or above the limit. */
|
|
5144
|
-
level:
|
|
5162
|
+
level: import_zod18.z.enum(["approaching", "reached"])
|
|
5145
5163
|
});
|
|
5146
|
-
var
|
|
5164
|
+
var TermsStatus = import_zod18.z.object({ accepted_version: import_zod18.z.string().nullable(), current_version: import_zod18.z.string() });
|
|
5165
|
+
var Usage = import_zod18.z.object({
|
|
5147
5166
|
plan: PlanId,
|
|
5148
5167
|
period_start: Timestamp,
|
|
5149
5168
|
period_end: Timestamp,
|
|
5150
|
-
metrics:
|
|
5151
|
-
warnings:
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5169
|
+
metrics: import_zod18.z.record(UsageMetric, import_zod18.z.object({ used: import_zod18.z.number().int().min(0), limit: import_zod18.z.number().int().min(0).nullable() })),
|
|
5170
|
+
warnings: import_zod18.z.array(UsageWarning),
|
|
5171
|
+
terms: TermsStatus
|
|
5172
|
+
});
|
|
5173
|
+
var TermsAcceptance = import_zod18.z.object({ accept_terms: AcceptTerms });
|
|
5174
|
+
var CheckoutRequest = import_zod18.z.object({
|
|
5175
|
+
plan: import_zod18.z.enum(["starter", "growth"]),
|
|
5176
|
+
success_url: import_zod18.z.string().url(),
|
|
5177
|
+
cancel_url: import_zod18.z.string().url(),
|
|
5178
|
+
/** The buyer accepted the terms of service and the processing agreement of this version. */
|
|
5179
|
+
accept_terms: AcceptTerms
|
|
5180
|
+
});
|
|
5181
|
+
var CheckoutSession = import_zod18.z.object({ url: import_zod18.z.string().url() });
|
|
5182
|
+
var PortalRequest = import_zod18.z.object({ return_url: import_zod18.z.string().url() });
|
|
5183
|
+
var PortalSession = import_zod18.z.object({ url: import_zod18.z.string().url() });
|
|
5161
5184
|
var USAGE_WARNING_HEADER = "x-mail-usage-warning";
|
|
5162
5185
|
function formatUsageWarningHeader(warnings) {
|
|
5163
5186
|
if (warnings.length === 0) return null;
|
|
@@ -5177,7 +5200,7 @@ function parseUsageWarningHeader(value) {
|
|
|
5177
5200
|
}
|
|
5178
5201
|
|
|
5179
5202
|
// src/routes.ts
|
|
5180
|
-
var
|
|
5203
|
+
var import_zod19 = require("zod");
|
|
5181
5204
|
var list = (item) => page(item);
|
|
5182
5205
|
var foundationRoutes = {
|
|
5183
5206
|
"workspaces.create": {
|
|
@@ -5423,7 +5446,7 @@ var templateRoutes = {
|
|
|
5423
5446
|
path: "/v1/templates/:id/export",
|
|
5424
5447
|
params: IdParams,
|
|
5425
5448
|
query: TemplateExportQuery,
|
|
5426
|
-
response:
|
|
5449
|
+
response: import_zod19.z.string(),
|
|
5427
5450
|
responseType: "text",
|
|
5428
5451
|
status: 200,
|
|
5429
5452
|
access: "read",
|
|
@@ -5803,7 +5826,7 @@ var sendingRoutes = {
|
|
|
5803
5826
|
path: "/v1/mailings/:id/export",
|
|
5804
5827
|
params: IdParams,
|
|
5805
5828
|
query: MailingExportQuery,
|
|
5806
|
-
response:
|
|
5829
|
+
response: import_zod19.z.string(),
|
|
5807
5830
|
responseType: "text",
|
|
5808
5831
|
status: 200,
|
|
5809
5832
|
access: "read",
|
|
@@ -6070,7 +6093,7 @@ var platformRoutes = {
|
|
|
6070
6093
|
"contactProperties.list": {
|
|
6071
6094
|
method: "GET",
|
|
6072
6095
|
path: "/v1/contact-properties",
|
|
6073
|
-
response:
|
|
6096
|
+
response: import_zod19.z.object({ data: import_zod19.z.array(ContactPropertyDefinition) }),
|
|
6074
6097
|
status: 200,
|
|
6075
6098
|
access: "read",
|
|
6076
6099
|
phase: "S4"
|
|
@@ -6369,7 +6392,7 @@ var billingRoutes = {
|
|
|
6369
6392
|
"billing.plans": {
|
|
6370
6393
|
method: "GET",
|
|
6371
6394
|
path: "/v1/billing/plans",
|
|
6372
|
-
response:
|
|
6395
|
+
response: import_zod19.z.object({ data: import_zod19.z.array(CatalogPlan), addons: BillingAddons }),
|
|
6373
6396
|
status: 200,
|
|
6374
6397
|
access: "read",
|
|
6375
6398
|
phase: "S5"
|
|
@@ -6409,6 +6432,15 @@ var billingRoutes = {
|
|
|
6409
6432
|
status: 200,
|
|
6410
6433
|
access: "admin",
|
|
6411
6434
|
phase: "S5"
|
|
6435
|
+
},
|
|
6436
|
+
"billing.acceptTerms": {
|
|
6437
|
+
method: "POST",
|
|
6438
|
+
path: "/v1/billing/terms",
|
|
6439
|
+
body: TermsAcceptance,
|
|
6440
|
+
response: TermsStatus,
|
|
6441
|
+
status: 200,
|
|
6442
|
+
access: "admin",
|
|
6443
|
+
phase: "S5"
|
|
6412
6444
|
}
|
|
6413
6445
|
};
|
|
6414
6446
|
var inviteRoutes = {
|
|
@@ -6520,7 +6552,7 @@ var automationRoutes = {
|
|
|
6520
6552
|
method: "POST",
|
|
6521
6553
|
path: "/v1/automations/:id/pause",
|
|
6522
6554
|
params: IdParams,
|
|
6523
|
-
body:
|
|
6555
|
+
body: import_zod19.z.object({}).strict(),
|
|
6524
6556
|
response: Automation,
|
|
6525
6557
|
status: 200,
|
|
6526
6558
|
access: "write",
|
|
@@ -6530,7 +6562,7 @@ var automationRoutes = {
|
|
|
6530
6562
|
method: "POST",
|
|
6531
6563
|
path: "/v1/automations/:id/resume",
|
|
6532
6564
|
params: IdParams,
|
|
6533
|
-
body:
|
|
6565
|
+
body: import_zod19.z.object({}).strict(),
|
|
6534
6566
|
response: Automation,
|
|
6535
6567
|
status: 200,
|
|
6536
6568
|
access: "write",
|
|
@@ -6540,7 +6572,7 @@ var automationRoutes = {
|
|
|
6540
6572
|
method: "POST",
|
|
6541
6573
|
path: "/v1/automations/:id/archive",
|
|
6542
6574
|
params: IdParams,
|
|
6543
|
-
body:
|
|
6575
|
+
body: import_zod19.z.object({}).strict(),
|
|
6544
6576
|
response: Automation,
|
|
6545
6577
|
status: 200,
|
|
6546
6578
|
access: "write",
|
|
@@ -6721,6 +6753,7 @@ function matchRoute(method, pathname) {
|
|
|
6721
6753
|
AbTestState,
|
|
6722
6754
|
AbVariant,
|
|
6723
6755
|
AbWinnerRequest,
|
|
6756
|
+
AcceptTerms,
|
|
6724
6757
|
ApiKey,
|
|
6725
6758
|
ApiKeyCreate,
|
|
6726
6759
|
ApiKeyCreated,
|
|
@@ -6892,6 +6925,7 @@ function matchRoute(method, pathname) {
|
|
|
6892
6925
|
InviteListQuery,
|
|
6893
6926
|
InviteStatus,
|
|
6894
6927
|
JsonValue,
|
|
6928
|
+
LEGAL_TERMS_VERSION,
|
|
6895
6929
|
LETTER_ONLY_MERGE_FIELDS,
|
|
6896
6930
|
LETTER_RECIPIENT_REFUSAL,
|
|
6897
6931
|
LIST_UNSUBSCRIBE_POST_VALUE,
|
|
@@ -7138,6 +7172,8 @@ function matchRoute(method, pathname) {
|
|
|
7138
7172
|
TemplateUpdatedData,
|
|
7139
7173
|
TemplateVersion,
|
|
7140
7174
|
TemplateVersionParams,
|
|
7175
|
+
TermsAcceptance,
|
|
7176
|
+
TermsStatus,
|
|
7141
7177
|
TimeOfDay,
|
|
7142
7178
|
Timestamp,
|
|
7143
7179
|
TimezoneName,
|