@diagonal-hq/cli 0.28.3 → 0.29.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/cli.mjs +3356 -4743
- package/dist/sdk-contract.d.ts +91 -16
- package/dist/workflow/generated/capabilities.d.ts +16 -7
- package/dist/workflow/index.d.ts +10 -2
- package/dist/workflow/liquid.d.ts +44 -0
- package/dist/workflow/notifications.d.ts +2 -2
- package/package.json +10 -2
package/dist/sdk-contract.d.ts
CHANGED
|
@@ -2814,6 +2814,26 @@ type SdkNotificationTemplateList = {
|
|
|
2814
2814
|
pagination: ResourcePagination;
|
|
2815
2815
|
};
|
|
2816
2816
|
|
|
2817
|
+
type SdkNotificationTemplateEmailDraft = {
|
|
2818
|
+
notification_template_id: string;
|
|
2819
|
+
notification_template_name: string;
|
|
2820
|
+
notification_type_id: string;
|
|
2821
|
+
notification_type_name: string;
|
|
2822
|
+
/** The type's recipient resource. Its templates read the recipient as `{{ record.<field> }}`. */
|
|
2823
|
+
notifiable_resource_id: string | null;
|
|
2824
|
+
/** Liquid source, such as `Hi {{ first_name | upcase }}`. */
|
|
2825
|
+
subject: string;
|
|
2826
|
+
/** The template's published layout, or null for the default body. */
|
|
2827
|
+
email_layout_id: string | null;
|
|
2828
|
+
/**
|
|
2829
|
+
* Every field the layout declares, or `content` without a layout, as the template
|
|
2830
|
+
* saved it. Liquid fields are source strings. A field the template leaves empty is null.
|
|
2831
|
+
*/
|
|
2832
|
+
layout_data: Record<string, any>;
|
|
2833
|
+
/** The values the template's type takes. Supply them per recipient in `data`. */
|
|
2834
|
+
variables: SdkNotificationVariableSummary[];
|
|
2835
|
+
};
|
|
2836
|
+
|
|
2817
2837
|
type SdkNavigationMenu = {
|
|
2818
2838
|
id: string;
|
|
2819
2839
|
name: string;
|
|
@@ -7453,6 +7473,34 @@ type SdkHooks = {
|
|
|
7453
7473
|
notificationTypeId: string | null | undefined,
|
|
7454
7474
|
options?: SdkNotificationListOptions
|
|
7455
7475
|
): SdkApiHandle<SdkNotificationTemplateList>;
|
|
7476
|
+
/**
|
|
7477
|
+
* Read a template's saved email subject and layout fields as unrendered Liquid, with
|
|
7478
|
+
* its published layout and the variables of its type. Requires send_emails; does not
|
|
7479
|
+
* require manage_notifications. No request runs until notificationTemplateId is set.
|
|
7480
|
+
* Reading never changes the template. Embedded files the viewer cannot read are removed.
|
|
7481
|
+
* The request fails with 422 for a template without email, without a published layout,
|
|
7482
|
+
* or with copy that only a notification send resolves: `{{ ref }}` generated values, a
|
|
7483
|
+
* field bound to a notification variable, or Liquid in a typed field.
|
|
7484
|
+
* To edit and send the draft, prefer `<Sdk.Components.EmailComposer notificationTemplateId>`,
|
|
7485
|
+
* which loads it for you. Without the composer, send it with useSendEmail in bulk mode:
|
|
7486
|
+
* the send renders the subject and Liquid fields once for each recipient's `data`.
|
|
7487
|
+
* Do not preview a template with placeholder variables and send the result: filters,
|
|
7488
|
+
* defaults, and conditions would read the placeholder.
|
|
7489
|
+
* @example
|
|
7490
|
+
* const draft = Sdk.hooks.useNotificationTemplateEmailDraft(templateId);
|
|
7491
|
+
* const email = Sdk.hooks.useSendEmail();
|
|
7492
|
+
* await email.send({
|
|
7493
|
+
* bulk: true,
|
|
7494
|
+
* to: members.map((m) => ({ email: m.email, data: { first_name: m.first_name } })),
|
|
7495
|
+
* subject: draft.data.subject,
|
|
7496
|
+
* email_layout_id: draft.data.email_layout_id,
|
|
7497
|
+
* layout_data: draft.data.layout_data
|
|
7498
|
+
* });
|
|
7499
|
+
*/
|
|
7500
|
+
useNotificationTemplateEmailDraft(
|
|
7501
|
+
notificationTemplateId: string | null | undefined,
|
|
7502
|
+
options?: { enabled?: boolean }
|
|
7503
|
+
): SdkApiHandle<SdkNotificationTemplateEmailDraft>;
|
|
7456
7504
|
|
|
7457
7505
|
/**
|
|
7458
7506
|
* List pending and failed notifications associated with one source or recipient record.
|
|
@@ -10677,7 +10725,9 @@ type DropdownMenuItem = {
|
|
|
10677
10725
|
onSelect?: () => void;
|
|
10678
10726
|
};
|
|
10679
10727
|
|
|
10680
|
-
type EmailComposerProps = EmailComposerBaseProps &
|
|
10728
|
+
type EmailComposerProps = EmailComposerBaseProps &
|
|
10729
|
+
EmailComposerContentProps &
|
|
10730
|
+
EmailComposerAudienceProps;
|
|
10681
10731
|
|
|
10682
10732
|
type EmailComposerBaseProps = {
|
|
10683
10733
|
/**
|
|
@@ -10706,13 +10756,6 @@ type EmailComposerBaseProps = {
|
|
|
10706
10756
|
*/
|
|
10707
10757
|
variables?: EmailComposerVariable[];
|
|
10708
10758
|
|
|
10709
|
-
/**
|
|
10710
|
-
* Published email layout that wraps the body. When set, the layout is fixed and the
|
|
10711
|
-
* picker is hidden. When omitted, the toolbar offers the workspace's published
|
|
10712
|
-
* layouts, or no layout at all.
|
|
10713
|
-
*/
|
|
10714
|
-
emailLayoutId?: string | null;
|
|
10715
|
-
|
|
10716
10759
|
/**
|
|
10717
10760
|
* Values every email can read as `{{ key }}` — the same for all recipients, and
|
|
10718
10761
|
* the defaults for any variables the chosen layout declares. Recipient `data`
|
|
@@ -10723,14 +10766,6 @@ type EmailComposerBaseProps = {
|
|
|
10723
10766
|
*/
|
|
10724
10767
|
data?: Record<string, any>;
|
|
10725
10768
|
|
|
10726
|
-
/**
|
|
10727
|
-
* Subject the composer opens with, as Liquid source, so it can use `{{ name }}` and
|
|
10728
|
-
* the other variables. The viewer can edit it, and "Send another" restores it. The
|
|
10729
|
-
* composer reads it once, when it mounts: give the component a new `key` to start
|
|
10730
|
-
* again from a new subject and new `data`.
|
|
10731
|
-
*/
|
|
10732
|
-
initialSubject?: string;
|
|
10733
|
-
|
|
10734
10769
|
/**
|
|
10735
10770
|
* Called after the email is queued.
|
|
10736
10771
|
*/
|
|
@@ -10755,6 +10790,45 @@ type EmailComposerVariable = {
|
|
|
10755
10790
|
type?: 'text' | 'number' | 'boolean' | 'date';
|
|
10756
10791
|
};
|
|
10757
10792
|
|
|
10793
|
+
type EmailComposerContentProps =
|
|
10794
|
+
| {
|
|
10795
|
+
/**
|
|
10796
|
+
* Saved notification template the composer starts from, by ID. The composer
|
|
10797
|
+
* loads its subject, layout, and layout fields as Liquid source, and the send
|
|
10798
|
+
* renders them once for each recipient, so filters, defaults, and conditions
|
|
10799
|
+
* read that recipient's `data`. The template's layout is fixed, and its type's
|
|
10800
|
+
* variables fill the `{{` menu when `variables` is omitted. The edits change
|
|
10801
|
+
* only this email, never the template. Requires `send_emails`, not
|
|
10802
|
+
* `manage_notifications`.
|
|
10803
|
+
*
|
|
10804
|
+
* The composer shows a loading state, then the draft. A failed load shows the
|
|
10805
|
+
* reason with a "Try again" button; templates that only a notification send can
|
|
10806
|
+
* render fail this way. The draft is read once per mount and is not refreshed
|
|
10807
|
+
* in the background, so it never replaces the viewer's edits. A different ID
|
|
10808
|
+
* discards the edits and loads that template. A new `key` reloads the same
|
|
10809
|
+
* template. "Send another" restores the template's copy.
|
|
10810
|
+
*/
|
|
10811
|
+
notificationTemplateId: string;
|
|
10812
|
+
emailLayoutId?: never;
|
|
10813
|
+
initialSubject?: never;
|
|
10814
|
+
}
|
|
10815
|
+
| {
|
|
10816
|
+
notificationTemplateId?: undefined;
|
|
10817
|
+
/**
|
|
10818
|
+
* Published email layout that wraps the body. When set, the layout is fixed and the
|
|
10819
|
+
* picker is hidden. When omitted, the toolbar offers the workspace's published
|
|
10820
|
+
* layouts, or no layout at all.
|
|
10821
|
+
*/
|
|
10822
|
+
emailLayoutId?: string | null;
|
|
10823
|
+
/**
|
|
10824
|
+
* Subject the composer opens with, as Liquid source, so it can use `{{ name }}` and
|
|
10825
|
+
* the other variables. The viewer can edit it, and "Send another" restores it. The
|
|
10826
|
+
* composer reads it once, when it mounts: give the component a new `key` to start
|
|
10827
|
+
* again from a new subject and new `data`.
|
|
10828
|
+
*/
|
|
10829
|
+
initialSubject?: string;
|
|
10830
|
+
};
|
|
10831
|
+
|
|
10758
10832
|
type EmailComposerAudienceProps =
|
|
10759
10833
|
| {
|
|
10760
10834
|
/**
|
|
@@ -14528,6 +14602,7 @@ declare namespace Sdk {
|
|
|
14528
14602
|
export type NotificationTemplateSummary = import("diagonal:sdk-internal").SdkNotificationTemplateSummary;
|
|
14529
14603
|
export type NotificationTypeList = import("diagonal:sdk-internal").SdkNotificationTypeList;
|
|
14530
14604
|
export type NotificationTemplateList = import("diagonal:sdk-internal").SdkNotificationTemplateList;
|
|
14605
|
+
export type NotificationTemplateEmailDraft = import("diagonal:sdk-internal").SdkNotificationTemplateEmailDraft;
|
|
14531
14606
|
export type NavigationMenu = import("diagonal:sdk-internal").SdkNavigationMenu;
|
|
14532
14607
|
export type NavigationMenuCatalog = import("diagonal:sdk-internal").SdkNavigationMenuCatalog;
|
|
14533
14608
|
export type SystemSettingsPage = import("diagonal:sdk-internal").SdkSystemSettingsPage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ResourceKeyWith } from '../data';
|
|
2
2
|
import type { ContentDocument } from '../input';
|
|
3
|
-
|
|
3
|
+
import type { DeepReadonly, Liquid, StaticLiquid } from '../liquid';
|
|
4
|
+
export declare const SDK_VERSION = 75;
|
|
4
5
|
export interface WorkspaceSystemFields {
|
|
5
6
|
"ai_custom_system_prompt": string | null;
|
|
6
7
|
"brand_kit": {
|
|
@@ -739,10 +740,14 @@ export interface MailSendInput {
|
|
|
739
740
|
cc?: Array<string> | null;
|
|
740
741
|
bcc?: Array<string> | null;
|
|
741
742
|
replyTo?: Array<string> | null;
|
|
742
|
-
subject:
|
|
743
|
+
subject: Liquid;
|
|
743
744
|
emailLayout?: string | null;
|
|
745
|
+
/**
|
|
746
|
+
* A value composed from other values fails the compile: the layout can render it as Liquid.
|
|
747
|
+
* @liquidSlots $references
|
|
748
|
+
*/
|
|
744
749
|
layoutData?: {
|
|
745
|
-
content?:
|
|
750
|
+
content?: Liquid;
|
|
746
751
|
[key: string]: unknown;
|
|
747
752
|
};
|
|
748
753
|
records?: Array<{
|
|
@@ -880,10 +885,14 @@ export interface NotificationSendInput {
|
|
|
880
885
|
resource: ResourceKeyWith<"notifiable">;
|
|
881
886
|
relations?: Array<string>;
|
|
882
887
|
record: string;
|
|
883
|
-
subject:
|
|
888
|
+
subject: Liquid;
|
|
884
889
|
emailLayout?: string | null;
|
|
890
|
+
/**
|
|
891
|
+
* A value composed from other values fails the compile: the layout can render it as Liquid.
|
|
892
|
+
* @liquidSlots $references
|
|
893
|
+
*/
|
|
885
894
|
layoutData?: {
|
|
886
|
-
content?:
|
|
895
|
+
content?: Liquid;
|
|
887
896
|
[key: string]: unknown;
|
|
888
897
|
};
|
|
889
898
|
attachments?: Array<string> | null;
|
|
@@ -2211,7 +2220,7 @@ export declare const mail: {
|
|
|
2211
2220
|
/** Find tracked emails by recipient, linked record, subject, sender, status, or date, newest first, with the delivery status of each recipient, including hard and soft bounces. Searches without a record, or that include the record's current addresses, require a Run As identity with the Manage Notifications permission */
|
|
2212
2221
|
search: (input: MailSearchInput) => Promise<MailSearchOutput>;
|
|
2213
2222
|
/** Send an email */
|
|
2214
|
-
send: (input: MailSendInput) => Promise<MailSendOutput>;
|
|
2223
|
+
send: <const I extends DeepReadonly<MailSendInput>>(input: StaticLiquid<I, MailSendInput>) => Promise<MailSendOutput>;
|
|
2215
2224
|
/** Send an email using a notification type and template */
|
|
2216
2225
|
sendNotification: (input: MailSendNotificationInput) => Promise<MailSendNotificationOutput>;
|
|
2217
2226
|
};
|
|
@@ -2237,7 +2246,7 @@ export declare const money: {
|
|
|
2237
2246
|
};
|
|
2238
2247
|
export declare const notification: {
|
|
2239
2248
|
/** Send a notification email to a notifiable record */
|
|
2240
|
-
send: (input: NotificationSendInput) => Promise<NotificationSendOutput>;
|
|
2249
|
+
send: <const I extends DeepReadonly<NotificationSendInput>>(input: StaticLiquid<I, NotificationSendInput>) => Promise<NotificationSendOutput>;
|
|
2241
2250
|
/** Find records with filters and send each record’s notification to the type’s configured recipient resource */
|
|
2242
2251
|
sendBulkNotifications: (input: NotificationSendBulkNotificationsInput) => Promise<NotificationSendBulkNotificationsOutput>;
|
|
2243
2252
|
/** Send a notification template to a full record of the type’s recipient resource */
|
package/dist/workflow/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { HostError, WorkflowFailure, fail, validationError } from './errors';
|
|
|
3
3
|
export type { HostFailure } from './errors';
|
|
4
4
|
export { invoke, setTransport, type HostTransport } from './transport';
|
|
5
5
|
export { transaction } from './transaction';
|
|
6
|
+
export type { Liquid, declaredInput } from './liquid';
|
|
6
7
|
export { data } from './data';
|
|
7
8
|
export { mail, notification, sms } from './notifications';
|
|
8
9
|
export { workspace } from './workspace-values';
|
|
@@ -12,16 +13,23 @@ export * from './generated/capabilities';
|
|
|
12
13
|
/** The embedding host selects its execution context through its supplied declarations. */
|
|
13
14
|
export interface ScriptHostContext {
|
|
14
15
|
}
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Declaration-merged by the generated workspace module with one entry per resource.
|
|
18
|
+
* @augmentable
|
|
19
|
+
*/
|
|
16
20
|
export interface WorkspaceResources {
|
|
17
21
|
}
|
|
18
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Declaration-merged by the workspace's field definitions with each key's value type.
|
|
24
|
+
* @augmentable
|
|
25
|
+
*/
|
|
19
26
|
export interface WorkspaceFieldCatalog {
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Declaration-merged by the generated workspace module with one entry per notification type:
|
|
23
30
|
* its id, the unions of its template ids (all, email-enabled, and SMS-enabled), and the shape
|
|
24
31
|
* of its variables.
|
|
32
|
+
* @augmentable
|
|
25
33
|
*/
|
|
26
34
|
export interface WorkspaceNotificationTypes {
|
|
27
35
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare const liquidBrand: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* The key under which a checked capability parameter carries its declared input type, so that a
|
|
4
|
+
* tool such as the editor outline can read the fields that the capability declares.
|
|
5
|
+
*/
|
|
6
|
+
export declare const declaredInput: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Text that the task renders as a Liquid template, such as the body of an email. Write it as fixed
|
|
9
|
+
* text, and pass each value as a reference: a value written into the text would be evaluated as
|
|
10
|
+
* Liquid, so `{{ workspace.name }}` in submitted data would render.
|
|
11
|
+
*/
|
|
12
|
+
export type Liquid = string & {
|
|
13
|
+
readonly [liquidBrand]?: true;
|
|
14
|
+
};
|
|
15
|
+
/** The text that the type check shows for a Liquid field whose value is not fixed text. */
|
|
16
|
+
type FixedTextHint = 'Write fixed text here. Put each value in a reference and write {{ ref.<key> }}.';
|
|
17
|
+
type IsLiquid<T> = [T] extends [string] ? typeof liquidBrand extends keyof T ? true : false : false;
|
|
18
|
+
/**
|
|
19
|
+
* A string literal, or a union of string literals. A template literal type such as `Hi ${string}`
|
|
20
|
+
* is not fixed: Record gives it an index signature. StaticFields passes a value without null and
|
|
21
|
+
* undefined, so an optional value is fixed only when its string is. `never` is the value `undefined`
|
|
22
|
+
* alone, which is fixed.
|
|
23
|
+
*/
|
|
24
|
+
type IsFixed<T> = [T] extends [never] ? true : false extends FixedMember<T> ? false : true;
|
|
25
|
+
/**
|
|
26
|
+
* Whether each member of `T` is fixed, member by member: a Record of the whole union would require
|
|
27
|
+
* the key of each literal member, so one literal would hide a template literal beside it.
|
|
28
|
+
*/
|
|
29
|
+
type FixedMember<T> = T extends string ? string extends T ? false : {} extends Record<T, 1> ? false : true : true;
|
|
30
|
+
/** The input of a capability call, deeply readonly, so a `const` type parameter can infer it. */
|
|
31
|
+
export type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer E)[] ? readonly DeepReadonly<E>[] : T extends object ? {
|
|
32
|
+
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
33
|
+
} : T;
|
|
34
|
+
/**
|
|
35
|
+
* The input `I` of a capability call whose declared input is `D`, with each value of a Liquid field
|
|
36
|
+
* that is not fixed text replaced by the hint, so the call fails the type check at that value.
|
|
37
|
+
*/
|
|
38
|
+
export type StaticLiquid<I, D> = StaticFields<I, D> & {
|
|
39
|
+
readonly [declaredInput]?: D;
|
|
40
|
+
};
|
|
41
|
+
type StaticFields<I, D> = {
|
|
42
|
+
[K in keyof I]: K extends keyof NonNullable<D> ? IsLiquid<NonNullable<NonNullable<D>[K]>> extends true ? IsFixed<NonNullable<I[K]>> extends true ? I[K] : FixedTextHint : I[K] extends readonly unknown[] ? I[K] : NonNullable<I[K]> extends object ? StaticFields<I[K], NonNullable<D>[K]> : I[K] : I[K];
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -30,7 +30,7 @@ type NotificationInput<I, T, Channel extends 'template' | 'emailTemplate' | 'sms
|
|
|
30
30
|
export declare const mail: {
|
|
31
31
|
sendNotification: <T extends NotificationTypeKey>(input: NotificationInput<MailSendNotificationInput, T, "emailTemplate">) => Promise<MailSendNotificationOutput>;
|
|
32
32
|
search: (input: import("./index").MailSearchInput) => Promise<import("./index").MailSearchOutput>;
|
|
33
|
-
send: (input: import("./index").MailSendInput) => Promise<import("./index").MailSendOutput>;
|
|
33
|
+
send: <const I extends import("./liquid").DeepReadonly<import("./index").MailSendInput>>(input: import("./liquid").StaticLiquid<I, import("./index").MailSendInput>) => Promise<import("./index").MailSendOutput>;
|
|
34
34
|
};
|
|
35
35
|
export declare const notification: {
|
|
36
36
|
sendNotification: <T extends NotificationTypeKey>(input: NotificationInput<NotificationSendNotificationInput, T>) => Promise<boolean>;
|
|
@@ -40,7 +40,7 @@ export declare const notification: {
|
|
|
40
40
|
setConsent: <R extends NotificationSetConsentInput["resource"]>(input: Omit<NotificationSetConsentInput, "resource"> & {
|
|
41
41
|
resource: R;
|
|
42
42
|
}) => Promise<NotificationSetConsentOutput>;
|
|
43
|
-
send: (input: import("./index").NotificationSendInput) => Promise<import("./index").NotificationSendOutput>;
|
|
43
|
+
send: <const I extends import("./liquid").DeepReadonly<import("./index").NotificationSendInput>>(input: import("./liquid").StaticLiquid<I, import("./index").NotificationSendInput>) => Promise<import("./index").NotificationSendOutput>;
|
|
44
44
|
};
|
|
45
45
|
export declare const sms: {
|
|
46
46
|
sendNotification: <T extends NotificationTypeKey>(input: NotificationInput<SmsSendNotificationInput, T, "smsTemplate">) => Promise<SmsSendNotificationOutput>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diagonal-hq/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
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": {
|
|
@@ -43,5 +43,13 @@
|
|
|
43
43
|
"dist/workflow",
|
|
44
44
|
"LICENSE",
|
|
45
45
|
"README.md"
|
|
46
|
-
]
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"bun": "1.4.4"
|
|
49
|
+
},
|
|
50
|
+
"optionalDependencies": {
|
|
51
|
+
"@diagonal-hq/workflow-script-compiler-darwin-arm64": "0.1.0-h40b8d96b5efe",
|
|
52
|
+
"@diagonal-hq/workflow-script-compiler-linux-x64": "0.1.0-h40b8d96b5efe",
|
|
53
|
+
"@diagonal-hq/workflow-script-compiler-linux-arm64": "0.1.0-h40b8d96b5efe"
|
|
54
|
+
}
|
|
47
55
|
}
|