@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, Id, Purpose, PageQuery, ReplyToList, Timestamp, pageResult } from './common.js';
|
|
3
|
+
import { Block, BlockDoc } from './content-blocks.js';
|
|
4
|
+
import { LintResult } from './content-library.js';
|
|
5
|
+
import { RcsContent } from './rcs.js';
|
|
6
|
+
export const TemplateKind = z.enum(['blocks', 'html', 'text', 'sms']);
|
|
7
|
+
/** Stored in template_versions.body; `kind` must match the template's kind. */
|
|
8
|
+
export const TemplateBody = z.discriminatedUnion('kind', [
|
|
9
|
+
z.object({ kind: z.literal('blocks'), doc: BlockDoc }),
|
|
10
|
+
/** `authoring` + `source`: the html was compiled from markdown or raw MJML on save; the source is kept for re-editing. */
|
|
11
|
+
z.object({ kind: z.literal('html'), html: z.string().max(512_000), authoring: z.enum(['markdown', 'mjml']).optional(), source: z.string().max(512_000).optional() }),
|
|
12
|
+
z.object({ kind: z.literal('text'), text: z.string().max(100_000) }),
|
|
13
|
+
z.object({ kind: z.literal('sms'), text: z.string().max(1600) }),
|
|
14
|
+
]);
|
|
15
|
+
export const TemplateVersionInput = z.object({
|
|
16
|
+
body: TemplateBody,
|
|
17
|
+
subject: z.string().max(998).nullable().default(null),
|
|
18
|
+
preheader: z.string().max(500).nullable().default(null),
|
|
19
|
+
fromNameOverride: z.string().max(200).nullable().default(null),
|
|
20
|
+
textBody: z.string().max(100_000).nullable().default(null),
|
|
21
|
+
/** Sender defaults carried by the template; a campaign or journey step that sets its own wins. */
|
|
22
|
+
fromEmail: z.email().max(320).nullable().optional(),
|
|
23
|
+
replyTo: ReplyToList.nullable().optional(),
|
|
24
|
+
/** Copy addresses. Honoured on transactional sends only: a copy shares the recipient's personal content and never consented. */
|
|
25
|
+
cc: z.array(z.email().max(320)).max(10).optional(),
|
|
26
|
+
/** Email only: an AMP for Email document sent as a text/x-amp-html part next to the HTML (which stays the fallback). Checked at save. */
|
|
27
|
+
ampHtml: z.string().max(200_000).nullable().optional(),
|
|
28
|
+
/** SMS only: an RCS card and suggestion chips; the text body is the SMS fallback. */
|
|
29
|
+
rcs: RcsContent.nullable().optional(),
|
|
30
|
+
});
|
|
31
|
+
export const TemplateVersionDto = z.object({
|
|
32
|
+
id: Id, templateId: Id, workspaceId: Id, body: TemplateBody,
|
|
33
|
+
subject: z.string().nullable(), preheader: z.string().nullable(), fromNameOverride: z.string().nullable(), textBody: z.string().nullable(),
|
|
34
|
+
approvalStatus: z.enum(['none', 'pending', 'approved', 'rejected']), reviewComment: z.string().nullable(),
|
|
35
|
+
createdBy: z.string().nullable(), createdAt: Timestamp, approvedBy: z.string().nullable(), approvedAt: Timestamp.nullable(),
|
|
36
|
+
fromEmail: z.string().nullable().default(null), replyTo: z.string().nullable().default(null), cc: z.array(z.string()).default([]),
|
|
37
|
+
ampHtml: z.string().nullable().default(null), rcs: RcsContent.nullable().default(null),
|
|
38
|
+
/** Set when a reviewer confirmed this version is transactional despite offer wording (POST .../transactional-review). */
|
|
39
|
+
transactionalReviewedBy: z.string().nullable().default(null), transactionalReviewedAt: Timestamp.nullable().default(null),
|
|
40
|
+
});
|
|
41
|
+
export const TemplateDto = z.object({
|
|
42
|
+
id: Id, workspaceId: Id, channel: Channel, name: z.string(), kind: TemplateKind, folder: z.string().nullable(), tags: z.array(z.string()),
|
|
43
|
+
currentVersionId: Id.nullable(), archived: z.boolean(), folderId: Id.nullable(), brandKitId: Id.nullable(), isDefault: z.boolean().default(false), topicId: Id.nullable().default(null), createdBy: z.string().nullable().default(null), app: z.string().nullable().default(null), createdAt: Timestamp, updatedAt: Timestamp,
|
|
44
|
+
});
|
|
45
|
+
export const TemplateWithVersion = TemplateDto.extend({ currentVersion: TemplateVersionDto.nullable() });
|
|
46
|
+
export const CreateTemplateBody = z.object({
|
|
47
|
+
name: z.string().trim().min(1).max(200),
|
|
48
|
+
kind: TemplateKind,
|
|
49
|
+
/** Only with kind `sms`: `push` makes a push template (version subject = title, text = body). */
|
|
50
|
+
channel: z.literal('push').optional(),
|
|
51
|
+
/** A top-level folder by name, created when missing (the same folder record `folderId` names). */
|
|
52
|
+
folder: z.string().trim().max(200).nullable().optional(),
|
|
53
|
+
folderId: Id.nullable().optional(),
|
|
54
|
+
tags: z.array(z.string().max(64)).max(50).default([]),
|
|
55
|
+
/** Preference topic for this template's marketing sends that name no topic (as on PATCH). */
|
|
56
|
+
topicId: Id.nullable().optional(),
|
|
57
|
+
app: AppSlug.nullish().describe('Product (app slug) that owns the template; an app-bound API key stamps its own and only sees its own'),
|
|
58
|
+
version: TemplateVersionInput.optional(),
|
|
59
|
+
});
|
|
60
|
+
export const UpdateTemplateBody = z.object({
|
|
61
|
+
name: z.string().trim().min(1).max(200).optional(),
|
|
62
|
+
/** Moves to the top-level folder of that name, created when missing; null takes it out of any folder. `folderId` wins when both are sent. */
|
|
63
|
+
folder: z.string().trim().max(200).nullable().optional(),
|
|
64
|
+
tags: z.array(z.string().max(64)).max(50).optional(),
|
|
65
|
+
archived: z.boolean().optional(),
|
|
66
|
+
folderId: Id.nullable().optional(),
|
|
67
|
+
brandKitId: Id.nullable().optional(),
|
|
68
|
+
/** Preference topic for this template's marketing sends that name no topic; null clears it. People who opted out of the topic are not messaged. */
|
|
69
|
+
topicId: Id.nullable().optional(),
|
|
70
|
+
/** The pre-selected template for new campaigns on this channel; setting it clears the previous default. */
|
|
71
|
+
isDefault: z.boolean().optional(),
|
|
72
|
+
app: AppSlug.nullable().optional().describe('Move to another product (app slug), or null to share; app-bound keys cannot'),
|
|
73
|
+
});
|
|
74
|
+
export const ListTemplatesQuery = PageQuery.extend({
|
|
75
|
+
channel: Channel.optional(), folder: z.string().optional(), folderId: Id.optional(), tag: z.string().max(64).optional(), q: z.string().max(200).optional(),
|
|
76
|
+
archived: z.enum(['true', 'false']).transform((v) => v === 'true').optional(),
|
|
77
|
+
/** Actor id of the creator (a user id, or `me` for the caller). */
|
|
78
|
+
createdBy: z.string().max(128).optional(),
|
|
79
|
+
kind: TemplateKind.optional(), app: AppSlug.optional(),
|
|
80
|
+
createdAfter: Timestamp.optional(), createdBefore: Timestamp.optional(),
|
|
81
|
+
sort: z.enum(['newest', 'oldest', 'name', 'name_desc', 'updated']).default('newest'),
|
|
82
|
+
});
|
|
83
|
+
export const TemplatePage = pageResult(TemplateDto);
|
|
84
|
+
/** Apply one change to many templates. Tags: `tags` replaces, `addTags` / `removeTags` edit. */
|
|
85
|
+
export const BulkUpdateTemplatesBody = z.object({
|
|
86
|
+
ids: z.array(Id).min(1).max(100),
|
|
87
|
+
patch: z.object({
|
|
88
|
+
folderId: Id.nullable(), archived: z.boolean(), brandKitId: Id.nullable(), topicId: Id.nullable(),
|
|
89
|
+
tags: z.array(z.string().max(64)).max(50), addTags: z.array(z.string().max(64)).max(50), removeTags: z.array(z.string().max(64)).max(50),
|
|
90
|
+
}).partial().refine((p) => Object.keys(p).length > 0, 'Nothing to change'),
|
|
91
|
+
});
|
|
92
|
+
export const BulkUpdateTemplatesResult = z.object({ updated: z.number().int(), failed: z.array(z.object({ id: Id, reason: z.string() })) });
|
|
93
|
+
export const TemplateVersionPage = pageResult(TemplateVersionDto);
|
|
94
|
+
export const PreviewBody = z.object({
|
|
95
|
+
versionId: Id.optional(),
|
|
96
|
+
brandKitId: Id.optional(),
|
|
97
|
+
strict: z.boolean().default(false),
|
|
98
|
+
/** Shallow-merged over the sample profile / vars. */
|
|
99
|
+
profile: z.record(z.string(), z.unknown()).optional(),
|
|
100
|
+
vars: z.record(z.string(), z.unknown()).optional(),
|
|
101
|
+
/** Render against this real profile instead of the sample one. */
|
|
102
|
+
profileId: Id.optional(),
|
|
103
|
+
/** Preview as a member of these segments (segment-aware conditional blocks). */
|
|
104
|
+
segmentIds: z.array(Id).max(20).optional(),
|
|
105
|
+
darkMode: z.boolean().default(false),
|
|
106
|
+
/** When set, the result carries lint findings for this send purpose. */
|
|
107
|
+
purpose: Purpose.optional(),
|
|
108
|
+
});
|
|
109
|
+
export const QaIssue = z.object({ code: z.string(), message: z.string() });
|
|
110
|
+
export const QaReport = z.object({
|
|
111
|
+
clipping: z.object({ bytes: z.number(), limit: z.number(), percent: z.number(), clipped: z.boolean() }),
|
|
112
|
+
accessibility: z.array(QaIssue),
|
|
113
|
+
spam: z.object({ score: z.number(), hits: z.array(QaIssue.extend({ points: z.number() })) }),
|
|
114
|
+
/** Inline-CSS audit: styles that mail clients drop or ignore. */
|
|
115
|
+
css: z.array(QaIssue).default([]),
|
|
116
|
+
});
|
|
117
|
+
export const PreviewResult = z.object({
|
|
118
|
+
channel: Channel,
|
|
119
|
+
subject: z.string().nullable(), preheader: z.string().nullable(), html: z.string().nullable(), text: z.string(),
|
|
120
|
+
links: z.array(z.object({ url: z.string(), position: z.number() })),
|
|
121
|
+
warnings: z.array(z.string()),
|
|
122
|
+
sms: z.object({ segments: z.number(), encoding: z.enum(['GSM-7', 'UCS-2']) }).nullable(),
|
|
123
|
+
lint: LintResult.nullable(),
|
|
124
|
+
/** Email only: clipping meter, accessibility findings and spam score. */
|
|
125
|
+
qa: QaReport.nullable().optional(),
|
|
126
|
+
});
|
|
127
|
+
export const SnippetKey = z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/);
|
|
128
|
+
export const SnippetDto = z.object({ id: Id, workspaceId: Id, key: SnippetKey, channel: Channel, body: z.string(), locked: z.boolean(), createdAt: Timestamp, updatedAt: Timestamp });
|
|
129
|
+
export const CreateSnippetBody = z.object({ key: SnippetKey, channel: Channel, body: z.string().max(50_000) });
|
|
130
|
+
export const UpdateSnippetBody = z.object({ body: z.string().max(50_000) });
|
|
131
|
+
export const SnippetBulkDeleteBody = z.object({ ids: z.array(Id).min(1).max(100) });
|
|
132
|
+
export const SnippetBulkDeleteResult = z.object({ deleted: z.number().int(), skippedLocked: z.number().int() });
|
|
133
|
+
export const SnippetPage = pageResult(SnippetDto);
|
|
134
|
+
export const BrandColors = z.object({ primary: z.string().max(32), text: z.string().max(32), background: z.string().max(32), accent: z.string().max(32).optional() }).partial();
|
|
135
|
+
export const BrandFonts = z.object({ heading: z.string().max(100), body: z.string().max(100) }).partial();
|
|
136
|
+
export const BrandKitInput = z.object({
|
|
137
|
+
name: z.string().trim().min(1).max(200),
|
|
138
|
+
logoAssetId: Id.nullable().default(null),
|
|
139
|
+
logoUrl: z.string().max(2048).nullable().default(null),
|
|
140
|
+
colors: BrandColors.default({}),
|
|
141
|
+
fonts: BrandFonts.default({}),
|
|
142
|
+
footerHtml: z.string().max(20_000).nullable().default(null),
|
|
143
|
+
postalAddress: z.string().max(500).nullable().default(null),
|
|
144
|
+
customCss: z.string().max(50_000).nullable().default(null),
|
|
145
|
+
/** HTML wrapper for HTML templates; must contain {{ content }}, where the template body goes. */
|
|
146
|
+
layoutHtml: z.string().max(50_000).nullable().default(null),
|
|
147
|
+
/** The workspace default kit applies automatically to every block-editor render that names none. */
|
|
148
|
+
isDefault: z.boolean().default(false),
|
|
149
|
+
});
|
|
150
|
+
// Not `BrandKitInput.partial()`: zod re-applies defaults to missing keys, which would reset fields on PATCH.
|
|
151
|
+
export const UpdateBrandKitBody = z.object({
|
|
152
|
+
name: z.string().trim().min(1).max(200), logoAssetId: Id.nullable(), logoUrl: z.string().max(2048).nullable(),
|
|
153
|
+
colors: BrandColors, fonts: BrandFonts, footerHtml: z.string().max(20_000).nullable(), postalAddress: z.string().max(500).nullable(), customCss: z.string().max(50_000).nullable(), layoutHtml: z.string().max(50_000).nullable(), isDefault: z.boolean(),
|
|
154
|
+
}).partial();
|
|
155
|
+
export const BrandKitDto = BrandKitInput.extend({ id: Id, workspaceId: Id, createdAt: Timestamp, updatedAt: Timestamp });
|
|
156
|
+
export const BrandKitPage = pageResult(BrandKitDto);
|
|
157
|
+
/** AI translation of a language variant (opt-in AI assist; brand voice applies). Liquid tags are never altered. */
|
|
158
|
+
export const TranslateVariantBody = z.object({
|
|
159
|
+
blocks: z.array(Block).max(100), subject: z.string().max(998).optional(), preheader: z.string().max(500).optional(),
|
|
160
|
+
targetLanguage: z.string().min(2).max(50),
|
|
161
|
+
});
|
|
162
|
+
export const TranslateVariantResult = z.object({
|
|
163
|
+
blocks: z.array(Block), subject: z.string().optional(), preheader: z.string().optional(), model: z.string(), draft: z.literal(true),
|
|
164
|
+
});
|
|
165
|
+
/** Real-client rendering previews (Litmus / Email on Acid style) through a per-workspace connection. */
|
|
166
|
+
export const QaPreviewConnectionBody = z.object({ vendor: z.string().min(1).max(32), name: z.string().trim().min(1).max(100), apiKey: z.string().min(1).max(500).optional(),
|
|
167
|
+
/** Second credential for vendors that need one (Email on Acid: the account password). */
|
|
168
|
+
apiSecret: z.string().min(1).max(500).optional() });
|
|
169
|
+
export const QaPreviewConnectionDto = z.object({
|
|
170
|
+
configured: z.boolean(), vendor: z.string().nullable(), name: z.string().nullable(),
|
|
171
|
+
/** Vendors this server has an adapter for. */
|
|
172
|
+
vendors: z.array(z.string()),
|
|
173
|
+
});
|
|
174
|
+
export const ClientPreviewStartBody = z.object({ versionId: Id.optional(), clients: z.array(z.string().min(1).max(100)).max(100).optional() });
|
|
175
|
+
export const PreviewClientDto = z.object({ id: z.string(), name: z.string(), platform: z.enum(['web', 'desktop', 'mobile']), defaultSelected: z.boolean() });
|
|
176
|
+
export const PreviewClientsDto = z.object({ clients: z.array(PreviewClientDto), credits: z.object({ remaining: z.number(), resetsAt: z.string().nullable() }).nullable() });
|
|
177
|
+
export const ClientPreviewRunDto = z.object({
|
|
178
|
+
id: Id, templateId: Id, versionId: Id.nullable(), vendor: z.string(), externalId: z.string(), clients: z.array(z.string()), status: z.enum(['pending', 'done', 'failed']),
|
|
179
|
+
shots: z.array(z.object({ client: z.string(), url: z.string() })), error: z.string().nullable(), createdBy: z.string().nullable(), createdAt: Timestamp,
|
|
180
|
+
});
|
|
181
|
+
export const ClientPreviewRunList = z.object({ items: z.array(ClientPreviewRunDto) });
|
|
182
|
+
export const ClientPreviewStart = z.object({ externalId: z.string() });
|
|
183
|
+
export const ClientPreviewResult = z.object({
|
|
184
|
+
status: z.enum(['pending', 'done', 'failed']), error: z.string().optional(),
|
|
185
|
+
shots: z.array(z.object({ client: z.string(), url: z.string() })),
|
|
186
|
+
});
|
|
187
|
+
/** The fill-in parts of a template's current version: block design blocks or marked HTML regions. */
|
|
188
|
+
export const TemplateDefaultContent = z.object({
|
|
189
|
+
versionId: Id.nullable(), subject: z.string().nullable(),
|
|
190
|
+
regions: z.array(z.object({ key: z.string(), kind: z.string(), content: z.string() })),
|
|
191
|
+
});
|
|
192
|
+
/** A finished block-to-HTML conversion (the conversion is synchronous, so a job is always complete). */
|
|
193
|
+
export const TemplateConversionJob = z.object({ id: Id, status: z.literal('complete'), sourceTemplateId: Id, resultTemplateId: Id.nullable(), createdAt: Timestamp });
|
|
194
|
+
export const TemplateConversionJobPage = pageResult(TemplateConversionJob);
|