@hermeticacomms/sdk-node 0.0.0-stage → 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/LICENSE +9 -0
- package/README.md +12 -2
- package/dist/contracts/analytics.d.ts +405 -0
- package/dist/contracts/analytics.js +77 -0
- package/dist/contracts/auth.d.ts +363 -0
- package/dist/contracts/auth.js +130 -0
- package/dist/contracts/billing.d.ts +143 -0
- package/dist/contracts/billing.js +32 -0
- package/dist/contracts/campaigns.d.ts +915 -0
- package/dist/contracts/campaigns.js +276 -0
- package/dist/contracts/common.d.ts +57 -0
- package/dist/contracts/common.js +35 -0
- package/dist/contracts/connectors.d.ts +179 -0
- package/dist/contracts/connectors.js +46 -0
- package/dist/contracts/consent.d.ts +628 -0
- package/dist/contracts/consent.js +194 -0
- package/dist/contracts/content-blocks.d.ts +165 -0
- package/dist/contracts/content-blocks.js +62 -0
- package/dist/contracts/content-library.d.ts +347 -0
- package/dist/contracts/content-library.js +52 -0
- package/dist/contracts/content.d.ts +955 -0
- package/dist/contracts/content.js +194 -0
- package/dist/contracts/delivery.d.ts +602 -0
- package/dist/contracts/delivery.js +220 -0
- package/dist/contracts/events.d.ts +514 -0
- package/dist/contracts/events.js +180 -0
- package/dist/contracts/experiments.d.ts +378 -0
- package/dist/contracts/experiments.js +140 -0
- package/dist/contracts/identity.d.ts +761 -0
- package/dist/contracts/identity.js +226 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.js +15 -0
- package/dist/contracts/integrations.d.ts +445 -0
- package/dist/contracts/integrations.js +139 -0
- package/dist/contracts/leads.d.ts +733 -0
- package/dist/contracts/leads.js +125 -0
- package/dist/contracts/metrics.d.ts +465 -0
- package/dist/contracts/metrics.js +96 -0
- package/dist/contracts/outbound.d.ts +15535 -0
- package/dist/contracts/outbound.js +432 -0
- package/dist/contracts/pickers.d.ts +12 -0
- package/dist/contracts/pickers.js +20 -0
- package/dist/contracts/platform-admin.d.ts +244 -0
- package/dist/contracts/platform-admin.js +98 -0
- package/dist/contracts/postcards.d.ts +79 -0
- package/dist/contracts/postcards.js +29 -0
- package/dist/contracts/push.d.ts +530 -0
- package/dist/contracts/push.js +102 -0
- package/dist/contracts/rcs.d.ts +39 -0
- package/dist/contracts/rcs.js +19 -0
- package/dist/contracts/segments.d.ts +3187 -0
- package/dist/contracts/segments.js +421 -0
- package/dist/contracts/workflow-nodes.d.ts +2130 -0
- package/dist/contracts/workflow-nodes.js +346 -0
- package/dist/contracts/workflows.d.ts +46811 -0
- package/dist/contracts/workflows.js +350 -0
- package/dist/contracts/x10-platform.d.ts +2603 -0
- package/dist/contracts/x10-platform.js +129 -0
- package/dist/http.d.ts +30 -0
- package/dist/http.js +65 -0
- package/dist/index.d.ts +11631 -0
- package/dist/index.js +63 -0
- package/dist/platform.d.ts +163 -0
- package/dist/platform.js +40 -0
- package/dist/resources.d.ts +1338 -0
- package/dist/resources.js +56 -0
- package/dist/signature.d.ts +5 -0
- package/dist/signature.js +19 -0
- package/dist/x10.d.ts +1608 -0
- package/dist/x10.js +66 -0
- package/dist/z10.d.ts +256 -0
- package/dist/z10.js +46 -0
- package/package.json +40 -4
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AppSlug, Channel, DateTimeIn, Id, Purpose, Timestamp, patchOf } from './common.js';
|
|
3
|
+
export const ConsentStatus = z.enum(['granted', 'revoked', 'pending_confirmation']);
|
|
4
|
+
export const LegalBasis = z.enum(['consent', 'legitimate_interest', 'contract', 'other']);
|
|
5
|
+
export const ConsentSource = z.enum(['form', 'import', 'api', 'sms_keyword', 'preference_center', 'admin', 'double_opt_in', 'instagram_dm', 'facebook_dm']);
|
|
6
|
+
export const RevocationScope = z.enum(['topic', 'channel', 'all']);
|
|
7
|
+
export const SuppressionReason = z.enum(['unsubscribe', 'hard_bounce', 'complaint', 'stop_keyword', 'manual', 'invalid', 'dnc']);
|
|
8
|
+
export const SuppressionScope = z.enum(['global', 'topic', 'purpose']);
|
|
9
|
+
export const BlockReason = z.enum([
|
|
10
|
+
'suppressed',
|
|
11
|
+
'no_consent',
|
|
12
|
+
'consent_revoked',
|
|
13
|
+
'consent_expired',
|
|
14
|
+
'topic_unsubscribed',
|
|
15
|
+
'blocklisted_domain',
|
|
16
|
+
'jurisdiction_blocked',
|
|
17
|
+
'transactional_only',
|
|
18
|
+
'snoozed',
|
|
19
|
+
'channel_not_preferred',
|
|
20
|
+
'frequency_limited',
|
|
21
|
+
]);
|
|
22
|
+
/** Consent assertion for one (channel, purpose, topic). */
|
|
23
|
+
export const ConsentInputBody = z.object({
|
|
24
|
+
channel: Channel,
|
|
25
|
+
purpose: Purpose,
|
|
26
|
+
topicId: Id.nullish(),
|
|
27
|
+
status: ConsentStatus,
|
|
28
|
+
legalBasis: LegalBasis.default('consent'),
|
|
29
|
+
source: ConsentSource,
|
|
30
|
+
sourceRef: z.string().max(256).nullish(),
|
|
31
|
+
disclosureText: z.string().max(4000).nullish(),
|
|
32
|
+
disclosureVersion: z.string().max(64).nullish(),
|
|
33
|
+
ip: z.string().max(64).nullish(),
|
|
34
|
+
userAgent: z.string().max(512).nullish(),
|
|
35
|
+
proof: z.record(z.string(), z.unknown()).nullish().describe('From an API key, a proof source needs evidence: form → formSubmissionId; double_opt_in / sms_keyword → consentRecordId of that flow'),
|
|
36
|
+
expiresAt: DateTimeIn().nullish(),
|
|
37
|
+
revocationScope: RevocationScope.nullish(),
|
|
38
|
+
});
|
|
39
|
+
export const ConsentInput = ConsentInputBody.extend({ profileId: Id });
|
|
40
|
+
export const ConsentRecordDto = z.object({
|
|
41
|
+
id: Id,
|
|
42
|
+
profileId: Id,
|
|
43
|
+
channel: Channel,
|
|
44
|
+
purpose: Purpose,
|
|
45
|
+
topicId: Id.nullable(),
|
|
46
|
+
status: ConsentStatus,
|
|
47
|
+
legalBasis: LegalBasis,
|
|
48
|
+
source: ConsentSource,
|
|
49
|
+
sourceRef: z.string().nullable(),
|
|
50
|
+
disclosureText: z.string().nullable(),
|
|
51
|
+
disclosureVersion: z.string().nullable(),
|
|
52
|
+
expiresAt: Timestamp.nullable(),
|
|
53
|
+
revocationScope: RevocationScope.nullable(),
|
|
54
|
+
at: Timestamp,
|
|
55
|
+
});
|
|
56
|
+
export const ConsentOutcome = z.union([z.object({ record: ConsentRecordDto }), z.object({ ignored: z.literal('revoked_previously') })]);
|
|
57
|
+
/** Latest status per (profile, channel, purpose, topic). */
|
|
58
|
+
export const ConsentStateDto = z.object({
|
|
59
|
+
profileId: Id,
|
|
60
|
+
channel: Channel,
|
|
61
|
+
purpose: Purpose,
|
|
62
|
+
topicId: Id.nullable(),
|
|
63
|
+
status: ConsentStatus,
|
|
64
|
+
recordId: Id,
|
|
65
|
+
expiresAt: Timestamp.nullable(),
|
|
66
|
+
updatedAt: Timestamp,
|
|
67
|
+
/** Source of the record behind this state (form, double_opt_in, api, ...). */
|
|
68
|
+
source: z.string().nullable().optional(),
|
|
69
|
+
});
|
|
70
|
+
export const TopicInput = z.object({
|
|
71
|
+
channel: Channel,
|
|
72
|
+
key: z.string().min(1).max(64).regex(/^[a-z0-9_-]+$/),
|
|
73
|
+
name: z.string().min(1).max(128),
|
|
74
|
+
description: z.string().max(1000).nullish(),
|
|
75
|
+
defaultOptIn: z.boolean().default(false),
|
|
76
|
+
visibleInPreferenceCenter: z.boolean().default(true),
|
|
77
|
+
groupId: Id.nullish(),
|
|
78
|
+
position: z.number().int().min(0).max(10_000).optional(),
|
|
79
|
+
/** Product that owns the topic (null = shared). Keys stay workspace-unique, so still prefix them across products. */
|
|
80
|
+
app: AppSlug.nullish(),
|
|
81
|
+
});
|
|
82
|
+
// Without defaults: zod 4 `.partial()` keeps them, so patching only the name would flip defaultOptIn back to false.
|
|
83
|
+
export const TopicPatch = TopicInput.omit({ channel: true, key: true }).extend({ defaultOptIn: z.boolean().optional(), visibleInPreferenceCenter: z.boolean().optional() }).partial();
|
|
84
|
+
export const TopicDto = z.object({
|
|
85
|
+
id: Id,
|
|
86
|
+
channel: Channel,
|
|
87
|
+
key: z.string(),
|
|
88
|
+
name: z.string(),
|
|
89
|
+
description: z.string().nullable(),
|
|
90
|
+
defaultOptIn: z.boolean(),
|
|
91
|
+
visibleInPreferenceCenter: z.boolean(),
|
|
92
|
+
groupId: Id.nullable().optional(),
|
|
93
|
+
position: z.number().int().optional(),
|
|
94
|
+
app: z.string().nullable().optional(),
|
|
95
|
+
createdAt: Timestamp,
|
|
96
|
+
archivedAt: Timestamp.nullable().optional(),
|
|
97
|
+
/** With ?counts=true: people with granted consent on this topic. */
|
|
98
|
+
subscriberCount: z.number().int().optional(),
|
|
99
|
+
});
|
|
100
|
+
/** Interest category: groups topics with a display type for the preference centre. */
|
|
101
|
+
export const TopicGroupBody = z.object({
|
|
102
|
+
name: z.string().trim().min(1).max(128),
|
|
103
|
+
displayType: z.enum(['checkboxes', 'radio', 'dropdown', 'hidden']).default('checkboxes'),
|
|
104
|
+
position: z.number().int().min(0).max(10_000).default(0),
|
|
105
|
+
});
|
|
106
|
+
export const TopicGroupPatch = patchOf(TopicGroupBody);
|
|
107
|
+
export const TopicGroupDto = z.object({ id: Id, name: z.string(), displayType: z.string(), position: z.number().int(), topicCount: z.number().int().optional(), createdAt: Timestamp });
|
|
108
|
+
export const SuppressionInput = z.object({
|
|
109
|
+
channel: Channel,
|
|
110
|
+
value: z.string().min(1).max(320),
|
|
111
|
+
scope: SuppressionScope.default('global'),
|
|
112
|
+
topicId: Id.nullish(),
|
|
113
|
+
purpose: Purpose.nullish(),
|
|
114
|
+
reason: SuppressionReason,
|
|
115
|
+
sourceRef: z.string().max(256).nullish(),
|
|
116
|
+
});
|
|
117
|
+
export const SuppressionDto = z.object({
|
|
118
|
+
id: Id,
|
|
119
|
+
channel: Channel,
|
|
120
|
+
valueNormalized: z.string(),
|
|
121
|
+
scope: SuppressionScope,
|
|
122
|
+
topicId: Id.nullable(),
|
|
123
|
+
purpose: Purpose.nullable(),
|
|
124
|
+
reason: SuppressionReason,
|
|
125
|
+
sourceRef: z.string().nullable(),
|
|
126
|
+
liftedAt: Timestamp.nullable(),
|
|
127
|
+
liftedBy: z.string().nullable(),
|
|
128
|
+
liftReason: z.string().nullable(),
|
|
129
|
+
createdAt: Timestamp,
|
|
130
|
+
});
|
|
131
|
+
export const SuppressionListQuery = z.object({
|
|
132
|
+
channel: Channel.optional(),
|
|
133
|
+
active: z.enum(['true', 'false']).optional(),
|
|
134
|
+
/** Case-insensitive substring of the suppressed address / phone number. */
|
|
135
|
+
q: z.string().trim().min(1).max(320).optional(),
|
|
136
|
+
/** Suppression type. */
|
|
137
|
+
reason: SuppressionReason.optional(),
|
|
138
|
+
/** Email domain (e.g. example.com); email suppressions only. */
|
|
139
|
+
domain: z.string().trim().toLowerCase().min(1).max(253).optional(),
|
|
140
|
+
/** Created on/after, before. */
|
|
141
|
+
createdFrom: DateTimeIn().optional(),
|
|
142
|
+
createdTo: DateTimeIn().optional(),
|
|
143
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
144
|
+
cursor: Id.optional(),
|
|
145
|
+
});
|
|
146
|
+
export const LiftSuppressionBody = z.object({ reason: z.string().min(1).max(500) });
|
|
147
|
+
export const BlocklistInput = z.object({ domain: z.string().min(3).max(253), reason: z.string().max(500).nullish() });
|
|
148
|
+
export const BlocklistDto = z.object({ id: Id, domain: z.string(), reason: z.string().nullable(), createdAt: Timestamp });
|
|
149
|
+
export const EligibilityRequest = z.object({
|
|
150
|
+
profileId: Id,
|
|
151
|
+
channel: Channel,
|
|
152
|
+
purpose: Purpose,
|
|
153
|
+
topicId: Id.optional(),
|
|
154
|
+
destination: z.string().min(1).max(320),
|
|
155
|
+
recipientCountry: z.string().length(2).optional(),
|
|
156
|
+
/** Outbound sequence the send belongs to: a legitimate-interest assessment scoped to it may lift a jurisdiction block. */
|
|
157
|
+
sequenceId: Id.optional(),
|
|
158
|
+
});
|
|
159
|
+
/** `liaId`: the legitimate-interest assessment that lifted this prospecting send's jurisdiction block. */
|
|
160
|
+
export const Eligibility = z.object({ eligible: z.boolean(), reasons: z.array(BlockReason), liaId: z.string().optional() });
|
|
161
|
+
/** Workspace-wide opt-outs (latest consent state revoked), filterable by channel and topic. */
|
|
162
|
+
export const OptoutListQuery = z.object({
|
|
163
|
+
channel: Channel.optional(), topicId: z.union([z.uuid(), z.literal('none')]).optional(),
|
|
164
|
+
limit: z.coerce.number().int().min(1).max(200).default(50), offset: z.coerce.number().int().min(0).default(0),
|
|
165
|
+
});
|
|
166
|
+
export const OptoutDto = z.object({ profileId: z.uuid(), channel: Channel, purpose: z.string(), topicId: z.uuid().nullable(), revokedAt: Timestamp });
|
|
167
|
+
export const OptoutPage = z.object({ items: z.array(OptoutDto), total: z.number().int() });
|
|
168
|
+
/** Clear hard-bounce suppressions in a date range (or one address); admin only, audited with the reason. */
|
|
169
|
+
export const BounceLiftBody = z.object({ startDate: DateTimeIn().optional(), endDate: DateTimeIn().optional(), email: z.string().max(320).optional(), reason: z.string().min(1).max(500) });
|
|
170
|
+
export const BounceLiftResult = z.object({ lifted: z.number().int() });
|
|
171
|
+
/** Legitimate-interest assessment (D-OUT-29): unlocks prospecting to the listed default-blocked countries until revoked. */
|
|
172
|
+
export const LiaInput = z.object({
|
|
173
|
+
purpose: z.string().trim().min(10).max(4000),
|
|
174
|
+
balancingTest: z.string().trim().min(10).max(8000),
|
|
175
|
+
optOutWording: z.string().trim().min(5).max(1000),
|
|
176
|
+
countries: z.array(z.string().length(2)).min(1).max(40),
|
|
177
|
+
/** Limit it to these outbound sequences and/or profiles in these segments; both empty = every prospecting path. */
|
|
178
|
+
sequenceIds: z.array(Id).max(50).optional(), segmentIds: z.array(Id).max(50).optional(),
|
|
179
|
+
/** When to look at it again (a reminder, not enforced) and when it stops unlocking anything. */
|
|
180
|
+
reviewAt: DateTimeIn().nullable().optional(), expiresAt: DateTimeIn().nullable().optional(),
|
|
181
|
+
/** The full assessment document: a file in the content library. */
|
|
182
|
+
documentAssetId: Id.nullable().optional(),
|
|
183
|
+
});
|
|
184
|
+
/** Scope, dates and document of a recorded assessment; the assessment text itself is evidence and does not change (record a new one). */
|
|
185
|
+
export const LiaPatch = z.object({
|
|
186
|
+
sequenceIds: z.array(Id).max(50).optional(), segmentIds: z.array(Id).max(50).optional(),
|
|
187
|
+
reviewAt: DateTimeIn().nullable().optional(), expiresAt: DateTimeIn().nullable().optional(), documentAssetId: Id.nullable().optional(),
|
|
188
|
+
});
|
|
189
|
+
export const LiaDto = z.object({
|
|
190
|
+
id: Id, purpose: z.string(), balancingTest: z.string(), optOutWording: z.string(), countries: z.array(z.string()),
|
|
191
|
+
assessedBy: Id.nullable(), revokedAt: Timestamp.nullable(), createdAt: Timestamp,
|
|
192
|
+
sequenceIds: z.array(Id), segmentIds: z.array(Id), reviewAt: Timestamp.nullable(), expiresAt: Timestamp.nullable(), documentAssetId: Id.nullable(),
|
|
193
|
+
});
|
|
194
|
+
export const LiaList = z.object({ items: z.array(LiaDto), blockedCountries: z.array(z.string()), unlockableCountries: z.array(z.string()) });
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Block document (editor model, P3 T3.3). Compiled to MJML by @hermetica/content `blocksToMjml`. */
|
|
3
|
+
declare const Hide: z.ZodEnum<{
|
|
4
|
+
desktop: "desktop";
|
|
5
|
+
mobile: "mobile";
|
|
6
|
+
}>;
|
|
7
|
+
/** Per-block override applied only where the client honours prefers-color-scheme: dark. */
|
|
8
|
+
declare const Dark: z.ZodObject<{
|
|
9
|
+
background: z.ZodOptional<z.ZodString>;
|
|
10
|
+
color: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type DarkOverride = z.infer<typeof Dark>;
|
|
13
|
+
/** bestsellers = "popular"; also_bought = "customers also bought" (pluggable recommender); recently_purchased = "buy it again"; most_viewed = "trending"; recommended = per-profile item-to-item picks (nightly); new_arrivals = newest products; collection = products in the store collection named by `category`. */
|
|
14
|
+
export declare const PRODUCT_MODES: readonly ['feed', 'bestsellers', 'recently_viewed', 'related', 'category', 'also_bought', 'recently_purchased', 'most_viewed', 'recommended', 'new_arrivals', 'collection'];
|
|
15
|
+
export type ProductMode = (typeof PRODUCT_MODES)[number];
|
|
16
|
+
export type Hide = z.infer<typeof Hide>;
|
|
17
|
+
type Base = {
|
|
18
|
+
id?: string;
|
|
19
|
+
hide?: Hide;
|
|
20
|
+
dark?: DarkOverride;
|
|
21
|
+
};
|
|
22
|
+
export type Block = Base & ({
|
|
23
|
+
type: 'section';
|
|
24
|
+
background?: string;
|
|
25
|
+
backgroundImage?: string;
|
|
26
|
+
children: Block[];
|
|
27
|
+
} | {
|
|
28
|
+
type: 'columns';
|
|
29
|
+
columns: Block[][];
|
|
30
|
+
} | {
|
|
31
|
+
type: 'text';
|
|
32
|
+
html: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'image';
|
|
35
|
+
src: string;
|
|
36
|
+
alt?: string;
|
|
37
|
+
href?: string;
|
|
38
|
+
width?: number;
|
|
39
|
+
params?: Record<string, string>;
|
|
40
|
+
brandItemId?: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'button';
|
|
43
|
+
label: string;
|
|
44
|
+
href: string;
|
|
45
|
+
background?: string;
|
|
46
|
+
color?: string;
|
|
47
|
+
brandItemId?: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'divider';
|
|
50
|
+
} | {
|
|
51
|
+
type: 'spacer';
|
|
52
|
+
height?: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'social';
|
|
55
|
+
items: {
|
|
56
|
+
network: string;
|
|
57
|
+
href: string;
|
|
58
|
+
}[];
|
|
59
|
+
brandItemId?: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'html';
|
|
62
|
+
html: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'product';
|
|
65
|
+
feedId: string;
|
|
66
|
+
limit?: number;
|
|
67
|
+
mode?: ProductMode;
|
|
68
|
+
category?: string;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'coupon';
|
|
71
|
+
poolId: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'conditional';
|
|
74
|
+
if: string;
|
|
75
|
+
segmentIds?: string[];
|
|
76
|
+
children: Block[];
|
|
77
|
+
} | {
|
|
78
|
+
type: 'list';
|
|
79
|
+
for: string;
|
|
80
|
+
in: string;
|
|
81
|
+
children: Block[];
|
|
82
|
+
} | {
|
|
83
|
+
type: 'menu';
|
|
84
|
+
items: {
|
|
85
|
+
label: string;
|
|
86
|
+
href: string;
|
|
87
|
+
}[];
|
|
88
|
+
align?: 'left' | 'center' | 'right';
|
|
89
|
+
} | {
|
|
90
|
+
type: 'table';
|
|
91
|
+
rows: string[][];
|
|
92
|
+
header?: boolean;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'countdown';
|
|
95
|
+
to: string;
|
|
96
|
+
label?: string;
|
|
97
|
+
expiredText?: string;
|
|
98
|
+
color?: string;
|
|
99
|
+
background?: string;
|
|
100
|
+
fontSize?: number;
|
|
101
|
+
width?: number;
|
|
102
|
+
zone?: string;
|
|
103
|
+
unitLabels?: string[];
|
|
104
|
+
} | {
|
|
105
|
+
type: 'saved';
|
|
106
|
+
sectionId: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: 'video';
|
|
109
|
+
thumbnail: string;
|
|
110
|
+
href: string;
|
|
111
|
+
alt?: string;
|
|
112
|
+
width?: number;
|
|
113
|
+
label?: string;
|
|
114
|
+
} | {
|
|
115
|
+
type: 'split';
|
|
116
|
+
image: string;
|
|
117
|
+
alt?: string;
|
|
118
|
+
imageSide?: 'left' | 'right';
|
|
119
|
+
html: string;
|
|
120
|
+
ctaLabel?: string;
|
|
121
|
+
ctaHref?: string;
|
|
122
|
+
} | {
|
|
123
|
+
type: 'review';
|
|
124
|
+
productId: string;
|
|
125
|
+
label?: string;
|
|
126
|
+
} | {
|
|
127
|
+
type: 'poll';
|
|
128
|
+
pollId: string;
|
|
129
|
+
question: string;
|
|
130
|
+
options: {
|
|
131
|
+
id: string;
|
|
132
|
+
label: string;
|
|
133
|
+
}[];
|
|
134
|
+
} | {
|
|
135
|
+
type: 'sponsor';
|
|
136
|
+
slot?: string;
|
|
137
|
+
sponsor?: string;
|
|
138
|
+
headline?: string;
|
|
139
|
+
body?: string;
|
|
140
|
+
imageUrl?: string;
|
|
141
|
+
href?: string;
|
|
142
|
+
cta?: string;
|
|
143
|
+
});
|
|
144
|
+
export declare const Block: z.ZodType<Block>;
|
|
145
|
+
/** A language variant: replaces the base blocks (and optionally subject/preheader) for recipients whose locale matches the key (`fr`, `pt-BR`). */
|
|
146
|
+
export declare const Translation: z.ZodObject<{
|
|
147
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
148
|
+
preheader: z.ZodOptional<z.ZodString>;
|
|
149
|
+
blocks: z.ZodArray<z.ZodType<Block, unknown, z.core.$ZodTypeInternals<Block, unknown>>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
export type Translation = z.infer<typeof Translation>;
|
|
152
|
+
export declare const LOCALE_RE: RegExp;
|
|
153
|
+
export declare const BlockDoc: z.ZodObject<{
|
|
154
|
+
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
155
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
156
|
+
background: z.ZodOptional<z.ZodString>;
|
|
157
|
+
blocks: z.ZodArray<z.ZodType<Block, unknown, z.core.$ZodTypeInternals<Block, unknown>>>;
|
|
158
|
+
translations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
159
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
160
|
+
preheader: z.ZodOptional<z.ZodString>;
|
|
161
|
+
blocks: z.ZodArray<z.ZodType<Block, unknown, z.core.$ZodTypeInternals<Block, unknown>>>;
|
|
162
|
+
}, z.core.$strip>>>;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
export type BlockDoc = z.infer<typeof BlockDoc>;
|
|
165
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Block document (editor model, P3 T3.3). Compiled to MJML by @hermetica/content `blocksToMjml`. */
|
|
3
|
+
const Hide = z.enum(['mobile', 'desktop']);
|
|
4
|
+
const Color = z.string().max(32).regex(/^(#[0-9a-fA-F]{3,8}|[a-zA-Z]+|transparent)$/);
|
|
5
|
+
/** Per-block override applied only where the client honours prefers-color-scheme: dark. */
|
|
6
|
+
const Dark = z.object({ background: Color.optional(), color: Color.optional() });
|
|
7
|
+
const base = { id: z.string().min(1).max(64).optional(), hide: Hide.optional(), dark: Dark.optional() };
|
|
8
|
+
/** bestsellers = "popular"; also_bought = "customers also bought" (pluggable recommender); recently_purchased = "buy it again"; most_viewed = "trending"; recommended = per-profile item-to-item picks (nightly); new_arrivals = newest products; collection = products in the store collection named by `category`. */
|
|
9
|
+
export const PRODUCT_MODES = ['feed', 'bestsellers', 'recently_viewed', 'related', 'category', 'also_bought', 'recently_purchased', 'most_viewed', 'recommended', 'new_arrivals', 'collection'];
|
|
10
|
+
const children = () => z.array(z.lazy(() => Block)).max(100);
|
|
11
|
+
export const Block = z.lazy(() => z.discriminatedUnion('type', [
|
|
12
|
+
z.object({ ...base, type: z.literal('section'), background: Color.optional(), backgroundImage: z.string().max(2048).optional(), children: children() }),
|
|
13
|
+
z.object({ ...base, type: z.literal('columns'), columns: z.array(children()).min(1).max(4) }),
|
|
14
|
+
z.object({ ...base, type: z.literal('text'), html: z.string().max(100_000) }),
|
|
15
|
+
z.object({ ...base, type: z.literal('image'), src: z.string().max(2048), alt: z.string().max(500).optional(), href: z.string().max(2048).optional(), width: z.number().int().min(1).max(1200).optional(),
|
|
16
|
+
/** Query parameters added to `src` at render; values may hold merge tags (`{{ profile.first_name }}`), URL-encoded per recipient. For personalized image services. */
|
|
17
|
+
params: z.record(z.string().regex(/^[a-zA-Z0-9_]{1,32}$/), z.string().max(200)).refine((r) => Object.keys(r).length <= 10, 'At most 10 parameters').optional(),
|
|
18
|
+
/** A brand logo item: fills src/alt/link/size wherever the block leaves them empty. */
|
|
19
|
+
brandItemId: z.uuid().optional() }),
|
|
20
|
+
// brandItemId: a brand button style (padding, border, font); the block's own colours still win.
|
|
21
|
+
z.object({ ...base, type: z.literal('button'), label: z.string().max(200), href: z.string().max(2048), background: Color.optional(), color: Color.optional(), brandItemId: z.uuid().optional() }),
|
|
22
|
+
z.object({ ...base, type: z.literal('divider') }),
|
|
23
|
+
z.object({ ...base, type: z.literal('spacer'), height: z.number().int().min(1).max(200).optional() }),
|
|
24
|
+
// brandItemId: a brand social group; its links (and custom icons) replace `items` at render.
|
|
25
|
+
z.object({ ...base, type: z.literal('social'), items: z.array(z.object({ network: z.string().max(32), href: z.string().max(2048) })).max(12), brandItemId: z.uuid().optional() }),
|
|
26
|
+
z.object({ ...base, type: z.literal('html'), html: z.string().max(200_000) }),
|
|
27
|
+
z.object({ ...base, type: z.literal('product'), feedId: z.uuid(), limit: z.number().int().min(1).max(24).optional(), mode: z.enum(PRODUCT_MODES).optional(), category: z.string().max(100).optional() }),
|
|
28
|
+
z.object({ ...base, type: z.literal('coupon'), poolId: z.uuid() }),
|
|
29
|
+
// `if` may be empty when segmentIds is set: show to members of ANY listed segment, AND the expression when both are given.
|
|
30
|
+
z.object({ ...base, type: z.literal('conditional'), if: z.string().max(500), segmentIds: z.array(z.uuid()).max(20).optional(), children: children() }),
|
|
31
|
+
// `for`: loop variable; `in`: collection path (products | event.items)
|
|
32
|
+
z.object({ ...base, type: z.literal('list'), for: z.string().regex(/^[a-z_][a-z0-9_]*$/i).max(32), in: z.string().regex(/^[a-z_][a-z0-9_.]*$/i).max(100), children: children() }),
|
|
33
|
+
z.object({ ...base, type: z.literal('menu'), items: z.array(z.object({ label: z.string().max(60), href: z.string().max(2048) })).max(8), align: z.enum(['left', 'center', 'right']).optional() }),
|
|
34
|
+
z.object({ ...base, type: z.literal('table'), rows: z.array(z.array(z.string().max(500)).min(1).max(6)).min(1).max(30), header: z.boolean().optional() }),
|
|
35
|
+
// `to`: ISO-8601 instant. Sends show a live timer image (`/t/cd/<signed>.gif`, drawn at open time with these colours, size and zone label); the text computed at render is its alt and the fallback.
|
|
36
|
+
z.object({ ...base, type: z.literal('countdown'), to: z.iso.datetime({ offset: true }), label: z.string().max(100).optional(), expiredText: z.string().max(200).optional(),
|
|
37
|
+
color: z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).optional(), background: z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).optional(),
|
|
38
|
+
fontSize: z.number().int().min(10).max(70).optional(), width: z.number().int().min(120).max(600).optional(), zone: z.string().regex(/^[A-Za-z0-9 :+/.-]{1,24}$/).optional(),
|
|
39
|
+
/** Words under the days, hours, minutes and seconds digits of the timer image (A-Z and 0-9 drawn; accents dropped; about 5 letters fit). */
|
|
40
|
+
unitLabels: z.array(z.string().max(12)).length(4).optional() }),
|
|
41
|
+
z.object({ ...base, type: z.literal('saved'), sectionId: z.uuid() }),
|
|
42
|
+
// Video thumbnail: email clients cannot play video, so a still image links out to the video page.
|
|
43
|
+
z.object({ ...base, type: z.literal('video'), thumbnail: z.string().max(2048), href: z.string().max(2048), alt: z.string().max(500).optional(), width: z.number().int().min(1).max(1200).optional(), label: z.string().max(100).optional() }),
|
|
44
|
+
// Image beside text (stacks on mobile); the call-to-action button is optional.
|
|
45
|
+
z.object({ ...base, type: z.literal('split'), image: z.string().max(2048), alt: z.string().max(500).optional(), imageSide: z.enum(['left', 'right']).optional(), html: z.string().max(100_000), ctaLabel: z.string().max(200).optional(), ctaHref: z.string().max(2048).optional() }),
|
|
46
|
+
// Star rating and review count for one catalog product, from published reviews; renders nothing until the product has a review.
|
|
47
|
+
z.object({ ...base, type: z.literal('review'), productId: z.string().regex(/^[A-Za-z0-9_.:-]{1,128}$/), label: z.string().max(100).optional() }),
|
|
48
|
+
// Poll (engagement module): each option is a signed one-vote link; the poll itself lives in `surveys`.
|
|
49
|
+
z.object({ ...base, type: z.literal('poll'), pollId: z.uuid(), question: z.string().max(500), options: z.array(z.object({ id: z.string().regex(/^[a-z0-9_-]{1,40}$/), label: z.string().max(200) })).min(2).max(20) }),
|
|
50
|
+
// Sponsor ad: `slot` is filled with a booked or network ad at send/render time (sponsorships module); the other fields hold the ad itself. Renders nothing without headline and href.
|
|
51
|
+
z.object({ ...base, type: z.literal('sponsor'), slot: z.string().regex(/^[a-z0-9_-]{1,32}$/).optional(), sponsor: z.string().max(200).optional(), headline: z.string().max(200).optional(), body: z.string().max(1000).optional(), imageUrl: z.string().max(2048).optional(), href: z.string().max(2048).optional(), cta: z.string().max(60).optional() }),
|
|
52
|
+
])).meta({ id: 'Block' }); // recursive: an `id` makes it one OpenAPI component instead of a dangling `$ref`
|
|
53
|
+
/** A language variant: replaces the base blocks (and optionally subject/preheader) for recipients whose locale matches the key (`fr`, `pt-BR`). */
|
|
54
|
+
export const Translation = z.object({ subject: z.string().max(998).optional(), preheader: z.string().max(500).optional(), blocks: z.array(Block).max(100) });
|
|
55
|
+
export const LOCALE_RE = /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})?$/;
|
|
56
|
+
export const BlockDoc = z.object({
|
|
57
|
+
version: z.literal(1).default(1),
|
|
58
|
+
width: z.number().int().min(320).max(800).default(600),
|
|
59
|
+
background: Color.optional(),
|
|
60
|
+
blocks: z.array(Block).max(100),
|
|
61
|
+
translations: z.record(z.string().regex(LOCALE_RE), Translation).optional(),
|
|
62
|
+
}).meta({ title: 'BlockDoc' });
|