-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathemail-template.form.ts
More file actions
85 lines (83 loc) · 3.18 KB
/
Copy pathemail-template.form.ts
File metadata and controls
85 lines (83 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineForm } from '../ui/view.zod';
/**
* EmailTemplate — canonical FormView layout.
*
* Bound to `EmailTemplateDefinitionSchema` (the canonical `email_template`
* metadata type). Bodies are rendered with the `code` widget so admins
* get syntax highlighting for the HTML body; the plain-text body uses
* a textarea since it is rarely styled.
*/
export const emailTemplateForm = defineForm({
schemaId: 'email_template',
type: 'simple',
sections: [
{
label: 'Identity',
description: 'Template identifier resolved by IEmailService.sendTemplate({ template: name, locale, ... }).',
columns: 2,
fields: [
{ field: 'name', required: true, colSpan: 1, helpText: 'Dotted snake_case (e.g. auth.password_reset, crm.welcome)' },
{ field: 'label', required: true, colSpan: 1 },
{ field: 'category', type: 'select', colSpan: 1, options: [
{ label: 'Auth', value: 'auth' },
{ label: 'Notification', value: 'notification' },
{ label: 'Workflow', value: 'workflow' },
{ label: 'Marketing', value: 'marketing' },
{ label: 'Custom', value: 'custom' },
]},
{ field: 'locale', colSpan: 1, helpText: 'BCP-47 tag — e.g. en-US, zh-CN' },
{ field: 'description', widget: 'textarea', colSpan: 2 },
],
},
{
label: 'Subject',
description: 'Subject line. Supports {{var.path}} interpolation.',
columns: 1,
fields: [
{ field: 'subject', required: true, widget: 'textarea' },
],
},
{
label: 'HTML body',
description: 'Rich HTML body. Most clients strip <head>, so use inline styles.',
columns: 1,
fields: [
{ field: 'bodyHtml', required: true, type: 'code', language: 'html' },
],
},
{
label: 'Plain-text body',
description: 'Optional plain-text alternative. When omitted, the service strips tags from the HTML body to derive one. Providing one improves spam scoring.',
columns: 1,
fields: [
{ field: 'bodyText', widget: 'textarea' },
],
},
{
label: 'Variables',
description: 'Declared variables. Rendered as hints in Studio and validated by sendTemplate() when required.',
columns: 1,
fields: [
{ field: 'variables', widget: 'json', helpText: '[{ "name": "user.name", "type": "string", "required": true, "description": "..." }]' },
],
},
{
label: 'Delivery overrides',
description: 'Optional per-template overrides for From / Reply-To.',
columns: 2,
fields: [
{ field: 'fromOverride', widget: 'json', colSpan: 2, helpText: '{ "name": "Acme Sales", "address": "sales@acme.com" }' },
{ field: 'replyTo', colSpan: 2, helpText: 'Reply-To email address' },
],
},
{
label: 'Status',
columns: 2,
fields: [
{ field: 'active', type: 'boolean', colSpan: 1, helpText: 'When unchecked, sendTemplate() returns TEMPLATE_INACTIVE.' },
{ field: 'isSystem', type: 'boolean', colSpan: 1, helpText: 'Built-in template; tenants may override but should not delete.' },
],
},
],
});