@diagonal-hq/pages 0.5.1 → 0.6.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/dist/index.d.ts CHANGED
@@ -2878,6 +2878,26 @@ export type SdkNotificationTemplateList = {
2878
2878
  pagination: ResourcePagination;
2879
2879
  };
2880
2880
 
2881
+ export type SdkNotificationTemplateEmailDraft = {
2882
+ notification_template_id: string;
2883
+ notification_template_name: string;
2884
+ notification_type_id: string;
2885
+ notification_type_name: string;
2886
+ /** The type's recipient resource. Its templates read the recipient as `{{ record.<field> }}`. */
2887
+ notifiable_resource_id: string | null;
2888
+ /** Liquid source, such as `Hi {{ first_name | upcase }}`. */
2889
+ subject: string;
2890
+ /** The template's published layout, or null for the default body. */
2891
+ email_layout_id: string | null;
2892
+ /**
2893
+ * Every field the layout declares, or `content` without a layout, as the template
2894
+ * saved it. Liquid fields are source strings. A field the template leaves empty is null.
2895
+ */
2896
+ layout_data: Record<string, any>;
2897
+ /** The values the template's type takes. Supply them per recipient in `data`. */
2898
+ variables: SdkNotificationVariableSummary[];
2899
+ };
2900
+
2881
2901
  export type SdkNavigationMenu = {
2882
2902
  id: string;
2883
2903
  name: string;
@@ -7515,6 +7535,34 @@ export type SdkHooks = {
7515
7535
  notificationTypeId: string | null | undefined,
7516
7536
  options?: SdkNotificationListOptions
7517
7537
  ): SdkApiHandle<SdkNotificationTemplateList>;
7538
+ /**
7539
+ * Read a template's saved email subject and layout fields as unrendered Liquid, with
7540
+ * its published layout and the variables of its type. Requires send_emails; does not
7541
+ * require manage_notifications. No request runs until notificationTemplateId is set.
7542
+ * Reading never changes the template. Embedded files the viewer cannot read are removed.
7543
+ * The request fails with 422 for a template without email, without a published layout,
7544
+ * or with copy that only a notification send resolves: `{{ ref }}` generated values, a
7545
+ * field bound to a notification variable, or Liquid in a typed field.
7546
+ * To edit and send the draft, prefer `<Sdk.Components.EmailComposer notificationTemplateId>`,
7547
+ * which loads it for you. Without the composer, send it with useSendEmail in bulk mode:
7548
+ * the send renders the subject and Liquid fields once for each recipient's `data`.
7549
+ * Do not preview a template with placeholder variables and send the result: filters,
7550
+ * defaults, and conditions would read the placeholder.
7551
+ * @example
7552
+ * const draft = Sdk.hooks.useNotificationTemplateEmailDraft(templateId);
7553
+ * const email = Sdk.hooks.useSendEmail();
7554
+ * await email.send({
7555
+ * bulk: true,
7556
+ * to: members.map((m) => ({ email: m.email, data: { first_name: m.first_name } })),
7557
+ * subject: draft.data.subject,
7558
+ * email_layout_id: draft.data.email_layout_id,
7559
+ * layout_data: draft.data.layout_data
7560
+ * });
7561
+ */
7562
+ useNotificationTemplateEmailDraft(
7563
+ notificationTemplateId: string | null | undefined,
7564
+ options?: { enabled?: boolean }
7565
+ ): SdkApiHandle<SdkNotificationTemplateEmailDraft>;
7518
7566
 
7519
7567
  /**
7520
7568
  * List pending and failed notifications associated with one source or recipient record.
@@ -10739,7 +10787,9 @@ export type DropdownMenuItem = {
10739
10787
  onSelect?: () => void;
10740
10788
  };
10741
10789
 
10742
- export type EmailComposerProps = EmailComposerBaseProps & EmailComposerAudienceProps;
10790
+ export type EmailComposerProps = EmailComposerBaseProps &
10791
+ EmailComposerContentProps &
10792
+ EmailComposerAudienceProps;
10743
10793
 
10744
10794
  export type EmailComposerBaseProps = {
10745
10795
  /**
@@ -10768,13 +10818,6 @@ export type EmailComposerBaseProps = {
10768
10818
  */
10769
10819
  variables?: EmailComposerVariable[];
10770
10820
 
10771
- /**
10772
- * Published email layout that wraps the body. When set, the layout is fixed and the
10773
- * picker is hidden. When omitted, the toolbar offers the workspace's published
10774
- * layouts, or no layout at all.
10775
- */
10776
- emailLayoutId?: string | null;
10777
-
10778
10821
  /**
10779
10822
  * Values every email can read as `{{ key }}` — the same for all recipients, and
10780
10823
  * the defaults for any variables the chosen layout declares. Recipient `data`
@@ -10785,14 +10828,6 @@ export type EmailComposerBaseProps = {
10785
10828
  */
10786
10829
  data?: Record<string, any>;
10787
10830
 
10788
- /**
10789
- * Subject the composer opens with, as Liquid source, so it can use `{{ name }}` and
10790
- * the other variables. The viewer can edit it, and "Send another" restores it. The
10791
- * composer reads it once, when it mounts: give the component a new `key` to start
10792
- * again from a new subject and new `data`.
10793
- */
10794
- initialSubject?: string;
10795
-
10796
10831
  /**
10797
10832
  * Called after the email is queued.
10798
10833
  */
@@ -10817,6 +10852,45 @@ export type EmailComposerVariable = {
10817
10852
  type?: 'text' | 'number' | 'boolean' | 'date';
10818
10853
  };
10819
10854
 
10855
+ export type EmailComposerContentProps =
10856
+ | {
10857
+ /**
10858
+ * Saved notification template the composer starts from, by ID. The composer
10859
+ * loads its subject, layout, and layout fields as Liquid source, and the send
10860
+ * renders them once for each recipient, so filters, defaults, and conditions
10861
+ * read that recipient's `data`. The template's layout is fixed, and its type's
10862
+ * variables fill the `{{` menu when `variables` is omitted. The edits change
10863
+ * only this email, never the template. Requires `send_emails`, not
10864
+ * `manage_notifications`.
10865
+ *
10866
+ * The composer shows a loading state, then the draft. A failed load shows the
10867
+ * reason with a "Try again" button; templates that only a notification send can
10868
+ * render fail this way. The draft is read once per mount and is not refreshed
10869
+ * in the background, so it never replaces the viewer's edits. A different ID
10870
+ * discards the edits and loads that template. A new `key` reloads the same
10871
+ * template. "Send another" restores the template's copy.
10872
+ */
10873
+ notificationTemplateId: string;
10874
+ emailLayoutId?: never;
10875
+ initialSubject?: never;
10876
+ }
10877
+ | {
10878
+ notificationTemplateId?: undefined;
10879
+ /**
10880
+ * Published email layout that wraps the body. When set, the layout is fixed and the
10881
+ * picker is hidden. When omitted, the toolbar offers the workspace's published
10882
+ * layouts, or no layout at all.
10883
+ */
10884
+ emailLayoutId?: string | null;
10885
+ /**
10886
+ * Subject the composer opens with, as Liquid source, so it can use `{{ name }}` and
10887
+ * the other variables. The viewer can edit it, and "Send another" restores it. The
10888
+ * composer reads it once, when it mounts: give the component a new `key` to start
10889
+ * again from a new subject and new `data`.
10890
+ */
10891
+ initialSubject?: string;
10892
+ };
10893
+
10820
10894
  export type EmailComposerAudienceProps =
10821
10895
  | {
10822
10896
  /**
@@ -11066,8 +11140,8 @@ export type FormFieldInputProps = {
11066
11140
 
11067
11141
  /**
11068
11142
  * Prefix segments for `context.errors` lookups. Location fields read
11069
- * `<prefix>.<subfield>` errors for `line1`, `line2`, `city`, `state`,
11070
- * `postal_code`, and `country`. Pass `['display_address']` for errors such as
11143
+ * `<prefix>.<subfield>` errors for `display_name`, `line1`, `line2`, `city`,
11144
+ * `state`, `postal_code`, and `country`. Pass `['display_address']` for errors such as
11071
11145
  * `display_address.line1`, shown beside Address line 1.
11072
11146
  * Nested inline-create drafts append their draft index and child field key,
11073
11147
  * so a caller rendering the `files` relation passes `['files']` for errors
@@ -11641,9 +11715,15 @@ export type FormLocationInputProps = PrimitiveFormFieldProps & {
11641
11715
 
11642
11716
  /**
11643
11717
  * Per-subfield validation errors, keyed by address field name
11644
- * (`line1`, `line2`, `city`, `state`, `postal_code`, `country`).
11718
+ * (`display_name`, `line1`, `line2`, `city`, `state`, `postal_code`, `country`).
11645
11719
  */
11646
11720
  errors?: LocationAddressFormErrors;
11721
+
11722
+ /**
11723
+ * Show the editable Display name row above Address line 1 in the expanded fields.
11724
+ * Defaults to `true`. Pass `false` on a form that should not collect a display name.
11725
+ */
11726
+ showDisplayName?: boolean;
11647
11727
  };
11648
11728
 
11649
11729
  export type LocationValue = {
@@ -11661,7 +11741,10 @@ export type LocationValue = {
11661
11741
  };
11662
11742
 
11663
11743
  export type LocationAddressFormErrors = Partial<
11664
- Record<'line1' | 'line2' | 'city' | 'state' | 'postal_code' | 'country', string | string[]>
11744
+ Record<
11745
+ 'display_name' | 'line1' | 'line2' | 'city' | 'state' | 'postal_code' | 'country',
11746
+ string | string[]
11747
+ >
11665
11748
  >;
11666
11749
 
11667
11750
  export type FormMarkdownInputProps = Omit<
@@ -14566,6 +14649,7 @@ export declare const useNewCalendarEvent: SdkInternal.FilePageSdk["hooks"]["useN
14566
14649
  export declare const useNotificationConsent: SdkInternal.FilePageSdk["hooks"]["useNotificationConsent"];
14567
14650
  export declare const useNotificationHistory: SdkInternal.FilePageSdk["hooks"]["useNotificationHistory"];
14568
14651
  export declare const useNotificationHistoryDetail: SdkInternal.FilePageSdk["hooks"]["useNotificationHistoryDetail"];
14652
+ export declare const useNotificationTemplateEmailDraft: SdkInternal.FilePageSdk["hooks"]["useNotificationTemplateEmailDraft"];
14569
14653
  export declare const useNotificationTemplates: SdkInternal.FilePageSdk["hooks"]["useNotificationTemplates"];
14570
14654
  export declare const useNotificationTypes: SdkInternal.FilePageSdk["hooks"]["useNotificationTypes"];
14571
14655
  export declare const usePackageReleaseNotes: SdkInternal.FilePageSdk["hooks"]["usePackageReleaseNotes"];
@@ -15003,6 +15087,8 @@ export declare const workspace: SdkInternal.FilePageSdk["workspace"];
15003
15087
 
15004
15088
  export type NotificationTemplateList = SdkInternal.SdkNotificationTemplateList;
15005
15089
 
15090
+ export type NotificationTemplateEmailDraft = SdkInternal.SdkNotificationTemplateEmailDraft;
15091
+
15006
15092
  export type NavigationMenu = SdkInternal.SdkNavigationMenu;
15007
15093
 
15008
15094
  export type NavigationMenuCatalog = SdkInternal.SdkNavigationMenuCatalog;
package/dist/index.js CHANGED
@@ -187,6 +187,7 @@ export const useNewCalendarEvent = undefined;
187
187
  export const useNotificationConsent = undefined;
188
188
  export const useNotificationHistory = undefined;
189
189
  export const useNotificationHistoryDetail = undefined;
190
+ export const useNotificationTemplateEmailDraft = undefined;
190
191
  export const useNotificationTemplates = undefined;
191
192
  export const useNotificationTypes = undefined;
192
193
  export const usePackageReleaseNotes = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/pages",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "The Page SDK for the pages of file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {