@composable-os/sdk 0.0.0-stage → 0.1.0-beta.10
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/LICENSE +109 -0
- package/dist/allowance.d.ts +198 -0
- package/dist/allowance.js +374 -0
- package/dist/automation-check.d.ts +38 -0
- package/dist/automation-check.js +454 -0
- package/dist/automation.d.ts +767 -0
- package/dist/automation.js +303 -0
- package/dist/behaviour.d.ts +3 -0
- package/dist/behaviour.js +153 -0
- package/dist/capacity.d.ts +77 -0
- package/dist/capacity.js +127 -0
- package/dist/contract.d.ts +819 -0
- package/dist/contract.js +42 -0
- package/dist/document.d.ts +211 -0
- package/dist/document.js +726 -0
- package/dist/field-types.d.ts +11 -0
- package/dist/field-types.js +98 -0
- package/dist/formula/ast.d.ts +67 -0
- package/dist/formula/ast.js +22 -0
- package/dist/formula/compile.d.ts +37 -0
- package/dist/formula/compile.js +379 -0
- package/dist/formula/index.d.ts +3 -0
- package/dist/formula/index.js +4 -0
- package/dist/formula/parser.d.ts +13 -0
- package/dist/formula/parser.js +365 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +24 -0
- package/dist/manifest.d.ts +1596 -0
- package/dist/manifest.js +1420 -0
- package/dist/media.d.ts +41 -0
- package/dist/media.js +90 -0
- package/dist/permissions.d.ts +17 -0
- package/dist/permissions.js +44 -0
- package/dist/recurring.d.ts +114 -0
- package/dist/recurring.js +173 -0
- package/dist/renamed.d.ts +16 -0
- package/dist/renamed.js +59 -0
- package/dist/rich-text-fixture.d.ts +121 -0
- package/dist/rich-text-fixture.js +67 -0
- package/dist/rich-text.d.ts +48 -0
- package/dist/rich-text.js +184 -0
- package/dist/runtime.d.ts +95 -0
- package/dist/runtime.js +312 -0
- package/dist/sellable.d.ts +253 -0
- package/dist/sellable.js +593 -0
- package/dist/slug.d.ts +11 -0
- package/dist/slug.js +23 -0
- package/dist/states.d.ts +238 -0
- package/dist/states.js +315 -0
- package/dist/testing.d.ts +151 -0
- package/dist/testing.js +679 -0
- package/dist/unique.d.ts +20 -0
- package/dist/unique.js +58 -0
- package/package.json +34 -4
- package/src/allowance.ts +522 -0
- package/src/automation-check.ts +534 -0
- package/src/automation.ts +743 -0
- package/src/behaviour.ts +215 -0
- package/src/capacity.ts +201 -0
- package/src/contract.ts +884 -0
- package/src/document.ts +935 -0
- package/src/field-types.ts +111 -0
- package/src/formula/ast.ts +72 -0
- package/src/formula/compile.ts +454 -0
- package/src/formula/index.ts +4 -0
- package/src/formula/parser.ts +417 -0
- package/src/index.ts +36 -0
- package/src/manifest.ts +1709 -0
- package/src/media.ts +108 -0
- package/src/permissions.ts +60 -0
- package/src/recurring.ts +321 -0
- package/src/renamed.ts +63 -0
- package/src/rich-text-fixture.ts +68 -0
- package/src/rich-text.ts +221 -0
- package/src/runtime.ts +410 -0
- package/src/sellable.ts +888 -0
- package/src/slug.ts +25 -0
- package/src/states.ts +484 -0
- package/src/testing.ts +847 -0
- package/src/unique.ts +81 -0
- package/README.md +0 -3
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ExtensionContext, type GatekeeperModuleName, type StageType, type ViewFilter } from "./contract.ts";
|
|
3
|
+
/** `"3 days"`, `"90 minutes"`, `"1 week"`, or milliseconds. */
|
|
4
|
+
export type Duration = number | `${number} ${"second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days" | "week" | "weeks"}`;
|
|
5
|
+
/** Milliseconds in a duration. Throws on a malformed one. */
|
|
6
|
+
export declare function durationMs(duration: Duration): number;
|
|
7
|
+
/** Record lifecycle events every core and extension object emits after commit. */
|
|
8
|
+
export declare const RECORD_EVENTS: readonly ["created", "updated", "deleted", "restored"];
|
|
9
|
+
export type RecordEventType = (typeof RECORD_EVENTS)[number];
|
|
10
|
+
/**
|
|
11
|
+
* A value a `fieldChanged` trigger compares a field's before / after value with: a literal, one
|
|
12
|
+
* of several literals, or (for an object's stage relation) the type of the stage.
|
|
13
|
+
*/
|
|
14
|
+
export type ValueMatch = string | number | boolean | null | {
|
|
15
|
+
in: readonly (string | number | boolean | null)[];
|
|
16
|
+
} | {
|
|
17
|
+
stageType: StageType;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Sync events (stage 6, ADR 0112): what the built-in email and calendar sync records when it
|
|
21
|
+
* writes, updates or removes an activity. `meeting.scheduled` is a new meeting (the sync service
|
|
22
|
+
* records it as `meeting.created`; both names match it).
|
|
23
|
+
*/
|
|
24
|
+
export declare const SYNC_EVENT_TYPES: readonly ["email.received", "email.sent", "email.deleted", "meeting.scheduled", "meeting.created", "meeting.updated", "meeting.cancelled"];
|
|
25
|
+
export type SyncEventType = (typeof SYNC_EVENT_TYPES)[number];
|
|
26
|
+
/**
|
|
27
|
+
* What starts a run. Inbound webhooks and sync events (stage 6b) come from integrations; the host
|
|
28
|
+
* dispatches each kind of event to its own trigger source.
|
|
29
|
+
*/
|
|
30
|
+
export type AutomationTrigger = {
|
|
31
|
+
/** A record of `object` was created, updated, deleted (to Trash) or restored. */
|
|
32
|
+
type: "record";
|
|
33
|
+
/** Core (`person`, `organisation`, `task`, `activity`) or `<extension>.<object>`. */
|
|
34
|
+
object: string;
|
|
35
|
+
on: readonly RecordEventType[];
|
|
36
|
+
/**
|
|
37
|
+
* Also fire for records changed by bulk operations (imports, `*Many`, backfills). Off by
|
|
38
|
+
* default: one import must not start thousands of runs (cost audit U3).
|
|
39
|
+
*/
|
|
40
|
+
includeBulk?: boolean;
|
|
41
|
+
} | {
|
|
42
|
+
/** A field of a record of `object` changed, optionally from / to given values. */
|
|
43
|
+
type: "fieldChanged";
|
|
44
|
+
object: string;
|
|
45
|
+
field: string;
|
|
46
|
+
from?: ValueMatch;
|
|
47
|
+
to?: ValueMatch;
|
|
48
|
+
includeBulk?: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
/**
|
|
51
|
+
* A cron expression (5 fields: minute hour day-of-month month day-of-week), evaluated in
|
|
52
|
+
* the deployment's automation timezone (Settings → Automations). The finest granularity
|
|
53
|
+
* is the host's cron tick (one minute).
|
|
54
|
+
*/
|
|
55
|
+
type: "schedule";
|
|
56
|
+
cron: string;
|
|
57
|
+
} | {
|
|
58
|
+
/**
|
|
59
|
+
* `offsetDays` days after (positive) or before (negative) a date field of each live record
|
|
60
|
+
* of `object`; 0 is the day itself. Evaluated once a day, in the automation timezone; or,
|
|
61
|
+
* with `zoneField`, in each record's own time zone (ADR 0460): the day of the date and
|
|
62
|
+
* "today" are both that zone's, and the run starts in the first hour of that local day.
|
|
63
|
+
*/
|
|
64
|
+
type: "dateRelative";
|
|
65
|
+
object: string;
|
|
66
|
+
field: string;
|
|
67
|
+
offsetDays: number;
|
|
68
|
+
/** A `timezone` field of `object`: count days in the zone each record names. */
|
|
69
|
+
zoneField?: string;
|
|
70
|
+
} | {
|
|
71
|
+
/**
|
|
72
|
+
* A person starts it from a record page (a button) or for selected records on a list (a
|
|
73
|
+
* bulk action, when `bulk` is true).
|
|
74
|
+
*/
|
|
75
|
+
type: "manual";
|
|
76
|
+
object: string;
|
|
77
|
+
/** The button's label, e.g. "Send renewal reminder". */
|
|
78
|
+
label: string;
|
|
79
|
+
bulk?: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
/** A pending action was decided in the Approvals inbox. */
|
|
82
|
+
type: "approvalDecided";
|
|
83
|
+
/** Default `any`. */
|
|
84
|
+
decision?: "approved" | "rejected" | "any";
|
|
85
|
+
/** Only actions of this operation (e.g. `record.update`). */
|
|
86
|
+
operation?: string;
|
|
87
|
+
/** Only actions touching records of this object. */
|
|
88
|
+
object?: string;
|
|
89
|
+
} | {
|
|
90
|
+
/**
|
|
91
|
+
* A verified delivery to an inbound webhook endpoint (the `webhook` gatekeeper, ADR 0113).
|
|
92
|
+
* The run gets the typed event in `event.integration` (`payload.payload` is the sender's
|
|
93
|
+
* JSON).
|
|
94
|
+
*/
|
|
95
|
+
type: "webhook";
|
|
96
|
+
/** The endpoint id an admin set up (`webhook://endpoint/<id>`), e.g. `stripe-billing`. */
|
|
97
|
+
endpoint: string;
|
|
98
|
+
/** Only these event types (e.g. `invoice.paid`). Omitted: every event. */
|
|
99
|
+
events?: readonly string[];
|
|
100
|
+
} | {
|
|
101
|
+
/**
|
|
102
|
+
* Email or calendar sync wrote, changed or removed an activity (ADR 0112). The trigger
|
|
103
|
+
* record is that activity; the event carries ids only, never content.
|
|
104
|
+
*/
|
|
105
|
+
type: "syncEvent";
|
|
106
|
+
event: SyncEventType;
|
|
107
|
+
/**
|
|
108
|
+
* Only when the email or meeting is linked to a known `person`, a known `organisation`, or
|
|
109
|
+
* (the default) `either`. Sync records activities only for known people and organisations.
|
|
110
|
+
*/
|
|
111
|
+
from?: "person" | "organisation" | "either";
|
|
112
|
+
};
|
|
113
|
+
export type AutomationTriggerType = AutomationTrigger["type"];
|
|
114
|
+
export declare const AUTOMATION_TRIGGER_TYPES: readonly ["record", "fieldChanged", "schedule", "dateRelative", "manual", "approvalDecided", "webhook", "syncEvent"];
|
|
115
|
+
/**
|
|
116
|
+
* A connection an automation needs (ADR 0051, ADR 0170). When the automation is approved or
|
|
117
|
+
* installed, a person binds each one to a connection they own or to an org connection; steps then
|
|
118
|
+
* reach it with `ctx.gatekeeper(gatekeeper).call(id, resource, method, ...args)`, acting as that
|
|
119
|
+
* connection's owner. Until every declared connection is bound, the automation does not run.
|
|
120
|
+
*/
|
|
121
|
+
export interface AutomationConnection {
|
|
122
|
+
/** camelCase, unique within the automation: what steps pass as the connection id. */
|
|
123
|
+
id: string;
|
|
124
|
+
/** The gatekeeper (host module) it is a connection of; declare it in permissions.modules. */
|
|
125
|
+
gatekeeper: GatekeeperModuleName;
|
|
126
|
+
/** Why it needs it, shown to the person binding it ("Send the welcome email"). */
|
|
127
|
+
purpose: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Who a notification goes to. `{ field }` is a `user` field of the trigger record (e.g. a deal's
|
|
131
|
+
* `owner`); `{ managerOf }` is the manager of the user in that field, or the admins when the
|
|
132
|
+
* deployment has no manager for them (the Deals README says so); `admins` is every admin.
|
|
133
|
+
*/
|
|
134
|
+
export type Recipient = {
|
|
135
|
+
field: string;
|
|
136
|
+
} | {
|
|
137
|
+
managerOf: string;
|
|
138
|
+
} | {
|
|
139
|
+
userId: string;
|
|
140
|
+
} | "admins" | "actor";
|
|
141
|
+
/** One kind of record a step creates or changes. */
|
|
142
|
+
export interface WriteIntent {
|
|
143
|
+
/** Core or `<extension>.<object>`. */
|
|
144
|
+
object: string;
|
|
145
|
+
/** Default `create`. */
|
|
146
|
+
action?: "create" | "update" | "delete";
|
|
147
|
+
/** How many records, when fixed (e.g. 3 onboarding tasks). Omitted: "one or more". */
|
|
148
|
+
count?: number;
|
|
149
|
+
/** Titles of the records created, when fixed: shown in the diagram. */
|
|
150
|
+
titles?: readonly string[];
|
|
151
|
+
/** For tasks: who they are assigned to. */
|
|
152
|
+
assignTo?: Recipient;
|
|
153
|
+
/** Linked to the trigger record. Default true for tasks and activities. */
|
|
154
|
+
linkedToTrigger?: boolean;
|
|
155
|
+
}
|
|
156
|
+
/** A notification a step sends (through `notification.send`). */
|
|
157
|
+
export interface NotifyIntent {
|
|
158
|
+
to: Recipient;
|
|
159
|
+
/** The title as written, with `{record}` standing for the trigger record's title. */
|
|
160
|
+
message: string;
|
|
161
|
+
/** The body as written, when it sends one (shortened in the host summary). */
|
|
162
|
+
body?: string;
|
|
163
|
+
}
|
|
164
|
+
interface StepBase {
|
|
165
|
+
/** Unique within the automation, camelCase: what `run` passes to `step.*`. */
|
|
166
|
+
name: string;
|
|
167
|
+
/** Short label for the diagram ("Create onboarding tasks"). Default: the name, humanised. */
|
|
168
|
+
label?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A declared step. `do` steps run extension code; `sleep` and `waitForEvent` are durable waits;
|
|
172
|
+
* a `condition` is a branch `run` takes in code, declared so the diagram shows it (the steps
|
|
173
|
+
* after it run only when it holds).
|
|
174
|
+
*/
|
|
175
|
+
export type AutomationStep = (StepBase & {
|
|
176
|
+
kind?: "do";
|
|
177
|
+
/** Objects it reads. */
|
|
178
|
+
reads?: readonly string[];
|
|
179
|
+
writes?: readonly WriteIntent[];
|
|
180
|
+
notifies?: readonly NotifyIntent[];
|
|
181
|
+
/** Further operations it calls (e.g. `query.sql`), for the permissions summary. */
|
|
182
|
+
calls?: readonly string[];
|
|
183
|
+
}) | (StepBase & {
|
|
184
|
+
kind: "sleep";
|
|
185
|
+
duration: Duration;
|
|
186
|
+
}) | (StepBase & {
|
|
187
|
+
kind: "waitForEvent";
|
|
188
|
+
/** The event type `step.waitForEvent` waits for. */
|
|
189
|
+
event: string;
|
|
190
|
+
/** Default 7 days. */
|
|
191
|
+
timeout?: Duration;
|
|
192
|
+
}) | (StepBase & {
|
|
193
|
+
kind: "condition";
|
|
194
|
+
/** The question, e.g. "Any onboarding task still open?". */
|
|
195
|
+
label: string;
|
|
196
|
+
/**
|
|
197
|
+
* The condition as the summary says it after "if", e.g. "any of those tasks are still
|
|
198
|
+
* open". Default: the label, lower-cased, without its question mark.
|
|
199
|
+
*/
|
|
200
|
+
clause?: string;
|
|
201
|
+
});
|
|
202
|
+
/** What happens when a person rejects a change a run queued for approval. Default `stop`. */
|
|
203
|
+
export type OnRejected = "stop" | "continue" | {
|
|
204
|
+
notify: Recipient;
|
|
205
|
+
message?: string;
|
|
206
|
+
};
|
|
207
|
+
/** Per-automation limits, within the host's maxima (Settings shows both). */
|
|
208
|
+
export interface AutomationRails {
|
|
209
|
+
/** Default 60. Above it the automation auto-pauses and admins are notified. */
|
|
210
|
+
maxRunsPerMinute?: number;
|
|
211
|
+
/** Default 500 writes an hour across all its runs. */
|
|
212
|
+
maxWritesPerHour?: number;
|
|
213
|
+
/** Seconds within which `updated` events for one record coalesce into one run. */
|
|
214
|
+
debounceSeconds?: number;
|
|
215
|
+
}
|
|
216
|
+
/** The event a run starts from, as `run` receives it. */
|
|
217
|
+
export interface AutomationEvent {
|
|
218
|
+
/** `<extension>.<automation>` */
|
|
219
|
+
automation: string;
|
|
220
|
+
runId: string;
|
|
221
|
+
trigger: AutomationTriggerType;
|
|
222
|
+
/** The trigger record (record, fieldChanged, dateRelative, manual), as read when the run started. */
|
|
223
|
+
record?: {
|
|
224
|
+
object: string;
|
|
225
|
+
id: string;
|
|
226
|
+
data: Record<string, unknown> | null;
|
|
227
|
+
/** The record's title when the run started (what `{record}` in a notification stands for). */
|
|
228
|
+
title?: string | null;
|
|
229
|
+
};
|
|
230
|
+
/** record / fieldChanged: what changed. `diff` holds changed fields only. */
|
|
231
|
+
change?: {
|
|
232
|
+
action: RecordEventType;
|
|
233
|
+
diff: Record<string, {
|
|
234
|
+
before: unknown;
|
|
235
|
+
after: unknown;
|
|
236
|
+
}>;
|
|
237
|
+
};
|
|
238
|
+
/** schedule / dateRelative: the period this run is for, e.g. `2026-11-05` or `2026-11-05T09:00`. */
|
|
239
|
+
period?: string;
|
|
240
|
+
/** manual: who started it, and every selected record for a bulk action. */
|
|
241
|
+
manual?: {
|
|
242
|
+
userId: string;
|
|
243
|
+
recordIds: string[];
|
|
244
|
+
};
|
|
245
|
+
/** approvalDecided: the decided action. */
|
|
246
|
+
approval?: {
|
|
247
|
+
actionId: string;
|
|
248
|
+
operation: string;
|
|
249
|
+
decision: "approved" | "rejected";
|
|
250
|
+
records: {
|
|
251
|
+
object: string;
|
|
252
|
+
id: string;
|
|
253
|
+
}[];
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* webhook / syncEvent: the integration event. Webhooks carry the sender's verified JSON in
|
|
257
|
+
* `payload.payload`; sync events carry ids only (`activityId`, `personIds`, `organisationIds`).
|
|
258
|
+
*/
|
|
259
|
+
integration?: {
|
|
260
|
+
eventId: string;
|
|
261
|
+
source: "webhook" | "sync";
|
|
262
|
+
type: string;
|
|
263
|
+
connectionId: string | null;
|
|
264
|
+
payload: unknown;
|
|
265
|
+
};
|
|
266
|
+
/** True in test mode: writes are simulated, waits are skipped. */
|
|
267
|
+
test: boolean;
|
|
268
|
+
}
|
|
269
|
+
/** The Workflow-shaped step API `run` receives. */
|
|
270
|
+
export interface AutomationStepApi {
|
|
271
|
+
/**
|
|
272
|
+
* Runs `fn` once, durably: its result is stored, and a run resumed after a restart or a wait
|
|
273
|
+
* gets the stored result instead of running it again. It is retried with backoff when it
|
|
274
|
+
* throws. `name` must be a declared `do` step (an intent here is checked against it).
|
|
275
|
+
*/
|
|
276
|
+
do<T>(name: string, fn: () => Promise<T> | T): Promise<T>;
|
|
277
|
+
do<T>(name: string, intent: Omit<Extract<AutomationStep, {
|
|
278
|
+
kind?: "do";
|
|
279
|
+
}>, "name" | "kind">, fn: () => Promise<T> | T): Promise<T>;
|
|
280
|
+
/** A durable wait (survives redeploys). Skipped, and shown, in test mode. */
|
|
281
|
+
sleep(name: string, duration: Duration): Promise<void>;
|
|
282
|
+
/** Waits for an event of the declared type; null on timeout. Skipped (null) in test mode. */
|
|
283
|
+
waitForEvent<T = unknown>(name: string): Promise<T | null>;
|
|
284
|
+
}
|
|
285
|
+
/** `ctx` in `run`: the extension's host modules plus notifications. */
|
|
286
|
+
export interface AutomationContext extends ExtensionContext {
|
|
287
|
+
/**
|
|
288
|
+
* Sends an in-app notification through `notification.send` (the extension needs it in
|
|
289
|
+
* `permissions.operations`). `{record}` in the title stands for the trigger record's title.
|
|
290
|
+
*/
|
|
291
|
+
notify(to: Recipient | Recipient[], message: {
|
|
292
|
+
title: string;
|
|
293
|
+
body?: string;
|
|
294
|
+
link?: "record" | "run";
|
|
295
|
+
}): Promise<{
|
|
296
|
+
sent: number;
|
|
297
|
+
}>;
|
|
298
|
+
}
|
|
299
|
+
export interface AutomationSpec<T extends AutomationTrigger = AutomationTrigger> {
|
|
300
|
+
/** Name shown in the list and on the automation page, e.g. "Won deal → onboarding". */
|
|
301
|
+
label: string;
|
|
302
|
+
/** One or two sentences for people and models: what and why. */
|
|
303
|
+
description: string;
|
|
304
|
+
trigger: T;
|
|
305
|
+
/**
|
|
306
|
+
* Declarative conditions on the trigger record (the same filter language as views), checked
|
|
307
|
+
* by the host before a run starts, and rendered in the summary.
|
|
308
|
+
*/
|
|
309
|
+
conditions?: ViewFilter;
|
|
310
|
+
/** Every step `run` may take, in order. */
|
|
311
|
+
steps: readonly AutomationStep[];
|
|
312
|
+
onRejected?: OnRejected;
|
|
313
|
+
rails?: AutomationRails;
|
|
314
|
+
/** Connections it needs, bound by a person when it is approved or installed. */
|
|
315
|
+
connections?: readonly AutomationConnection[];
|
|
316
|
+
/**
|
|
317
|
+
* `false`: installed turned off; a person turns it on under Automations (ADR 0246). Only the
|
|
318
|
+
* first install reads it; after that, on or off is the person's choice.
|
|
319
|
+
*/
|
|
320
|
+
enabled?: boolean;
|
|
321
|
+
run(event: AutomationEvent, step: AutomationStepApi, ctx: AutomationContext): Promise<unknown>;
|
|
322
|
+
}
|
|
323
|
+
export declare function defineAutomation<const T extends AutomationTrigger>(automation: AutomationSpec<T>): AutomationSpec<T>;
|
|
324
|
+
export declare const valueMatchSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodObject<{
|
|
325
|
+
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
326
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
327
|
+
stageType: z.ZodEnum<{
|
|
328
|
+
open: "open";
|
|
329
|
+
won: "won";
|
|
330
|
+
lost: "lost";
|
|
331
|
+
}>;
|
|
332
|
+
}, z.core.$strict>]>;
|
|
333
|
+
export declare const automationTriggerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
334
|
+
type: z.ZodLiteral<"record">;
|
|
335
|
+
object: z.ZodString;
|
|
336
|
+
on: z.ZodArray<z.ZodEnum<{
|
|
337
|
+
created: "created";
|
|
338
|
+
updated: "updated";
|
|
339
|
+
deleted: "deleted";
|
|
340
|
+
restored: "restored";
|
|
341
|
+
}>>;
|
|
342
|
+
includeBulk: z.ZodOptional<z.ZodBoolean>;
|
|
343
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
344
|
+
type: z.ZodLiteral<"fieldChanged">;
|
|
345
|
+
object: z.ZodString;
|
|
346
|
+
field: z.ZodString;
|
|
347
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodObject<{
|
|
348
|
+
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
349
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
350
|
+
stageType: z.ZodEnum<{
|
|
351
|
+
open: "open";
|
|
352
|
+
won: "won";
|
|
353
|
+
lost: "lost";
|
|
354
|
+
}>;
|
|
355
|
+
}, z.core.$strict>]>>;
|
|
356
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodObject<{
|
|
357
|
+
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
358
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
359
|
+
stageType: z.ZodEnum<{
|
|
360
|
+
open: "open";
|
|
361
|
+
won: "won";
|
|
362
|
+
lost: "lost";
|
|
363
|
+
}>;
|
|
364
|
+
}, z.core.$strict>]>>;
|
|
365
|
+
includeBulk: z.ZodOptional<z.ZodBoolean>;
|
|
366
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
367
|
+
type: z.ZodLiteral<"schedule">;
|
|
368
|
+
cron: z.ZodString;
|
|
369
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
370
|
+
type: z.ZodLiteral<"dateRelative">;
|
|
371
|
+
object: z.ZodString;
|
|
372
|
+
field: z.ZodString;
|
|
373
|
+
offsetDays: z.ZodNumber;
|
|
374
|
+
zoneField: z.ZodOptional<z.ZodString>;
|
|
375
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
376
|
+
type: z.ZodLiteral<"manual">;
|
|
377
|
+
object: z.ZodString;
|
|
378
|
+
label: z.ZodString;
|
|
379
|
+
bulk: z.ZodOptional<z.ZodBoolean>;
|
|
380
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
381
|
+
type: z.ZodLiteral<"approvalDecided">;
|
|
382
|
+
decision: z.ZodOptional<z.ZodEnum<{
|
|
383
|
+
any: "any";
|
|
384
|
+
approved: "approved";
|
|
385
|
+
rejected: "rejected";
|
|
386
|
+
}>>;
|
|
387
|
+
operation: z.ZodOptional<z.ZodString>;
|
|
388
|
+
object: z.ZodOptional<z.ZodString>;
|
|
389
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
390
|
+
type: z.ZodLiteral<"webhook">;
|
|
391
|
+
endpoint: z.ZodString;
|
|
392
|
+
events: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
393
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
394
|
+
type: z.ZodLiteral<"syncEvent">;
|
|
395
|
+
event: z.ZodEnum<{
|
|
396
|
+
"email.received": "email.received";
|
|
397
|
+
"email.sent": "email.sent";
|
|
398
|
+
"email.deleted": "email.deleted";
|
|
399
|
+
"meeting.scheduled": "meeting.scheduled";
|
|
400
|
+
"meeting.created": "meeting.created";
|
|
401
|
+
"meeting.updated": "meeting.updated";
|
|
402
|
+
"meeting.cancelled": "meeting.cancelled";
|
|
403
|
+
}>;
|
|
404
|
+
from: z.ZodOptional<z.ZodEnum<{
|
|
405
|
+
person: "person";
|
|
406
|
+
organisation: "organisation";
|
|
407
|
+
either: "either";
|
|
408
|
+
}>>;
|
|
409
|
+
}, z.core.$strict>], "type">;
|
|
410
|
+
export declare const automationConnectionSchema: z.ZodObject<{
|
|
411
|
+
id: z.ZodString;
|
|
412
|
+
gatekeeper: z.ZodEnum<{
|
|
413
|
+
email: "email";
|
|
414
|
+
google: "google";
|
|
415
|
+
microsoft: "microsoft";
|
|
416
|
+
slack: "slack";
|
|
417
|
+
"slack-post": "slack-post";
|
|
418
|
+
mcp: "mcp";
|
|
419
|
+
"email-send": "email-send";
|
|
420
|
+
zoominfo: "zoominfo";
|
|
421
|
+
websearch: "websearch";
|
|
422
|
+
webhook: "webhook";
|
|
423
|
+
fake: "fake";
|
|
424
|
+
}>;
|
|
425
|
+
purpose: z.ZodString;
|
|
426
|
+
}, z.core.$strict>;
|
|
427
|
+
export declare const durationSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
428
|
+
export declare const recipientSchema: z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
429
|
+
field: z.ZodString;
|
|
430
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
431
|
+
managerOf: z.ZodString;
|
|
432
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
433
|
+
userId: z.ZodString;
|
|
434
|
+
}, z.core.$strict>]>;
|
|
435
|
+
export declare const automationStepSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
436
|
+
name: z.ZodString;
|
|
437
|
+
label: z.ZodOptional<z.ZodString>;
|
|
438
|
+
kind: z.ZodOptional<z.ZodLiteral<"do">>;
|
|
439
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
440
|
+
writes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
441
|
+
object: z.ZodString;
|
|
442
|
+
action: z.ZodOptional<z.ZodEnum<{
|
|
443
|
+
create: "create";
|
|
444
|
+
update: "update";
|
|
445
|
+
delete: "delete";
|
|
446
|
+
}>>;
|
|
447
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
448
|
+
titles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
449
|
+
assignTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
450
|
+
field: z.ZodString;
|
|
451
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
452
|
+
managerOf: z.ZodString;
|
|
453
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
454
|
+
userId: z.ZodString;
|
|
455
|
+
}, z.core.$strict>]>>;
|
|
456
|
+
linkedToTrigger: z.ZodOptional<z.ZodBoolean>;
|
|
457
|
+
}, z.core.$strict>>>;
|
|
458
|
+
notifies: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
459
|
+
to: z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
460
|
+
field: z.ZodString;
|
|
461
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
462
|
+
managerOf: z.ZodString;
|
|
463
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
464
|
+
userId: z.ZodString;
|
|
465
|
+
}, z.core.$strict>]>;
|
|
466
|
+
message: z.ZodString;
|
|
467
|
+
body: z.ZodOptional<z.ZodString>;
|
|
468
|
+
}, z.core.$strict>>>;
|
|
469
|
+
calls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
470
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
471
|
+
name: z.ZodString;
|
|
472
|
+
label: z.ZodOptional<z.ZodString>;
|
|
473
|
+
kind: z.ZodLiteral<"sleep">;
|
|
474
|
+
duration: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
475
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
476
|
+
name: z.ZodString;
|
|
477
|
+
label: z.ZodOptional<z.ZodString>;
|
|
478
|
+
kind: z.ZodLiteral<"waitForEvent">;
|
|
479
|
+
event: z.ZodString;
|
|
480
|
+
timeout: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
481
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
482
|
+
name: z.ZodString;
|
|
483
|
+
label: z.ZodString;
|
|
484
|
+
kind: z.ZodLiteral<"condition">;
|
|
485
|
+
clause: z.ZodOptional<z.ZodString>;
|
|
486
|
+
}, z.core.$strict>]>;
|
|
487
|
+
export declare const automationConditionSchema: z.ZodType<ViewFilter>;
|
|
488
|
+
export declare const onRejectedSchema: z.ZodUnion<readonly [z.ZodLiteral<"stop">, z.ZodLiteral<"continue">, z.ZodObject<{
|
|
489
|
+
notify: z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
490
|
+
field: z.ZodString;
|
|
491
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
492
|
+
managerOf: z.ZodString;
|
|
493
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
494
|
+
userId: z.ZodString;
|
|
495
|
+
}, z.core.$strict>]>;
|
|
496
|
+
message: z.ZodOptional<z.ZodString>;
|
|
497
|
+
}, z.core.$strict>]>;
|
|
498
|
+
export declare const automationRailsSchema: z.ZodObject<{
|
|
499
|
+
maxRunsPerMinute: z.ZodOptional<z.ZodNumber>;
|
|
500
|
+
maxWritesPerHour: z.ZodOptional<z.ZodNumber>;
|
|
501
|
+
debounceSeconds: z.ZodOptional<z.ZodNumber>;
|
|
502
|
+
}, z.core.$strict>;
|
|
503
|
+
export declare const automationManifestSchema: z.ZodObject<{
|
|
504
|
+
label: z.ZodString;
|
|
505
|
+
description: z.ZodString;
|
|
506
|
+
trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
507
|
+
type: z.ZodLiteral<"record">;
|
|
508
|
+
object: z.ZodString;
|
|
509
|
+
on: z.ZodArray<z.ZodEnum<{
|
|
510
|
+
created: "created";
|
|
511
|
+
updated: "updated";
|
|
512
|
+
deleted: "deleted";
|
|
513
|
+
restored: "restored";
|
|
514
|
+
}>>;
|
|
515
|
+
includeBulk: z.ZodOptional<z.ZodBoolean>;
|
|
516
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
517
|
+
type: z.ZodLiteral<"fieldChanged">;
|
|
518
|
+
object: z.ZodString;
|
|
519
|
+
field: z.ZodString;
|
|
520
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodObject<{
|
|
521
|
+
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
522
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
523
|
+
stageType: z.ZodEnum<{
|
|
524
|
+
open: "open";
|
|
525
|
+
won: "won";
|
|
526
|
+
lost: "lost";
|
|
527
|
+
}>;
|
|
528
|
+
}, z.core.$strict>]>>;
|
|
529
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodObject<{
|
|
530
|
+
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
531
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
532
|
+
stageType: z.ZodEnum<{
|
|
533
|
+
open: "open";
|
|
534
|
+
won: "won";
|
|
535
|
+
lost: "lost";
|
|
536
|
+
}>;
|
|
537
|
+
}, z.core.$strict>]>>;
|
|
538
|
+
includeBulk: z.ZodOptional<z.ZodBoolean>;
|
|
539
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
540
|
+
type: z.ZodLiteral<"schedule">;
|
|
541
|
+
cron: z.ZodString;
|
|
542
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
543
|
+
type: z.ZodLiteral<"dateRelative">;
|
|
544
|
+
object: z.ZodString;
|
|
545
|
+
field: z.ZodString;
|
|
546
|
+
offsetDays: z.ZodNumber;
|
|
547
|
+
zoneField: z.ZodOptional<z.ZodString>;
|
|
548
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
549
|
+
type: z.ZodLiteral<"manual">;
|
|
550
|
+
object: z.ZodString;
|
|
551
|
+
label: z.ZodString;
|
|
552
|
+
bulk: z.ZodOptional<z.ZodBoolean>;
|
|
553
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
554
|
+
type: z.ZodLiteral<"approvalDecided">;
|
|
555
|
+
decision: z.ZodOptional<z.ZodEnum<{
|
|
556
|
+
any: "any";
|
|
557
|
+
approved: "approved";
|
|
558
|
+
rejected: "rejected";
|
|
559
|
+
}>>;
|
|
560
|
+
operation: z.ZodOptional<z.ZodString>;
|
|
561
|
+
object: z.ZodOptional<z.ZodString>;
|
|
562
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
563
|
+
type: z.ZodLiteral<"webhook">;
|
|
564
|
+
endpoint: z.ZodString;
|
|
565
|
+
events: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
566
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
567
|
+
type: z.ZodLiteral<"syncEvent">;
|
|
568
|
+
event: z.ZodEnum<{
|
|
569
|
+
"email.received": "email.received";
|
|
570
|
+
"email.sent": "email.sent";
|
|
571
|
+
"email.deleted": "email.deleted";
|
|
572
|
+
"meeting.scheduled": "meeting.scheduled";
|
|
573
|
+
"meeting.created": "meeting.created";
|
|
574
|
+
"meeting.updated": "meeting.updated";
|
|
575
|
+
"meeting.cancelled": "meeting.cancelled";
|
|
576
|
+
}>;
|
|
577
|
+
from: z.ZodOptional<z.ZodEnum<{
|
|
578
|
+
person: "person";
|
|
579
|
+
organisation: "organisation";
|
|
580
|
+
either: "either";
|
|
581
|
+
}>>;
|
|
582
|
+
}, z.core.$strict>], "type">;
|
|
583
|
+
conditions: z.ZodOptional<z.ZodType<ViewFilter, unknown, z.core.$ZodTypeInternals<ViewFilter, unknown>>>;
|
|
584
|
+
steps: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
585
|
+
name: z.ZodString;
|
|
586
|
+
label: z.ZodOptional<z.ZodString>;
|
|
587
|
+
kind: z.ZodOptional<z.ZodLiteral<"do">>;
|
|
588
|
+
reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
589
|
+
writes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
590
|
+
object: z.ZodString;
|
|
591
|
+
action: z.ZodOptional<z.ZodEnum<{
|
|
592
|
+
create: "create";
|
|
593
|
+
update: "update";
|
|
594
|
+
delete: "delete";
|
|
595
|
+
}>>;
|
|
596
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
597
|
+
titles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
598
|
+
assignTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
599
|
+
field: z.ZodString;
|
|
600
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
601
|
+
managerOf: z.ZodString;
|
|
602
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
603
|
+
userId: z.ZodString;
|
|
604
|
+
}, z.core.$strict>]>>;
|
|
605
|
+
linkedToTrigger: z.ZodOptional<z.ZodBoolean>;
|
|
606
|
+
}, z.core.$strict>>>;
|
|
607
|
+
notifies: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
608
|
+
to: z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
609
|
+
field: z.ZodString;
|
|
610
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
611
|
+
managerOf: z.ZodString;
|
|
612
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
613
|
+
userId: z.ZodString;
|
|
614
|
+
}, z.core.$strict>]>;
|
|
615
|
+
message: z.ZodString;
|
|
616
|
+
body: z.ZodOptional<z.ZodString>;
|
|
617
|
+
}, z.core.$strict>>>;
|
|
618
|
+
calls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
619
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
620
|
+
name: z.ZodString;
|
|
621
|
+
label: z.ZodOptional<z.ZodString>;
|
|
622
|
+
kind: z.ZodLiteral<"sleep">;
|
|
623
|
+
duration: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
624
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
625
|
+
name: z.ZodString;
|
|
626
|
+
label: z.ZodOptional<z.ZodString>;
|
|
627
|
+
kind: z.ZodLiteral<"waitForEvent">;
|
|
628
|
+
event: z.ZodString;
|
|
629
|
+
timeout: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
630
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
631
|
+
name: z.ZodString;
|
|
632
|
+
label: z.ZodString;
|
|
633
|
+
kind: z.ZodLiteral<"condition">;
|
|
634
|
+
clause: z.ZodOptional<z.ZodString>;
|
|
635
|
+
}, z.core.$strict>]>>;
|
|
636
|
+
onRejected: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"stop">, z.ZodLiteral<"continue">, z.ZodObject<{
|
|
637
|
+
notify: z.ZodUnion<readonly [z.ZodLiteral<"admins">, z.ZodLiteral<"actor">, z.ZodObject<{
|
|
638
|
+
field: z.ZodString;
|
|
639
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
640
|
+
managerOf: z.ZodString;
|
|
641
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
642
|
+
userId: z.ZodString;
|
|
643
|
+
}, z.core.$strict>]>;
|
|
644
|
+
message: z.ZodOptional<z.ZodString>;
|
|
645
|
+
}, z.core.$strict>]>>;
|
|
646
|
+
rails: z.ZodOptional<z.ZodObject<{
|
|
647
|
+
maxRunsPerMinute: z.ZodOptional<z.ZodNumber>;
|
|
648
|
+
maxWritesPerHour: z.ZodOptional<z.ZodNumber>;
|
|
649
|
+
debounceSeconds: z.ZodOptional<z.ZodNumber>;
|
|
650
|
+
}, z.core.$strict>>;
|
|
651
|
+
connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
652
|
+
id: z.ZodString;
|
|
653
|
+
gatekeeper: z.ZodEnum<{
|
|
654
|
+
email: "email";
|
|
655
|
+
google: "google";
|
|
656
|
+
microsoft: "microsoft";
|
|
657
|
+
slack: "slack";
|
|
658
|
+
"slack-post": "slack-post";
|
|
659
|
+
mcp: "mcp";
|
|
660
|
+
"email-send": "email-send";
|
|
661
|
+
zoominfo: "zoominfo";
|
|
662
|
+
websearch: "websearch";
|
|
663
|
+
webhook: "webhook";
|
|
664
|
+
fake: "fake";
|
|
665
|
+
}>;
|
|
666
|
+
purpose: z.ZodString;
|
|
667
|
+
}, z.core.$strict>>>;
|
|
668
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
669
|
+
}, z.core.$strip>;
|
|
670
|
+
export type AutomationManifest = z.infer<typeof automationManifestSchema>;
|
|
671
|
+
export interface AutomationJournalEntry {
|
|
672
|
+
name: string;
|
|
673
|
+
kind: "do" | "sleep" | "waitForEvent";
|
|
674
|
+
/** The step.do result, or the waitForEvent payload (null on timeout); null for a sleep. */
|
|
675
|
+
value: unknown;
|
|
676
|
+
}
|
|
677
|
+
export interface AutomationRunRequest {
|
|
678
|
+
/** The automation's key in `automations`. */
|
|
679
|
+
automation: string;
|
|
680
|
+
event: AutomationEvent;
|
|
681
|
+
journal: AutomationJournalEntry[];
|
|
682
|
+
/** `advance`: run one new step and stop. `test`: run to the end, skipping waits. */
|
|
683
|
+
mode: "advance" | "test";
|
|
684
|
+
version: string;
|
|
685
|
+
}
|
|
686
|
+
/** What one advance did. */
|
|
687
|
+
export type AutomationAdvance =
|
|
688
|
+
/** Ran the step.do `name` (the host calls `operations` it made through codemode:ops). */
|
|
689
|
+
{
|
|
690
|
+
kind: "do";
|
|
691
|
+
name: string;
|
|
692
|
+
value: unknown;
|
|
693
|
+
}
|
|
694
|
+
/** Stopped at a sleep: the host sleeps `ms`, journals it and advances again. */
|
|
695
|
+
| {
|
|
696
|
+
kind: "sleep";
|
|
697
|
+
name: string;
|
|
698
|
+
ms: number;
|
|
699
|
+
}
|
|
700
|
+
/** Stopped at a wait: the host waits for `event` up to `timeoutMs`. */
|
|
701
|
+
| {
|
|
702
|
+
kind: "waitForEvent";
|
|
703
|
+
name: string;
|
|
704
|
+
event: string;
|
|
705
|
+
timeoutMs: number;
|
|
706
|
+
}
|
|
707
|
+
/** `run` returned. */
|
|
708
|
+
| {
|
|
709
|
+
kind: "done";
|
|
710
|
+
value: unknown;
|
|
711
|
+
};
|
|
712
|
+
/** One step as test mode reports it (every step, in order, waits included). */
|
|
713
|
+
export interface AutomationTestStep {
|
|
714
|
+
name: string;
|
|
715
|
+
kind: "do" | "sleep" | "waitForEvent";
|
|
716
|
+
/** do: its result. sleep / waitForEvent: skipped, and how long it would wait. */
|
|
717
|
+
value?: unknown;
|
|
718
|
+
skippedMs?: number;
|
|
719
|
+
}
|
|
720
|
+
/** One recipient as `notification.send` takes it (core `recipientInputSchema`). */
|
|
721
|
+
export type NotificationRecipientInput = {
|
|
722
|
+
userId: string;
|
|
723
|
+
} | {
|
|
724
|
+
role: "admin";
|
|
725
|
+
} | {
|
|
726
|
+
field: string;
|
|
727
|
+
record: {
|
|
728
|
+
object: string;
|
|
729
|
+
id: string;
|
|
730
|
+
};
|
|
731
|
+
} | {
|
|
732
|
+
managerOf: string;
|
|
733
|
+
record: {
|
|
734
|
+
object: string;
|
|
735
|
+
id: string;
|
|
736
|
+
};
|
|
737
|
+
};
|
|
738
|
+
/** The `notification.send` input `ctx.notify(to, message)` makes for a run. */
|
|
739
|
+
export interface NotificationSendInput {
|
|
740
|
+
to: NotificationRecipientInput[];
|
|
741
|
+
type: "automation.message";
|
|
742
|
+
title: string;
|
|
743
|
+
body?: string;
|
|
744
|
+
link?: {
|
|
745
|
+
kind: "record";
|
|
746
|
+
object: string;
|
|
747
|
+
id: string;
|
|
748
|
+
} | {
|
|
749
|
+
kind: "automationRun";
|
|
750
|
+
automationId: string;
|
|
751
|
+
runId: string;
|
|
752
|
+
};
|
|
753
|
+
dedupeKey: string;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Turns `ctx.notify(to, message)` into a `notification.send` input for `event`'s run: field and
|
|
757
|
+
* manager recipients point at the trigger record, `"actor"` is whoever started a manual run,
|
|
758
|
+
* `{record}` in the title and body becomes the trigger record's title, and the dedupe key
|
|
759
|
+
* (`<runId>:<key>`, key = `<step name>:<n>` with n counting notify calls within that step, so it is the same on every replay) makes a retried or replayed step send each
|
|
760
|
+
* notification once. Shared by the runtime and the testing harness.
|
|
761
|
+
*/
|
|
762
|
+
export declare function notificationInput(event: AutomationEvent, to: Recipient | readonly Recipient[], message: {
|
|
763
|
+
title: string;
|
|
764
|
+
body?: string;
|
|
765
|
+
link?: "record" | "run";
|
|
766
|
+
}, key: string): NotificationSendInput;
|
|
767
|
+
export {};
|