@diagonal-hq/pages 0.5.2 → 0.6.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.
- package/dist/index.d.ts +129 -16
- package/dist/index.js +1 -0
- package/package.json +1 -1
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;
|
|
@@ -4536,6 +4556,11 @@ export type SdkDisplayFormatOptions = {
|
|
|
4536
4556
|
durationUnit?: 'milliseconds' | 'seconds' | 'minutes' | 'hours';
|
|
4537
4557
|
};
|
|
4538
4558
|
|
|
4559
|
+
export type SdkDisplayPriceOptions = {
|
|
4560
|
+
/** Use a short suffix or a long billing phrase. Defaults to `short`. */
|
|
4561
|
+
style?: 'short' | 'long';
|
|
4562
|
+
};
|
|
4563
|
+
|
|
4539
4564
|
export type SdkRecordInput<TRecord extends ResourceRecord = ResourceRecord> =
|
|
4540
4565
|
| TRecord
|
|
4541
4566
|
| { fields?: TRecord | null }
|
|
@@ -4579,6 +4604,29 @@ export type SdkDisplayUtils = {
|
|
|
4579
4604
|
options?: SdkDisplayFormatOptions
|
|
4580
4605
|
) => string | null;
|
|
4581
4606
|
|
|
4607
|
+
/**
|
|
4608
|
+
* Format money with its billing recurrence for string contexts such as template
|
|
4609
|
+
* literals and `<option>` labels. Pass the recurrence select field handle so an
|
|
4610
|
+
* unknown value can use its option label, or its raw value if no label exists.
|
|
4611
|
+
* Uses the existing money formatter. The default style is `short`.
|
|
4612
|
+
* `one_time`, nullish, and empty recurrence values return the amount alone.
|
|
4613
|
+
* Invalid money, malformed fields, and invalid styles return `null` and report
|
|
4614
|
+
* the standard SDK diagnostic.
|
|
4615
|
+
*
|
|
4616
|
+
* @example
|
|
4617
|
+
* const recurrence = prices.fields.recurrence;
|
|
4618
|
+
* const amount = { amount: 5000, currency: 'USD' };
|
|
4619
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount); // '$50.00/mo'
|
|
4620
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount, { style: 'long' }); // '$50.00 per month'
|
|
4621
|
+
* Sdk.utils.display.price(recurrence, 'weekly', amount); // '$50.00 (Weekly)' with an option label
|
|
4622
|
+
*/
|
|
4623
|
+
price: (
|
|
4624
|
+
field: SdkResourceField | null | undefined,
|
|
4625
|
+
recurrence: any,
|
|
4626
|
+
amount: any,
|
|
4627
|
+
options?: SdkDisplayPriceOptions
|
|
4628
|
+
) => string | null;
|
|
4629
|
+
|
|
4582
4630
|
/**
|
|
4583
4631
|
* Build initials from the first `count` whitespace-delimited name parts.
|
|
4584
4632
|
* `count` defaults to `2`. Nullish/blank names or an invalid count return `''`
|
|
@@ -4696,11 +4744,17 @@ export type SdkUtils = Omit<TaskUtils, 'workspace' | 'workflow' | 'tiptap'> & {
|
|
|
4696
4744
|
* @remarks
|
|
4697
4745
|
* `format` delegates date, time, money, number, phone, and location rendering to the
|
|
4698
4746
|
* existing SDK formatters so their current locale and timezone behavior remains consistent.
|
|
4747
|
+
* Use `price` for billing recurrence wording in template literals and `<option>` labels.
|
|
4699
4748
|
* Nullish or malformed values return `null` with the standard SDK diagnostic;
|
|
4700
4749
|
* `fieldValue` returns `null`.
|
|
4701
4750
|
*
|
|
4702
4751
|
* @example
|
|
4703
4752
|
* const status = Sdk.utils.display.format(tasks.fields.status, task.status);
|
|
4753
|
+
* const recurrence = prices.fields.recurrence;
|
|
4754
|
+
* const amount = { amount: 5000, currency: 'USD' };
|
|
4755
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount); // '$50.00/mo'
|
|
4756
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount, { style: 'long' }); // '$50.00 per month'
|
|
4757
|
+
* Sdk.utils.display.price(recurrence, 'weekly', amount); // '$50.00 (Weekly)' with an option label
|
|
4704
4758
|
*/
|
|
4705
4759
|
display: SdkDisplayUtils;
|
|
4706
4760
|
};
|
|
@@ -7515,6 +7569,34 @@ export type SdkHooks = {
|
|
|
7515
7569
|
notificationTypeId: string | null | undefined,
|
|
7516
7570
|
options?: SdkNotificationListOptions
|
|
7517
7571
|
): SdkApiHandle<SdkNotificationTemplateList>;
|
|
7572
|
+
/**
|
|
7573
|
+
* Read a template's saved email subject and layout fields as unrendered Liquid, with
|
|
7574
|
+
* its published layout and the variables of its type. Requires send_emails; does not
|
|
7575
|
+
* require manage_notifications. No request runs until notificationTemplateId is set.
|
|
7576
|
+
* Reading never changes the template. Embedded files the viewer cannot read are removed.
|
|
7577
|
+
* The request fails with 422 for a template without email, without a published layout,
|
|
7578
|
+
* or with copy that only a notification send resolves: `{{ ref }}` generated values, a
|
|
7579
|
+
* field bound to a notification variable, or Liquid in a typed field.
|
|
7580
|
+
* To edit and send the draft, prefer `<Sdk.Components.EmailComposer notificationTemplateId>`,
|
|
7581
|
+
* which loads it for you. Without the composer, send it with useSendEmail in bulk mode:
|
|
7582
|
+
* the send renders the subject and Liquid fields once for each recipient's `data`.
|
|
7583
|
+
* Do not preview a template with placeholder variables and send the result: filters,
|
|
7584
|
+
* defaults, and conditions would read the placeholder.
|
|
7585
|
+
* @example
|
|
7586
|
+
* const draft = Sdk.hooks.useNotificationTemplateEmailDraft(templateId);
|
|
7587
|
+
* const email = Sdk.hooks.useSendEmail();
|
|
7588
|
+
* await email.send({
|
|
7589
|
+
* bulk: true,
|
|
7590
|
+
* to: members.map((m) => ({ email: m.email, data: { first_name: m.first_name } })),
|
|
7591
|
+
* subject: draft.data.subject,
|
|
7592
|
+
* email_layout_id: draft.data.email_layout_id,
|
|
7593
|
+
* layout_data: draft.data.layout_data
|
|
7594
|
+
* });
|
|
7595
|
+
*/
|
|
7596
|
+
useNotificationTemplateEmailDraft(
|
|
7597
|
+
notificationTemplateId: string | null | undefined,
|
|
7598
|
+
options?: { enabled?: boolean }
|
|
7599
|
+
): SdkApiHandle<SdkNotificationTemplateEmailDraft>;
|
|
7518
7600
|
|
|
7519
7601
|
/**
|
|
7520
7602
|
* List pending and failed notifications associated with one source or recipient record.
|
|
@@ -10739,7 +10821,9 @@ export type DropdownMenuItem = {
|
|
|
10739
10821
|
onSelect?: () => void;
|
|
10740
10822
|
};
|
|
10741
10823
|
|
|
10742
|
-
export type EmailComposerProps = EmailComposerBaseProps &
|
|
10824
|
+
export type EmailComposerProps = EmailComposerBaseProps &
|
|
10825
|
+
EmailComposerContentProps &
|
|
10826
|
+
EmailComposerAudienceProps;
|
|
10743
10827
|
|
|
10744
10828
|
export type EmailComposerBaseProps = {
|
|
10745
10829
|
/**
|
|
@@ -10768,13 +10852,6 @@ export type EmailComposerBaseProps = {
|
|
|
10768
10852
|
*/
|
|
10769
10853
|
variables?: EmailComposerVariable[];
|
|
10770
10854
|
|
|
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
10855
|
/**
|
|
10779
10856
|
* Values every email can read as `{{ key }}` — the same for all recipients, and
|
|
10780
10857
|
* the defaults for any variables the chosen layout declares. Recipient `data`
|
|
@@ -10785,14 +10862,6 @@ export type EmailComposerBaseProps = {
|
|
|
10785
10862
|
*/
|
|
10786
10863
|
data?: Record<string, any>;
|
|
10787
10864
|
|
|
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
10865
|
/**
|
|
10797
10866
|
* Called after the email is queued.
|
|
10798
10867
|
*/
|
|
@@ -10817,6 +10886,45 @@ export type EmailComposerVariable = {
|
|
|
10817
10886
|
type?: 'text' | 'number' | 'boolean' | 'date';
|
|
10818
10887
|
};
|
|
10819
10888
|
|
|
10889
|
+
export type EmailComposerContentProps =
|
|
10890
|
+
| {
|
|
10891
|
+
/**
|
|
10892
|
+
* Saved notification template the composer starts from, by ID. The composer
|
|
10893
|
+
* loads its subject, layout, and layout fields as Liquid source, and the send
|
|
10894
|
+
* renders them once for each recipient, so filters, defaults, and conditions
|
|
10895
|
+
* read that recipient's `data`. The template's layout is fixed, and its type's
|
|
10896
|
+
* variables fill the `{{` menu when `variables` is omitted. The edits change
|
|
10897
|
+
* only this email, never the template. Requires `send_emails`, not
|
|
10898
|
+
* `manage_notifications`.
|
|
10899
|
+
*
|
|
10900
|
+
* The composer shows a loading state, then the draft. A failed load shows the
|
|
10901
|
+
* reason with a "Try again" button; templates that only a notification send can
|
|
10902
|
+
* render fail this way. The draft is read once per mount and is not refreshed
|
|
10903
|
+
* in the background, so it never replaces the viewer's edits. A different ID
|
|
10904
|
+
* discards the edits and loads that template. A new `key` reloads the same
|
|
10905
|
+
* template. "Send another" restores the template's copy.
|
|
10906
|
+
*/
|
|
10907
|
+
notificationTemplateId: string;
|
|
10908
|
+
emailLayoutId?: never;
|
|
10909
|
+
initialSubject?: never;
|
|
10910
|
+
}
|
|
10911
|
+
| {
|
|
10912
|
+
notificationTemplateId?: undefined;
|
|
10913
|
+
/**
|
|
10914
|
+
* Published email layout that wraps the body. When set, the layout is fixed and the
|
|
10915
|
+
* picker is hidden. When omitted, the toolbar offers the workspace's published
|
|
10916
|
+
* layouts, or no layout at all.
|
|
10917
|
+
*/
|
|
10918
|
+
emailLayoutId?: string | null;
|
|
10919
|
+
/**
|
|
10920
|
+
* Subject the composer opens with, as Liquid source, so it can use `{{ name }}` and
|
|
10921
|
+
* the other variables. The viewer can edit it, and "Send another" restores it. The
|
|
10922
|
+
* composer reads it once, when it mounts: give the component a new `key` to start
|
|
10923
|
+
* again from a new subject and new `data`.
|
|
10924
|
+
*/
|
|
10925
|
+
initialSubject?: string;
|
|
10926
|
+
};
|
|
10927
|
+
|
|
10820
10928
|
export type EmailComposerAudienceProps =
|
|
10821
10929
|
| {
|
|
10822
10930
|
/**
|
|
@@ -14575,6 +14683,7 @@ export declare const useNewCalendarEvent: SdkInternal.FilePageSdk["hooks"]["useN
|
|
|
14575
14683
|
export declare const useNotificationConsent: SdkInternal.FilePageSdk["hooks"]["useNotificationConsent"];
|
|
14576
14684
|
export declare const useNotificationHistory: SdkInternal.FilePageSdk["hooks"]["useNotificationHistory"];
|
|
14577
14685
|
export declare const useNotificationHistoryDetail: SdkInternal.FilePageSdk["hooks"]["useNotificationHistoryDetail"];
|
|
14686
|
+
export declare const useNotificationTemplateEmailDraft: SdkInternal.FilePageSdk["hooks"]["useNotificationTemplateEmailDraft"];
|
|
14578
14687
|
export declare const useNotificationTemplates: SdkInternal.FilePageSdk["hooks"]["useNotificationTemplates"];
|
|
14579
14688
|
export declare const useNotificationTypes: SdkInternal.FilePageSdk["hooks"]["useNotificationTypes"];
|
|
14580
14689
|
export declare const usePackageReleaseNotes: SdkInternal.FilePageSdk["hooks"]["usePackageReleaseNotes"];
|
|
@@ -15012,6 +15121,8 @@ export declare const workspace: SdkInternal.FilePageSdk["workspace"];
|
|
|
15012
15121
|
|
|
15013
15122
|
export type NotificationTemplateList = SdkInternal.SdkNotificationTemplateList;
|
|
15014
15123
|
|
|
15124
|
+
export type NotificationTemplateEmailDraft = SdkInternal.SdkNotificationTemplateEmailDraft;
|
|
15125
|
+
|
|
15015
15126
|
export type NavigationMenu = SdkInternal.SdkNavigationMenu;
|
|
15016
15127
|
|
|
15017
15128
|
export type NavigationMenuCatalog = SdkInternal.SdkNavigationMenuCatalog;
|
|
@@ -15268,6 +15379,8 @@ export declare const workspace: SdkInternal.FilePageSdk["workspace"];
|
|
|
15268
15379
|
|
|
15269
15380
|
export type DisplayFormatOptions = SdkInternal.SdkDisplayFormatOptions;
|
|
15270
15381
|
|
|
15382
|
+
export type DisplayPriceOptions = SdkInternal.SdkDisplayPriceOptions;
|
|
15383
|
+
|
|
15271
15384
|
export type FieldSelector<TKey extends string = string> = SdkInternal.SdkFieldSelector<TKey>;
|
|
15272
15385
|
|
|
15273
15386
|
export type RecordInput<TRecord extends SdkInternal.ResourceRecord = SdkInternal.ResourceRecord> = SdkInternal.SdkRecordInput<TRecord>;
|
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;
|