@diagonal-hq/cli 0.28.4 → 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.
@@ -1,6 +1,7 @@
1
1
  import type { ResourceKeyWith } from '../data';
2
2
  import type { ContentDocument } from '../input';
3
- export declare const SDK_VERSION = 71;
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: string;
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?: unknown;
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: string;
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?: unknown;
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 */
@@ -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
- /** Declaration-merged by the generated workspace module with one entry per resource. */
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
- /** Declaration-merged by the workspace's field definitions with each key's value type. */
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.28.4",
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
  }