@denarolabs/email-template 1.0.5 → 1.0.6

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.
Files changed (52) hide show
  1. package/dist/index.d.ts +425 -8
  2. package/dist/index.js +9841 -7
  3. package/package.json +16 -23
  4. package/dist/components/ai-email-editor/AIEmailEditor.d.ts +0 -3
  5. package/dist/components/ai-email-editor/AIEmailEditor.js +0 -207
  6. package/dist/components/ai-email-editor/chat-message.d.ts +0 -36
  7. package/dist/components/ai-email-editor/chat-message.js +0 -49
  8. package/dist/components/ai-email-editor/images.d.ts +0 -2
  9. package/dist/components/ai-email-editor/images.js +0 -14
  10. package/dist/components/ai-email-editor/model-picker.d.ts +0 -7
  11. package/dist/components/ai-email-editor/model-picker.js +0 -9
  12. package/dist/components/ai-email-editor/preview.d.ts +0 -35
  13. package/dist/components/ai-email-editor/preview.js +0 -728
  14. package/dist/components/ai-email-editor/send-test-email-modal.d.ts +0 -13
  15. package/dist/components/ai-email-editor/send-test-email-modal.js +0 -70
  16. package/dist/components/ai-email-editor/stream.d.ts +0 -20
  17. package/dist/components/ai-email-editor/stream.js +0 -57
  18. package/dist/components/ai-email-editor/use-ai-email-editor.d.ts +0 -117
  19. package/dist/components/ai-email-editor/use-ai-email-editor.js +0 -1308
  20. package/dist/components/ai-email-editor/view-html-modal.d.ts +0 -9
  21. package/dist/components/ai-email-editor/view-html-modal.js +0 -37
  22. package/dist/lib/ai-stream-contract.d.ts +0 -99
  23. package/dist/lib/ai-stream-contract.js +0 -35
  24. package/dist/lib/build-default-system-prompt.d.ts +0 -2
  25. package/dist/lib/build-default-system-prompt.js +0 -37
  26. package/dist/lib/capture-email-preview.d.ts +0 -5
  27. package/dist/lib/capture-email-preview.js +0 -73
  28. package/dist/lib/cn.d.ts +0 -2
  29. package/dist/lib/cn.js +0 -5
  30. package/dist/lib/merge-tag-validation.d.ts +0 -3
  31. package/dist/lib/merge-tag-validation.js +0 -45
  32. package/dist/lib/rasterize-image-client.d.ts +0 -4
  33. package/dist/lib/rasterize-image-client.js +0 -47
  34. package/dist/lib/strip-html-code-fences.d.ts +0 -1
  35. package/dist/lib/strip-html-code-fences.js +0 -6
  36. package/dist/schemas/aiEmail.d.ts +0 -224
  37. package/dist/schemas/aiEmail.js +0 -29
  38. package/dist/schemas/aiEmailResponse.d.ts +0 -15
  39. package/dist/schemas/aiEmailResponse.js +0 -15
  40. package/dist/types.d.ts +0 -57
  41. package/dist/types.js +0 -1
  42. package/dist/ui/button.d.ts +0 -11
  43. package/dist/ui/button.js +0 -34
  44. package/dist/ui/dialog.d.ts +0 -33
  45. package/dist/ui/dialog.js +0 -39
  46. package/dist/ui/dropdown-menu.d.ts +0 -8
  47. package/dist/ui/dropdown-menu.js +0 -23
  48. package/dist/ui/input.d.ts +0 -2
  49. package/dist/ui/input.js +0 -6
  50. package/dist/ui/textarea.d.ts +0 -2
  51. package/dist/ui/textarea.js +0 -7
  52. package/src/styles.css +0 -197
package/dist/index.d.ts CHANGED
@@ -1,8 +1,425 @@
1
- export { AIEmailEditor, default } from "./components/ai-email-editor/AIEmailEditor";
2
- export type { AIEmailEditorProps, AIEmailModelOption, StoredEmailRecord, AIEmailEditorMode, AIEmailEditorErrorSource, AIEmailEditorErrorContext, AIEmailEditorSuccessSource, AIEmailEditorSuccessContext, SendTestEmailInput, } from "./types";
3
- export { AiEmailResponseSchema, type AiEmailResponse, } from "./schemas/aiEmailResponse";
4
- export { AiEmailChatMessageSchema, AiEmailHtmlSnapshotSchema, AiEmailImageSchema, AiEmailSessionSchema, type AiEmailChatMessage, type AiEmailHtmlSnapshot, type AiEmailImage, type AiEmailSession, } from "./schemas/aiEmail";
5
- export { buildAiEmailStreamRequestSchema, buildResponseFormatDirective, } from "./lib/ai-stream-contract";
6
- export { getMergeTagError, extractMergeTags, applyMergeTags } from "./lib/merge-tag-validation";
7
- export { buildDefaultSystemPrompt } from "./lib/build-default-system-prompt";
8
- export { DEFAULT_EDIT_SUGGESTIONS, DEFAULT_NEW_TEMPLATE_SUGGESTIONS, resolveInitialSuggestions, detectPhase, extractStreamParts, formatPlan, parseStructuredStream, phaseLabel, } from "./components/ai-email-editor/stream";
1
+ import * as react from 'react';
2
+ import { z } from 'zod';
3
+ import { DeepPartial } from 'ai';
4
+
5
+ declare const AiEmailImageSchema: z.ZodObject<{
6
+ id: z.ZodString;
7
+ url: z.ZodString;
8
+ name: z.ZodOptional<z.ZodString>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ id: string;
11
+ url: string;
12
+ name?: string | undefined;
13
+ }, {
14
+ id: string;
15
+ url: string;
16
+ name?: string | undefined;
17
+ }>;
18
+ declare const AiEmailChatMessageSchema: z.ZodObject<{
19
+ id: z.ZodString;
20
+ role: z.ZodEnum<["user", "assistant"]>;
21
+ content: z.ZodString;
22
+ contextImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
23
+ id: z.ZodString;
24
+ url: z.ZodString;
25
+ name: z.ZodOptional<z.ZodString>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ id: string;
28
+ url: string;
29
+ name?: string | undefined;
30
+ }, {
31
+ id: string;
32
+ url: string;
33
+ name?: string | undefined;
34
+ }>, "many">>;
35
+ appliedHtml: z.ZodOptional<z.ZodBoolean>;
36
+ snapshotId: z.ZodOptional<z.ZodString>;
37
+ selectedBlockIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
+ phase: z.ZodOptional<z.ZodEnum<["thinking", "planning", "applying"]>>;
39
+ timestamp: z.ZodNumber;
40
+ }, "strip", z.ZodTypeAny, {
41
+ id: string;
42
+ role: "user" | "assistant";
43
+ content: string;
44
+ timestamp: number;
45
+ contextImages?: {
46
+ id: string;
47
+ url: string;
48
+ name?: string | undefined;
49
+ }[] | undefined;
50
+ appliedHtml?: boolean | undefined;
51
+ snapshotId?: string | undefined;
52
+ selectedBlockIds?: string[] | undefined;
53
+ phase?: "thinking" | "planning" | "applying" | undefined;
54
+ }, {
55
+ id: string;
56
+ role: "user" | "assistant";
57
+ content: string;
58
+ timestamp: number;
59
+ contextImages?: {
60
+ id: string;
61
+ url: string;
62
+ name?: string | undefined;
63
+ }[] | undefined;
64
+ appliedHtml?: boolean | undefined;
65
+ snapshotId?: string | undefined;
66
+ selectedBlockIds?: string[] | undefined;
67
+ phase?: "thinking" | "planning" | "applying" | undefined;
68
+ }>;
69
+ declare const AiEmailHtmlSnapshotSchema: z.ZodObject<{
70
+ id: z.ZodString;
71
+ html: z.ZodString;
72
+ label: z.ZodOptional<z.ZodString>;
73
+ timestamp: z.ZodNumber;
74
+ }, "strip", z.ZodTypeAny, {
75
+ html: string;
76
+ id: string;
77
+ timestamp: number;
78
+ label?: string | undefined;
79
+ }, {
80
+ html: string;
81
+ id: string;
82
+ timestamp: number;
83
+ label?: string | undefined;
84
+ }>;
85
+ declare const AiEmailSessionSchema: z.ZodObject<{
86
+ messages: z.ZodDefault<z.ZodArray<z.ZodObject<{
87
+ id: z.ZodString;
88
+ role: z.ZodEnum<["user", "assistant"]>;
89
+ content: z.ZodString;
90
+ contextImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
91
+ id: z.ZodString;
92
+ url: z.ZodString;
93
+ name: z.ZodOptional<z.ZodString>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ id: string;
96
+ url: string;
97
+ name?: string | undefined;
98
+ }, {
99
+ id: string;
100
+ url: string;
101
+ name?: string | undefined;
102
+ }>, "many">>;
103
+ appliedHtml: z.ZodOptional<z.ZodBoolean>;
104
+ snapshotId: z.ZodOptional<z.ZodString>;
105
+ selectedBlockIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
106
+ phase: z.ZodOptional<z.ZodEnum<["thinking", "planning", "applying"]>>;
107
+ timestamp: z.ZodNumber;
108
+ }, "strip", z.ZodTypeAny, {
109
+ id: string;
110
+ role: "user" | "assistant";
111
+ content: string;
112
+ timestamp: number;
113
+ contextImages?: {
114
+ id: string;
115
+ url: string;
116
+ name?: string | undefined;
117
+ }[] | undefined;
118
+ appliedHtml?: boolean | undefined;
119
+ snapshotId?: string | undefined;
120
+ selectedBlockIds?: string[] | undefined;
121
+ phase?: "thinking" | "planning" | "applying" | undefined;
122
+ }, {
123
+ id: string;
124
+ role: "user" | "assistant";
125
+ content: string;
126
+ timestamp: number;
127
+ contextImages?: {
128
+ id: string;
129
+ url: string;
130
+ name?: string | undefined;
131
+ }[] | undefined;
132
+ appliedHtml?: boolean | undefined;
133
+ snapshotId?: string | undefined;
134
+ selectedBlockIds?: string[] | undefined;
135
+ phase?: "thinking" | "planning" | "applying" | undefined;
136
+ }>, "many">>;
137
+ snapshots: z.ZodDefault<z.ZodArray<z.ZodObject<{
138
+ id: z.ZodString;
139
+ html: z.ZodString;
140
+ label: z.ZodOptional<z.ZodString>;
141
+ timestamp: z.ZodNumber;
142
+ }, "strip", z.ZodTypeAny, {
143
+ html: string;
144
+ id: string;
145
+ timestamp: number;
146
+ label?: string | undefined;
147
+ }, {
148
+ html: string;
149
+ id: string;
150
+ timestamp: number;
151
+ label?: string | undefined;
152
+ }>, "many">>;
153
+ snapshotIndex: z.ZodDefault<z.ZodNumber>;
154
+ contextImages: z.ZodDefault<z.ZodArray<z.ZodObject<{
155
+ id: z.ZodString;
156
+ url: z.ZodString;
157
+ name: z.ZodOptional<z.ZodString>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ id: string;
160
+ url: string;
161
+ name?: string | undefined;
162
+ }, {
163
+ id: string;
164
+ url: string;
165
+ name?: string | undefined;
166
+ }>, "many">>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ contextImages: {
169
+ id: string;
170
+ url: string;
171
+ name?: string | undefined;
172
+ }[];
173
+ messages: {
174
+ id: string;
175
+ role: "user" | "assistant";
176
+ content: string;
177
+ timestamp: number;
178
+ contextImages?: {
179
+ id: string;
180
+ url: string;
181
+ name?: string | undefined;
182
+ }[] | undefined;
183
+ appliedHtml?: boolean | undefined;
184
+ snapshotId?: string | undefined;
185
+ selectedBlockIds?: string[] | undefined;
186
+ phase?: "thinking" | "planning" | "applying" | undefined;
187
+ }[];
188
+ snapshots: {
189
+ html: string;
190
+ id: string;
191
+ timestamp: number;
192
+ label?: string | undefined;
193
+ }[];
194
+ snapshotIndex: number;
195
+ }, {
196
+ contextImages?: {
197
+ id: string;
198
+ url: string;
199
+ name?: string | undefined;
200
+ }[] | undefined;
201
+ messages?: {
202
+ id: string;
203
+ role: "user" | "assistant";
204
+ content: string;
205
+ timestamp: number;
206
+ contextImages?: {
207
+ id: string;
208
+ url: string;
209
+ name?: string | undefined;
210
+ }[] | undefined;
211
+ appliedHtml?: boolean | undefined;
212
+ snapshotId?: string | undefined;
213
+ selectedBlockIds?: string[] | undefined;
214
+ phase?: "thinking" | "planning" | "applying" | undefined;
215
+ }[] | undefined;
216
+ snapshots?: {
217
+ html: string;
218
+ id: string;
219
+ timestamp: number;
220
+ label?: string | undefined;
221
+ }[] | undefined;
222
+ snapshotIndex?: number | undefined;
223
+ }>;
224
+ type AiEmailImage = z.infer<typeof AiEmailImageSchema>;
225
+ type AiEmailChatMessage = z.infer<typeof AiEmailChatMessageSchema>;
226
+ type AiEmailHtmlSnapshot = z.infer<typeof AiEmailHtmlSnapshotSchema>;
227
+ type AiEmailSession = z.infer<typeof AiEmailSessionSchema>;
228
+
229
+ type AIEmailEditorMode = "email" | "landing";
230
+ type AIEmailEditorErrorSource = "stream" | "upload" | "save" | "image" | "html" | "send";
231
+ interface AIEmailEditorErrorContext {
232
+ source: AIEmailEditorErrorSource;
233
+ }
234
+ type AIEmailEditorSuccessSource = "upload" | "save" | "image" | "html" | "undo" | "revert" | "send";
235
+ interface AIEmailEditorSuccessContext {
236
+ source: AIEmailEditorSuccessSource;
237
+ message: string;
238
+ }
239
+ interface SendTestEmailInput {
240
+ to: string;
241
+ subject: string;
242
+ html: string;
243
+ mergeTagValues: Record<string, string>;
244
+ }
245
+ interface AIEmailModelOption {
246
+ id: string;
247
+ label: string;
248
+ hint?: string;
249
+ }
250
+ interface StoredEmailRecord {
251
+ id: string;
252
+ name: string;
253
+ html: string;
254
+ createdAt: number;
255
+ updatedAt: number;
256
+ aiSession?: AiEmailSession;
257
+ }
258
+ interface AIEmailEditorProps {
259
+ name: string;
260
+ savedTemplate: StoredEmailRecord | null;
261
+ onSave: (record: StoredEmailRecord) => Promise<void> | void;
262
+ streamRoute: string;
263
+ mergeTags: string[];
264
+ defaultMergeTagValues?: Record<string, string>;
265
+ mode?: AIEmailEditorMode;
266
+ systemPrompt?: string;
267
+ onUploadImage: (file: File | Blob) => Promise<{
268
+ url: string;
269
+ }>;
270
+ onDeleteImage: (url: string) => Promise<void>;
271
+ onSendTestEmail?: (input: SendTestEmailInput) => Promise<void>;
272
+ defaultTestEmailRecipient?: string;
273
+ defaultTestEmailSubject?: string;
274
+ onError: (error: Error, context: AIEmailEditorErrorContext) => void;
275
+ onSuccess?: (context: AIEmailEditorSuccessContext) => void;
276
+ open?: boolean;
277
+ onOpenChange?: (open: boolean) => void;
278
+ brandLabel?: string;
279
+ brandIconUrl?: string;
280
+ productLabel?: string;
281
+ models?: readonly AIEmailModelOption[];
282
+ defaultModel?: string;
283
+ initialSuggestions?: readonly string[];
284
+ }
285
+
286
+ declare function AIEmailEditor({ name, savedTemplate, onSave, streamRoute, mergeTags, defaultMergeTagValues, mode, systemPrompt, onUploadImage, onDeleteImage, onSendTestEmail, defaultTestEmailRecipient, defaultTestEmailSubject, onError, onSuccess, open, onOpenChange, brandLabel, brandIconUrl, productLabel, models, defaultModel, initialSuggestions, }: AIEmailEditorProps): react.JSX.Element | null;
287
+
288
+ declare const AiEmailResponseSchema: z.ZodObject<{
289
+ plan: z.ZodArray<z.ZodString, "many">;
290
+ suggestions: z.ZodArray<z.ZodString, "many">;
291
+ html: z.ZodString;
292
+ }, "strip", z.ZodTypeAny, {
293
+ html: string;
294
+ plan: string[];
295
+ suggestions: string[];
296
+ }, {
297
+ html: string;
298
+ plan: string[];
299
+ suggestions: string[];
300
+ }>;
301
+ type AiEmailResponse = z.infer<typeof AiEmailResponseSchema>;
302
+
303
+ declare function buildAiEmailStreamRequestSchema(): z.ZodObject<{
304
+ messages: z.ZodArray<z.ZodObject<{
305
+ role: z.ZodEnum<["user", "assistant"]>;
306
+ content: z.ZodString;
307
+ contextImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
308
+ url: z.ZodString;
309
+ label: z.ZodString;
310
+ }, "strip", z.ZodTypeAny, {
311
+ label: string;
312
+ url: string;
313
+ }, {
314
+ label: string;
315
+ url: string;
316
+ }>, "many">>;
317
+ }, "strip", z.ZodTypeAny, {
318
+ role: "user" | "assistant";
319
+ content: string;
320
+ contextImages?: {
321
+ label: string;
322
+ url: string;
323
+ }[] | undefined;
324
+ }, {
325
+ role: "user" | "assistant";
326
+ content: string;
327
+ contextImages?: {
328
+ label: string;
329
+ url: string;
330
+ }[] | undefined;
331
+ }>, "many">;
332
+ systemPrompt: z.ZodString;
333
+ model: z.ZodString;
334
+ sessionContextImages: z.ZodDefault<z.ZodArray<z.ZodObject<{
335
+ url: z.ZodString;
336
+ label: z.ZodString;
337
+ }, "strip", z.ZodTypeAny, {
338
+ label: string;
339
+ url: string;
340
+ }, {
341
+ label: string;
342
+ url: string;
343
+ }>, "many">>;
344
+ previewScreenshot: z.ZodOptional<z.ZodString>;
345
+ currentHtml: z.ZodOptional<z.ZodString>;
346
+ selectedBlocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
347
+ id: z.ZodString;
348
+ html: z.ZodString;
349
+ }, "strip", z.ZodTypeAny, {
350
+ html: string;
351
+ id: string;
352
+ }, {
353
+ html: string;
354
+ id: string;
355
+ }>, "many">>;
356
+ }, "strip", z.ZodTypeAny, {
357
+ messages: {
358
+ role: "user" | "assistant";
359
+ content: string;
360
+ contextImages?: {
361
+ label: string;
362
+ url: string;
363
+ }[] | undefined;
364
+ }[];
365
+ systemPrompt: string;
366
+ sessionContextImages: {
367
+ label: string;
368
+ url: string;
369
+ }[];
370
+ model: string;
371
+ previewScreenshot?: string | undefined;
372
+ currentHtml?: string | undefined;
373
+ selectedBlocks?: {
374
+ html: string;
375
+ id: string;
376
+ }[] | undefined;
377
+ }, {
378
+ messages: {
379
+ role: "user" | "assistant";
380
+ content: string;
381
+ contextImages?: {
382
+ label: string;
383
+ url: string;
384
+ }[] | undefined;
385
+ }[];
386
+ systemPrompt: string;
387
+ model: string;
388
+ sessionContextImages?: {
389
+ label: string;
390
+ url: string;
391
+ }[] | undefined;
392
+ previewScreenshot?: string | undefined;
393
+ currentHtml?: string | undefined;
394
+ selectedBlocks?: {
395
+ html: string;
396
+ id: string;
397
+ }[] | undefined;
398
+ }>;
399
+ declare function buildResponseFormatDirective(): string;
400
+
401
+ declare function extractMergeTags(content: string): string[];
402
+ declare function applyMergeTags(html: string, values: Record<string, string>): string;
403
+ declare function getMergeTagError(content: string, allowedTags: Iterable<string>): string | null;
404
+
405
+ declare function buildDefaultSystemPrompt(mergeTags: string[], mode?: AIEmailEditorMode): string;
406
+
407
+ type PartialAiEmailResponse = DeepPartial<AiEmailResponse>;
408
+ declare function phaseLabel(phase: "thinking" | "planning" | "applying"): string;
409
+ declare function formatPlan(plan: (string | undefined)[] | undefined): string;
410
+ declare function extractStreamParts(partial: PartialAiEmailResponse | undefined): {
411
+ narration: string;
412
+ suggestions: string[];
413
+ html: string;
414
+ };
415
+ declare function parseStructuredStream(accumulatedText: string): Promise<{
416
+ html?: string | undefined;
417
+ plan?: (string | undefined)[] | undefined;
418
+ suggestions?: (string | undefined)[] | undefined;
419
+ } | undefined>;
420
+ declare function detectPhase(partial: PartialAiEmailResponse | undefined): "thinking" | "planning" | "applying";
421
+ declare const DEFAULT_NEW_TEMPLATE_SUGGESTIONS: string[];
422
+ declare const DEFAULT_EDIT_SUGGESTIONS: string[];
423
+ declare function resolveInitialSuggestions(suggestions?: readonly string[]): readonly string[];
424
+
425
+ export { AIEmailEditor, type AIEmailEditorErrorContext, type AIEmailEditorErrorSource, type AIEmailEditorMode, type AIEmailEditorProps, type AIEmailEditorSuccessContext, type AIEmailEditorSuccessSource, type AIEmailModelOption, type AiEmailChatMessage, AiEmailChatMessageSchema, type AiEmailHtmlSnapshot, AiEmailHtmlSnapshotSchema, type AiEmailImage, AiEmailImageSchema, type AiEmailResponse, AiEmailResponseSchema, type AiEmailSession, AiEmailSessionSchema, DEFAULT_EDIT_SUGGESTIONS, DEFAULT_NEW_TEMPLATE_SUGGESTIONS, type SendTestEmailInput, type StoredEmailRecord, applyMergeTags, buildAiEmailStreamRequestSchema, buildDefaultSystemPrompt, buildResponseFormatDirective, AIEmailEditor as default, detectPhase, extractMergeTags, extractStreamParts, formatPlan, getMergeTagError, parseStructuredStream, phaseLabel, resolveInitialSuggestions };