@diagonal-hq/workflows 0.8.0 → 0.10.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/chunks/{chunk-FDU4BQPD.js → chunk-B2ACQBED.js} +3 -3
- package/dist/generated/capabilities.d.ts +26 -19
- package/dist/index.d.ts +10 -2
- package/dist/index.js +1 -1
- package/dist/liquid.d.ts +44 -0
- package/dist/notifications.d.ts +2 -2
- package/dist/profiles/test.js +1 -1
- package/dist/workspace-values.d.ts +2 -2
- package/package.json +1 -1
|
@@ -97,7 +97,7 @@ function isFailure(value2) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// packages/workflows/src/generated/capabilities.ts
|
|
100
|
-
var SDK_VERSION =
|
|
100
|
+
var SDK_VERSION = 76;
|
|
101
101
|
var ai = {
|
|
102
102
|
/** Ask a decisions model typed questions about some content and get labelled answers with their probabilities */
|
|
103
103
|
decide: (input) => invoke("ai.decide", input),
|
|
@@ -334,7 +334,7 @@ var text = {
|
|
|
334
334
|
/** Hash a text value */
|
|
335
335
|
hash: (input) => invoke("text.hash", input),
|
|
336
336
|
/** Generate a random UUID v7 */
|
|
337
|
-
randomUuid: (input) => invoke("text.random_uuid", input),
|
|
337
|
+
randomUuid: (input = {}) => invoke("text.random_uuid", input),
|
|
338
338
|
/** Convert a plain text string into rich Content */
|
|
339
339
|
toContent: (input) => invoke("text.to_content", input)
|
|
340
340
|
};
|
|
@@ -404,7 +404,7 @@ var workspace = {
|
|
|
404
404
|
/** Get the value of a field in a workspace */
|
|
405
405
|
value: (input) => invoke("workspace.value", input),
|
|
406
406
|
/** Get all workspace field values as a dictionary */
|
|
407
|
-
values: (input) => invoke("workspace.values", input)
|
|
407
|
+
values: (input = {}) => invoke("workspace.values", input)
|
|
408
408
|
};
|
|
409
409
|
|
|
410
410
|
// packages/workflows/src/data.ts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ResourceKeyWith } from "../data.js";
|
|
2
2
|
import type { ContentDocument } from "../input.js";
|
|
3
|
-
|
|
3
|
+
import type { DeepReadonly, Liquid, StaticLiquid } from "../liquid.js";
|
|
4
|
+
export declare const SDK_VERSION = 76;
|
|
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;
|
|
@@ -955,6 +964,8 @@ export interface NumberFormatInput {
|
|
|
955
964
|
}
|
|
956
965
|
export type NumberFormatOutput = string;
|
|
957
966
|
export interface PackageInstallInputInput {
|
|
967
|
+
package_id: string;
|
|
968
|
+
key: string;
|
|
958
969
|
}
|
|
959
970
|
export type PackageInstallInputOutput = unknown;
|
|
960
971
|
export interface PageUrlInput {
|
|
@@ -1802,8 +1813,7 @@ export interface TextHashInput {
|
|
|
1802
1813
|
value: string;
|
|
1803
1814
|
}
|
|
1804
1815
|
export type TextHashOutput = string;
|
|
1805
|
-
export
|
|
1806
|
-
}
|
|
1816
|
+
export type TextRandomUuidInput = Record<string, never>;
|
|
1807
1817
|
export type TextRandomUuidOutput = string;
|
|
1808
1818
|
export interface TextToContentInput {
|
|
1809
1819
|
value: string;
|
|
@@ -1861,11 +1871,9 @@ export interface TiptapParseInput {
|
|
|
1861
1871
|
placeholder?: string;
|
|
1862
1872
|
}
|
|
1863
1873
|
export type TiptapParseOutput = unknown;
|
|
1864
|
-
export
|
|
1865
|
-
}
|
|
1874
|
+
export type TransactionBeginInput = Record<string, never>;
|
|
1866
1875
|
export type TransactionBeginOutput = null;
|
|
1867
|
-
export
|
|
1868
|
-
}
|
|
1876
|
+
export type TransactionCommitInput = Record<string, never>;
|
|
1869
1877
|
export type TransactionCommitOutput = null;
|
|
1870
1878
|
export interface TransactionRollbackInput {
|
|
1871
1879
|
error?: {
|
|
@@ -2088,8 +2096,7 @@ export interface WorkspaceValueInput {
|
|
|
2088
2096
|
defaultValue?: unknown;
|
|
2089
2097
|
}
|
|
2090
2098
|
export type WorkspaceValueOutput = unknown;
|
|
2091
|
-
export
|
|
2092
|
-
}
|
|
2099
|
+
export type WorkspaceValuesInput = Record<string, never>;
|
|
2093
2100
|
export type WorkspaceValuesOutput = Record<string, unknown>;
|
|
2094
2101
|
export declare const ai: {
|
|
2095
2102
|
/** Ask a decisions model typed questions about some content and get labelled answers with their probabilities */
|
|
@@ -2211,7 +2218,7 @@ export declare const mail: {
|
|
|
2211
2218
|
/** 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
2219
|
search: (input: MailSearchInput) => Promise<MailSearchOutput>;
|
|
2213
2220
|
/** Send an email */
|
|
2214
|
-
send: (input: MailSendInput) => Promise<MailSendOutput>;
|
|
2221
|
+
send: <const I extends DeepReadonly<MailSendInput>>(input: StaticLiquid<I, MailSendInput>) => Promise<MailSendOutput>;
|
|
2215
2222
|
/** Send an email using a notification type and template */
|
|
2216
2223
|
sendNotification: (input: MailSendNotificationInput) => Promise<MailSendNotificationOutput>;
|
|
2217
2224
|
};
|
|
@@ -2237,7 +2244,7 @@ export declare const money: {
|
|
|
2237
2244
|
};
|
|
2238
2245
|
export declare const notification: {
|
|
2239
2246
|
/** Send a notification email to a notifiable record */
|
|
2240
|
-
send: (input: NotificationSendInput) => Promise<NotificationSendOutput>;
|
|
2247
|
+
send: <const I extends DeepReadonly<NotificationSendInput>>(input: StaticLiquid<I, NotificationSendInput>) => Promise<NotificationSendOutput>;
|
|
2241
2248
|
/** Find records with filters and send each record’s notification to the type’s configured recipient resource */
|
|
2242
2249
|
sendBulkNotifications: (input: NotificationSendBulkNotificationsInput) => Promise<NotificationSendBulkNotificationsOutput>;
|
|
2243
2250
|
/** Send a notification template to a full record of the type’s recipient resource */
|
|
@@ -2328,7 +2335,7 @@ export declare const text: {
|
|
|
2328
2335
|
/** Hash a text value */
|
|
2329
2336
|
hash: (input: TextHashInput) => Promise<TextHashOutput>;
|
|
2330
2337
|
/** Generate a random UUID v7 */
|
|
2331
|
-
randomUuid: (input
|
|
2338
|
+
randomUuid: (input?: TextRandomUuidInput) => Promise<TextRandomUuidOutput>;
|
|
2332
2339
|
/** Convert a plain text string into rich Content */
|
|
2333
2340
|
toContent: (input: TextToContentInput) => Promise<TextToContentOutput>;
|
|
2334
2341
|
};
|
|
@@ -2358,9 +2365,9 @@ export declare const tiptap: {
|
|
|
2358
2365
|
};
|
|
2359
2366
|
export declare const transaction: {
|
|
2360
2367
|
/** Transaction control for transaction(). */
|
|
2361
|
-
begin: (input
|
|
2368
|
+
begin: (input?: TransactionBeginInput) => Promise<TransactionBeginOutput>;
|
|
2362
2369
|
/** Transaction control for transaction(). */
|
|
2363
|
-
commit: (input
|
|
2370
|
+
commit: (input?: TransactionCommitInput) => Promise<TransactionCommitOutput>;
|
|
2364
2371
|
/** Transaction control for transaction(). */
|
|
2365
2372
|
rollback: (input: TransactionRollbackInput) => Promise<TransactionRollbackOutput>;
|
|
2366
2373
|
};
|
|
@@ -2406,5 +2413,5 @@ export declare const workspace: {
|
|
|
2406
2413
|
/** Get the value of a field in a workspace */
|
|
2407
2414
|
value: (input: WorkspaceValueInput) => Promise<WorkspaceValueOutput>;
|
|
2408
2415
|
/** Get all workspace field values as a dictionary */
|
|
2409
|
-
values: (input
|
|
2416
|
+
values: (input?: WorkspaceValuesInput) => Promise<WorkspaceValuesOutput>;
|
|
2410
2417
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { HostError, WorkflowFailure, fail, validationError } from "./errors.js";
|
|
|
3
3
|
export type { HostFailure } from "./errors.js";
|
|
4
4
|
export { invoke, setTransport, type HostTransport } from "./transport.js";
|
|
5
5
|
export { transaction } from "./transaction.js";
|
|
6
|
+
export type { Liquid, declaredInput } from "./liquid.js";
|
|
6
7
|
export { data } from "./data.js";
|
|
7
8
|
export { mail, notification, sms } from "./notifications.js";
|
|
8
9
|
export { workspace } from "./workspace-values.js";
|
|
@@ -12,16 +13,23 @@ export * from "./generated/capabilities.js";
|
|
|
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
|
}
|
package/dist/index.js
CHANGED
package/dist/liquid.d.ts
ADDED
|
@@ -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 {};
|
package/dist/notifications.d.ts
CHANGED
|
@@ -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.js").MailSearchInput) => Promise<import("./index.js").MailSearchOutput>;
|
|
33
|
-
send: (input: import("./index.js").MailSendInput) => Promise<import("./index.js").MailSendOutput>;
|
|
33
|
+
send: <const I extends import("./liquid.js").DeepReadonly<import("./index.js").MailSendInput>>(input: import("./liquid.js").StaticLiquid<I, import("./index.js").MailSendInput>) => Promise<import("./index.js").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.js").NotificationSendInput) => Promise<import("./index.js").NotificationSendOutput>;
|
|
43
|
+
send: <const I extends import("./liquid.js").DeepReadonly<import("./index.js").NotificationSendInput>>(input: import("./liquid.js").StaticLiquid<I, import("./index.js").NotificationSendInput>) => Promise<import("./index.js").NotificationSendOutput>;
|
|
44
44
|
};
|
|
45
45
|
export declare const sms: {
|
|
46
46
|
sendNotification: <T extends NotificationTypeKey>(input: NotificationInput<SmsSendNotificationInput, T, "smsTemplate">) => Promise<SmsSendNotificationOutput>;
|
package/dist/profiles/test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WorkspaceSystemFields } from "./generated/capabilities.js";
|
|
1
|
+
import { type WorkspaceSystemFields, type WorkspaceValuesInput } from "./generated/capabilities.js";
|
|
2
2
|
import type { WorkspaceFieldCatalog } from "./index.js";
|
|
3
3
|
type Fields = Omit<WorkspaceSystemFields, keyof WorkspaceFieldCatalog> & WorkspaceFieldCatalog;
|
|
4
4
|
type Property<T, K extends string> = T extends null | undefined ? never : T extends readonly (infer Item)[] ? K extends `${number}` ? K extends keyof T ? T[K] : Item : unknown : T extends object ? K extends keyof T ? T[K] : unknown : unknown;
|
|
@@ -27,7 +27,7 @@ export declare const workspace: {
|
|
|
27
27
|
key: K;
|
|
28
28
|
value?: WriteValue<NoInfer<K>>;
|
|
29
29
|
}) => Promise<WriteValue<K>>;
|
|
30
|
-
values: (input?:
|
|
30
|
+
values: (input?: WorkspaceValuesInput) => Promise<WorkspaceValues>;
|
|
31
31
|
setValues: <V extends Record<string, unknown> = Record<never, never>>(input: {
|
|
32
32
|
values?: V & WrittenValues<NoInfer<V>>;
|
|
33
33
|
}) => Promise<WrittenValues<V>>;
|
package/package.json
CHANGED