@diagonal-hq/cli 0.44.0 → 0.45.1

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.
@@ -2850,7 +2850,121 @@ type SdkNotificationTemplateContent = {
2850
2850
  references: Record<string, SdkNotificationTemplateReference>;
2851
2851
  };
2852
2852
 
2853
+ type SdkEmailDocument = EmailDocument;
2854
+
2855
+ type EmailDocument = {
2856
+ version: 1;
2857
+ /** The values that the author changed from the Brand Kit. */
2858
+ theme: Partial<EmailTheme>;
2859
+ blocks: EmailBlock[];
2860
+ };
2861
+
2862
+ type EmailTheme = {
2863
+ background: string;
2864
+ surface: string;
2865
+ text: string;
2866
+ muted: string;
2867
+ accent: string;
2868
+ accent_text: string;
2869
+ font: 'sans' | 'modern' | 'humanist' | 'serif';
2870
+ radius: number;
2871
+ };
2872
+
2873
+ type EmailBlock =
2874
+ | TextBlock
2875
+ | ImageBlock
2876
+ | ButtonBlock
2877
+ | LogoBlock
2878
+ | DividerBlock
2879
+ | SpacerBlock
2880
+ | ColumnsBlock
2881
+ | SocialBlock;
2882
+
2883
+ type TextBlock = BlockBase & { type: 'text'; content: JSONContent; align: EmailAlign };
2884
+
2885
+ type BlockBase = {
2886
+ id: string;
2887
+ condition?: BlockCondition | null;
2888
+ style: { padding_top: number; padding_bottom: number; background: string | null };
2889
+ };
2890
+
2891
+ type BlockCondition = { path: string; is: 'filled' | 'empty' };
2892
+
2893
+ type JSONContent<A = any, B = any, C = any, D = any> = any;
2894
+
2895
+ type EmailAlign = 'left' | 'center' | 'right';
2896
+
2897
+ type ImageBlock = BlockBase & {
2898
+ type: 'image';
2899
+ file_id: string | null;
2900
+ url: string | null;
2901
+ alt: string;
2902
+ link: EmailLink;
2903
+ width: number;
2904
+ radius: number;
2905
+ align: EmailAlign;
2906
+ };
2907
+
2908
+ type EmailLink =
2909
+ | { type: 'url'; value: string }
2910
+ | { type: 'variable'; expression: string }
2911
+ | null;
2912
+
2913
+ type ButtonBlock = BlockBase & {
2914
+ type: 'button';
2915
+ label: string;
2916
+ link: EmailLink;
2917
+ variant: 'solid' | 'outline';
2918
+ color: string | null;
2919
+ text_color: string | null;
2920
+ full_width: boolean;
2921
+ align: EmailAlign;
2922
+ };
2923
+
2924
+ type LogoBlock = BlockBase & {
2925
+ type: 'logo';
2926
+ variant: LogoVariant;
2927
+ width: number;
2928
+ link: EmailLink;
2929
+ align: EmailAlign;
2930
+ };
2931
+
2932
+ type LogoVariant = 'auto' | 'horizontal' | 'wordmark' | 'icon';
2933
+
2934
+ type DividerBlock = BlockBase & { type: 'divider'; color: string | null; thickness: number };
2935
+
2936
+ type SpacerBlock = BlockBase & { type: 'spacer'; height: number };
2937
+
2938
+ type ColumnsBlock = BlockBase & {
2939
+ type: 'columns';
2940
+ layout: ColumnLayout;
2941
+ columns: EmailBlock[][];
2942
+ };
2943
+
2944
+ type ColumnLayout = '1-1' | '1-2' | '2-1' | '1-1-1';
2945
+
2946
+ type SocialBlock = BlockBase & {
2947
+ type: 'social';
2948
+ links: { network: SocialNetwork; url: string }[];
2949
+ align: EmailAlign;
2950
+ };
2951
+
2952
+ type SocialNetwork =
2953
+ | 'facebook'
2954
+ | 'instagram'
2955
+ | 'linkedin'
2956
+ | 'x'
2957
+ | 'youtube'
2958
+ | 'tiktok'
2959
+ | 'website';
2960
+
2853
2961
  type SdkNotificationTemplateDefinition = SdkNotificationTemplateContent & {
2962
+ /** The `EmailBuilder` document, or null for a template that another editor wrote. */
2963
+ email_document: SdkEmailDocument | null;
2964
+ /** What the author must finish before the email can be sent. */
2965
+ email_document_issues: { block_id: string; message: string }[];
2966
+ /** Changes with the email's content. Send it as `expected_revision` to refuse a stale save. */
2967
+ content_revision: string;
2854
2968
  id: string;
2855
2969
  name: string;
2856
2970
  notification_type_name: string;
@@ -2864,6 +2978,14 @@ type SdkNotificationTemplateDefinition = SdkNotificationTemplateContent & {
2864
2978
  type SdkSaveNotificationTemplateInput = SdkNotificationTemplateContent & {
2865
2979
  id?: string;
2866
2980
  name: string;
2981
+ /**
2982
+ * The `EmailBuilder` document. The server compiles it to the `content` layout value. Copy it
2983
+ * from a starting template to keep the copy editable in the builder. A save that omits it
2984
+ * keeps the document, and may not change the content.
2985
+ */
2986
+ email_document?: SdkEmailDocument | null;
2987
+ /** The `content_revision` that the change is based on. A save from an older one fails with 409. */
2988
+ expected_revision?: string;
2867
2989
  };
2868
2990
 
2869
2991
  type SdkUseSaveNotificationTemplateOptions = {
@@ -6395,6 +6517,7 @@ type ComponentRegistry = {
6395
6517
  "DataTableToolbar": SdkComponent<DataTableToolbarProps>;
6396
6518
  "DeleteResourceRecord": SdkComponent<DeleteResourceRecordProps>;
6397
6519
  "DropdownMenu": SdkComponent<DropdownMenuProps>;
6520
+ "EmailBuilder": SdkComponent<EmailBuilderProps>;
6398
6521
  "EmailComposer": SdkComponent<EmailComposerProps>;
6399
6522
  "EmailMessages": SdkComponent<EmailMessagesProps>;
6400
6523
  "EmptyState": SdkComponent<EmptyStateProps>;
@@ -11010,6 +11133,81 @@ type DropdownMenuItem = {
11010
11133
  onSelect?: () => void;
11011
11134
  };
11012
11135
 
11136
+ type EmailBuilderProps = {
11137
+ /**
11138
+ * Notification template that the builder edits. The builder reads it once per mount and
11139
+ * saves each edit to it. Saving sends no email. Requires `manage_notifications`.
11140
+ */
11141
+ notificationTemplateId: string;
11142
+
11143
+ /** Title in the top bar, such as the campaign name. */
11144
+ title: string;
11145
+
11146
+ /** Called by the Back button after the last edit is saved. */
11147
+ onExit: () => void;
11148
+
11149
+ /** Called after each save, for example to copy the subject to a campaign record. */
11150
+ onSaved?: (template: SdkNotificationTemplateDefinition) => void;
11151
+
11152
+ /** Actions at the right of the top bar, such as Review and send. */
11153
+ actions?: (state: EmailBuilderState) => ReactNode;
11154
+
11155
+ /** Values of the type's variables for previews and tests. A record variable takes a record ID. */
11156
+ data?: Record<string, any>;
11157
+
11158
+ /** People the author can preview the email as. A test email renders for the selected person. */
11159
+ recipients?: EmailBuilderRecipient[];
11160
+
11161
+ /** Pages that buttons can link to. The first one is the Portal link block. */
11162
+ links?: EmailBuilderLink[];
11163
+
11164
+ /**
11165
+ * Layout that the next save uses. It must declare a `content` field. A layout can also declare
11166
+ * `preview_text`, `theme_background`, `theme_text`, `theme_muted`, `theme_accent`, and
11167
+ * `theme_font`. Omit it to keep the template's layout.
11168
+ */
11169
+ emailLayoutId?: string;
11170
+
11171
+ /**
11172
+ * Layout fields whose text starts the email when the template has no builder document yet.
11173
+ * @default ['content']
11174
+ */
11175
+ importFields?: string[];
11176
+
11177
+ /**
11178
+ * What the layout adds below every email, such as the sender's address and the unsubscribe
11179
+ * line. The canvas shows it as a locked section, so authors know what the recipient sees.
11180
+ */
11181
+ footer?: ReactNode;
11182
+
11183
+ /** Shows the email without editing, for example after it was sent. It keeps its saved design. */
11184
+ readOnly?: boolean;
11185
+ };
11186
+
11187
+ type EmailBuilderState = {
11188
+ /** True when every edit is saved. */
11189
+ isSaved: boolean;
11190
+ isSaving: boolean;
11191
+ /** Number of blocks the author must finish. A send refuses the email until it is zero. */
11192
+ issueCount: number;
11193
+ };
11194
+
11195
+ type EmailBuilderRecipient = {
11196
+ resourceId: string;
11197
+ recordId: string;
11198
+ email: string;
11199
+ name?: string;
11200
+ };
11201
+
11202
+ type EmailBuilderLink = {
11203
+ /** Name of the generated link. Lowercase letters, numbers, and underscores. */
11204
+ key: string;
11205
+ /** What the author reads in the link menu, such as `Member portal`. */
11206
+ label: string;
11207
+ /** Page that the link opens. */
11208
+ pageId: string;
11209
+ };
11210
+
11013
11211
  type EmailComposerProps = EmailComposerSendProps | EmailComposerDraftProps;
11014
11212
 
11015
11213
  type EmailComposerSendProps = EmailComposerBaseProps & {
@@ -11793,8 +11991,6 @@ type FormContentInputProps = Omit<
11793
11991
 
11794
11992
  type UiFormContentInputProps<A = any, B = any, C = any, D = any> = any;
11795
11993
 
11796
- type JSONContent<A = any, B = any, C = any, D = any> = any;
11797
-
11798
11994
  type ContentSettings = {
11799
11995
  extensions?: ExtensionsSettings;
11800
11996
  placeholder?: string | null;
@@ -14949,6 +15145,7 @@ declare namespace Sdk {
14949
15145
  export type NotificationTemplateEmailDraft = import("diagonal:sdk-internal").SdkNotificationTemplateEmailDraft;
14950
15146
  export type NotificationTemplateReference = import("diagonal:sdk-internal").SdkNotificationTemplateReference;
14951
15147
  export type NotificationTemplateContent = import("diagonal:sdk-internal").SdkNotificationTemplateContent;
15148
+ export type EmailDocument = import("diagonal:sdk-internal").SdkEmailDocument;
14952
15149
  export type NotificationTemplateDefinition = import("diagonal:sdk-internal").SdkNotificationTemplateDefinition;
14953
15150
  export type SaveNotificationTemplateInput = import("diagonal:sdk-internal").SdkSaveNotificationTemplateInput;
14954
15151
  export type UseSaveNotificationTemplateOptions = import("diagonal:sdk-internal").SdkUseSaveNotificationTemplateOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.44.0",
3
+ "version": "0.45.1",
4
4
  "description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {