@relyio/sdk 0.18.0 → 0.20.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/automations/index.cjs +18 -17
  3. package/dist/automations/index.d.cts +2 -1307
  4. package/dist/automations/index.d.ts +2 -1307
  5. package/dist/automations/index.js +3 -2
  6. package/dist/{chunk-ZAMAR3X2.cjs → chunk-5F3YYPLZ.cjs} +11249 -10771
  7. package/dist/{chunk-ZO6QDYJG.cjs → chunk-5WGMIQBH.cjs} +2 -2
  8. package/dist/{chunk-LSI26ZN2.cjs → chunk-DBYMG6MQ.cjs} +5 -5
  9. package/dist/{chunk-W2A4OTCI.js → chunk-EQUZNVAR.js} +2 -2
  10. package/dist/{chunk-IFKF72VJ.cjs → chunk-K66MBRI4.cjs} +147 -71
  11. package/dist/{chunk-ZHTJ7GXH.js → chunk-L42C4G2S.js} +106 -31
  12. package/dist/{chunk-EDE2H37D.js → chunk-OUR7OUUZ.js} +174 -12
  13. package/dist/{chunk-W7JFHSFM.js → chunk-PZCDJFMA.js} +11249 -10772
  14. package/dist/{chunk-SHSK7UUY.cjs → chunk-UO2QRYKV.cjs} +177 -11
  15. package/dist/{chunk-R6E4HE7R.js → chunk-W2GRVXDG.js} +3 -3
  16. package/dist/client/index.cjs +5 -5
  17. package/dist/client/index.d.cts +4 -4
  18. package/dist/client/index.d.ts +4 -4
  19. package/dist/client/index.js +3 -3
  20. package/dist/{define-content-type-NEQDrvdq.d.cts → define-content-type-C2HnCYYX.d.cts} +1324 -156
  21. package/dist/{define-content-type-fb-WCD5e.d.ts → define-content-type-CVLUusfx.d.ts} +1324 -156
  22. package/dist/dev-handshake/index.cjs +8 -8
  23. package/dist/dev-handshake/index.d.cts +1 -1
  24. package/dist/dev-handshake/index.d.ts +1 -1
  25. package/dist/dev-handshake/index.js +1 -1
  26. package/dist/extensions/index.cjs +26 -6
  27. package/dist/extensions/index.d.cts +3 -791
  28. package/dist/extensions/index.d.ts +3 -791
  29. package/dist/extensions/index.js +24 -4
  30. package/dist/functions/index.cjs +7 -4
  31. package/dist/functions/index.d.cts +2 -4
  32. package/dist/functions/index.d.ts +2 -4
  33. package/dist/functions/index.js +5 -2
  34. package/dist/{index-DwHcL6x5.d.cts → index-BLVNMYUU.d.cts} +142 -79
  35. package/dist/{index-C4LqrNd1.d.ts → index-BY1xU93u.d.ts} +1 -1
  36. package/dist/{index-Dnmt_UOo.d.cts → index-Cmup6HJY.d.cts} +1 -1
  37. package/dist/index-D1fiaQlK.d.ts +2284 -0
  38. package/dist/index-DImzg3ew.d.cts +2284 -0
  39. package/dist/{index-M3luH06A.d.ts → index-IjSyBr8f.d.ts} +142 -79
  40. package/dist/index.cjs +89 -85
  41. package/dist/index.d.cts +64 -15
  42. package/dist/index.d.ts +64 -15
  43. package/dist/index.js +5 -5
  44. package/dist/preview/index.cjs +3 -3
  45. package/dist/preview/index.js +1 -1
  46. package/dist/rich-text/index.d.cts +2 -2
  47. package/dist/rich-text/index.d.ts +2 -2
  48. package/dist/schema/index.cjs +41 -40
  49. package/dist/schema/index.d.cts +948 -118
  50. package/dist/schema/index.d.ts +948 -118
  51. package/dist/schema/index.js +2 -1
  52. package/dist/types/index.d.cts +1 -1
  53. package/dist/types/index.d.ts +1 -1
  54. package/package.json +5 -5
  55. package/dist/define-schema-DZhtvLiK.d.cts +0 -846
  56. package/dist/define-schema-Dlwh6l_J.d.ts +0 -846
  57. package/dist/register-B53i97A9.d.ts +0 -677
  58. package/dist/register-BYCs0FpF.d.cts +0 -677
@@ -1,1309 +1,4 @@
1
- import { ConditionScalar, ConditionTest, ConditionTree, ConditionTests } from '../schema/index.cjs';
1
+ import '../define-content-type-C2HnCYYX.cjs';
2
+ export { a0 as Accepts, au as AgentStepConfig, ag as AnyEntryEvent, ah as AnyEntryTriggers, aG as ApproveCounts, aH as ApproveOutput, aF as ApproveStepConfig, aE as AskOutput, aD as AskStepConfig, aq as AutomationAction, I as AutomationBecomesTest, aJ as AutomationConfig, Z as AutomationDefinition, T as AutomationDuration, G as AutomationEntryAction, aK as AutomationFile, P as AutomationInput, ab as AutomationItemHandle, U as AutomationItemRef, L as AutomationJson, V as AutomationLookupState, aw as AutomationProposal, X as AutomationProposeTarget, E as AutomationRecordAction, N as AutomationRef, Y as AutomationStep, ar as AutomationStepDraft, $ as AutomationTemplate, K as AutomationTrigger, a6 as AutomationTriggerHandle, O as AutomationValue, J as AutomationWhere, a8 as EntryEvent, ad as EntryTriggers, an as ExtensionTriggerEvent, aB as LookedUp, aA as LookedUpEntry, az as LookedUpEntryItem, ay as LookedUpRecord, aC as LookupOptions, av as ProposingAgentStepConfig, ax as ProposingOutput, a7 as RecordEvent, ac as RecordTriggers, _ as Ref, ak as RunFailedEvent, al as RunFailedWhere, aI as StepBuilder, as as StepHandle, a1 as StepInput, at as StepWithOutput, a9 as TriggerWhere, aa as UidRef, a3 as and, ai as anyEntry, am as automations, aL as defineAutomation, af as entries, ao as extensionTrigger, aM as isAutomationFile, a5 as not, ap as on, a4 as or, ae as records, aN as resolveAutomation, aj as schedule, a2 as tpl } from '../index-DImzg3ew.cjs';
2
3
  export { fields } from '../schema/index.cjs';
3
- import { A as AnySchemaDefinition, R as RegisteredSchema, B as BaseRecord, a as RecordBatchTarget, b as RecordBatchResult, c as RecordConditionValue } from '../register-BYCs0FpF.cjs';
4
- import { S as SchemaRecordTypeNames, I as InferRecordType, a as SchemaContentTypeNames, b as SchemaEntry, c as SchemaLocaleCodes, R as RecordWriteFieldsOf, d as RecordUpdateFieldsOf } from '../define-schema-DZhtvLiK.cjs';
5
- import { K as KeyedMembers, F as FieldValues, D as DeclaredFields, a as KeyedMembersOf, b as FileUpload } from '../define-content-type-NEQDrvdq.cjs';
6
4
  import '../rich-text.d-BWc-5gX1.cjs';
7
-
8
- /**
9
- * `@relyio/sdk/automations` — an Automation, declared (spec 3, REL-3845; ADR 0021).
10
- *
11
- * One file per Automation at `relyio/automations/<name>.ts`, default-exporting what
12
- * {@link defineAutomation} returns; the file's name is the Automation's. An Automation is a trigger
13
- * and a sequence of steps, and all of it is data: `steps` is called **once**, when the Manifest
14
- * loads, with typed references to the event and to earlier steps' outputs, and returns plain data.
15
- * No code of yours runs when an event arrives, except inside a Function step.
16
- *
17
- * @example
18
- * // relyio/automations/order-paid.ts
19
- * import { defineAutomation, fields, or, records, tpl } from '@relyio/sdk/automations'
20
- * import reserveStock from '../functions/reserve-stock'
21
- *
22
- * export default defineAutomation({
23
- * on: records.order.updated({ where: { status: { becomes: 'paid' } } }),
24
- * steps: ({ event, step }) => {
25
- * const reserve = step.fn('reserve', reserveStock, { orderId: event.record._metadata.id })
26
- * const fraud = step.agent('fraud', {
27
- * instructions: tpl`Read order ${event.record.number} and the customer's past orders`,
28
- * context: { order: event.record },
29
- * output: { verdict: fields.enum({ options: { 'looks fine': 'Looks fine', 'needs review': 'Needs review' } }) },
30
- * })
31
- * return [reserve, fraud, step.if('ship', fraud.output.verdict.eq('looks fine'), { then: […] })]
32
- * },
33
- * })
34
- *
35
- * **Typed.** Once `relyio generate-types` has registered the schema (`Register`), `records.<type>`
36
- * takes only the Record types it declares and `event.record` is typed by its fields. A Function
37
- * step takes the Function by import, so its input is checked against the Function's input Fields and
38
- * its `output` has exactly the Function's output Fields: a misspelt one is a type error, and so is a
39
- * step reading one declared after it. The plan refuses both again, for a Manifest read as data.
40
- *
41
- * **Conditions** are the list grammar's operators (`eq`, `ne`, `in`, `gt`, `exists`, …) on a
42
- * reference, combined with {@link and}, {@link or} and {@link not}. `becomes` — changed in this
43
- * write and now equal — is a trigger's `where` alone.
44
- *
45
- * **Extensions** (REL-3846): `relyio/extensions.ts` declares the Extensions the Project uses with
46
- * `defineExtensions` (`@relyio/sdk/extensions`), and hands out a typed handle for each. An Automation
47
- * imports it: `on: stripe.paymentIntentSucceeded()` starts on one of its Triggers, and
48
- * `step.action('email', resend.send, { … })` sends through one of its Actions — input and output
49
- * typed by the Extension. Using an Extension the file does not declare is refused by the plan.
50
- */
51
-
52
- /** What a Record event says happened to one Record. */
53
- type AutomationRecordAction = 'created' | 'updated' | 'deleted' | 'expired';
54
- /** What an entry event says happened to one entry. */
55
- type AutomationEntryAction = 'created' | 'updated' | 'published' | 'unpublished' | 'deleted' | 'archived' | 'restored';
56
- /** A `becomes` test: changed in this write and now equal. A trigger's `where` alone holds one. */
57
- interface AutomationBecomesTest {
58
- readonly root: 'event';
59
- readonly path: readonly string[];
60
- readonly operator: 'becomes';
61
- readonly value: ConditionScalar;
62
- }
63
- /** A trigger's `where`: a condition over `event`, whose tests may also be `becomes`. */
64
- type AutomationWhere = ConditionTest | AutomationBecomesTest | {
65
- readonly and: readonly AutomationWhere[];
66
- } | {
67
- readonly or: readonly AutomationWhere[];
68
- } | {
69
- readonly not: AutomationWhere;
70
- };
71
- /** An Automation's trigger, as data. */
72
- type AutomationTrigger = {
73
- readonly kind: 'record';
74
- readonly recordType: string;
75
- readonly action: AutomationRecordAction;
76
- readonly where?: AutomationWhere;
77
- } | {
78
- readonly kind: 'entry';
79
- readonly contentType: string;
80
- readonly action: AutomationEntryAction;
81
- readonly where?: AutomationWhere;
82
- }
83
- /**
84
- * An entry of any content type: `where` is a plain condition over {@link AnyEntryEvent} — the
85
- * entry's uid and content type, and what changed — with no `becomes`.
86
- */
87
- | {
88
- readonly kind: 'anyEntry';
89
- readonly action: AutomationEntryAction;
90
- readonly where?: ConditionTree;
91
- } | {
92
- readonly kind: 'schedule';
93
- readonly cron: string;
94
- readonly timezone: string;
95
- }
96
- /** Another Automation's run failed; `where` is a plain condition over {@link RunFailedEvent}. */
97
- | {
98
- readonly kind: 'runFailed';
99
- readonly where?: ConditionTree;
100
- }
101
- /**
102
- * One of an Extension's Triggers: `trigger` is its slug in the Extension catalog. `where` is a plain
103
- * condition over {@link ExtensionTriggerEvent}.
104
- */
105
- | {
106
- readonly kind: 'extension';
107
- readonly extension: string;
108
- readonly trigger: string;
109
- readonly where?: ConditionTree;
110
- };
111
- /** A JSON value, as a step's input holds it literally. */
112
- type AutomationJson = string | number | boolean | null | readonly AutomationJson[] | {
113
- readonly [key: string]: AutomationJson;
114
- };
115
- /** A reference: the value at `path` under `root` — `event`, or an earlier step's name. */
116
- interface AutomationRef {
117
- readonly kind: 'ref';
118
- readonly root: string;
119
- readonly path: readonly string[];
120
- }
121
- /** A value a step is handed, as data. */
122
- type AutomationValue = {
123
- readonly kind: 'literal';
124
- readonly value: AutomationJson;
125
- } | AutomationRef | {
126
- readonly kind: 'template';
127
- readonly parts: ReadonlyArray<string | AutomationRef>;
128
- } | {
129
- readonly kind: 'list';
130
- readonly items: readonly AutomationValue[];
131
- } | {
132
- readonly kind: 'object';
133
- readonly fields: Readonly<Record<string, AutomationValue>>;
134
- };
135
- /** A step's input, by key. */
136
- type AutomationInput = Readonly<Record<string, AutomationValue>>;
137
- /** A Wait's length: whole minutes, hours or days, at most 30 days. */
138
- type AutomationDuration = `${number}m` | `${number}h` | `${number}d`;
139
- /** One Record or entry by its uid: what a Look-up reads. */
140
- type AutomationItemRef = {
141
- readonly kind: 'record';
142
- readonly recordType: string;
143
- readonly uid: AutomationValue;
144
- } | {
145
- readonly kind: 'entry';
146
- readonly contentType: string;
147
- readonly uid: AutomationValue;
148
- };
149
- /** Which of an entry's states a Look-up reads: what readers see, or the editor's view. */
150
- type AutomationLookupState = 'published' | 'draft';
151
- /** A type an Agent step may propose a change to: a content type's entries, or a Record type's. */
152
- type AutomationProposeTarget = {
153
- readonly kind: 'entry';
154
- readonly contentType: string;
155
- } | {
156
- readonly kind: 'record';
157
- readonly recordType: string;
158
- };
159
- /** One Automation step, as data. */
160
- type AutomationStep = {
161
- readonly kind: 'function';
162
- readonly name: string;
163
- readonly function: string;
164
- readonly input: AutomationInput;
165
- } | {
166
- readonly kind: 'agent';
167
- readonly name: string;
168
- readonly agent?: string;
169
- readonly instructions: AutomationValue;
170
- readonly context: AutomationInput;
171
- readonly output: readonly object[];
172
- readonly propose?: readonly AutomationProposeTarget[];
173
- } | {
174
- readonly kind: 'action';
175
- readonly name: string;
176
- readonly extension: string;
177
- readonly action: string;
178
- readonly input: AutomationInput;
179
- } | {
180
- readonly kind: 'lookup';
181
- readonly name: string;
182
- readonly item: Extract<AutomationItemRef, {
183
- readonly kind: 'record';
184
- }>;
185
- } | {
186
- readonly kind: 'lookup';
187
- readonly name: string;
188
- readonly item: Extract<AutomationItemRef, {
189
- readonly kind: 'entry';
190
- }>;
191
- readonly state: AutomationLookupState;
192
- } | {
193
- readonly kind: 'if';
194
- readonly name: string;
195
- readonly condition: ConditionTree;
196
- readonly then: readonly AutomationStep[];
197
- readonly else: readonly AutomationStep[];
198
- } | {
199
- readonly kind: 'wait';
200
- readonly name: string;
201
- readonly duration: AutomationDuration;
202
- } | {
203
- readonly kind: 'ask';
204
- readonly name: string;
205
- readonly to: readonly string[];
206
- readonly question: AutomationValue;
207
- readonly choices: readonly string[];
208
- readonly timeout: AutomationDuration;
209
- readonly onTimeout?: string;
210
- readonly sample?: string;
211
- readonly approve?: AutomationRef;
212
- };
213
- /** What an Automation declares, as data: what the Manifest carries for one file. */
214
- interface AutomationDefinition {
215
- readonly description?: string;
216
- readonly on: AutomationTrigger;
217
- /** What each run is about: one Record or entry (REL-3853). */
218
- readonly about?: AutomationItemRef;
219
- readonly steps: readonly AutomationStep[];
220
- }
221
- /** Where a reference's value type rides, for the compiler alone. */
222
- declare const REF_VALUE: unique symbol;
223
- /** A list is compared by its members, as a condition compares a list. */
224
- type MemberOf<T> = T extends ReadonlyArray<infer Member> ? Member : T;
225
- /** The values a path holding `T` is compared with. */
226
- type ComparedWith<T> = unknown extends T ? ConditionScalar : MemberOf<NonNullable<T>> extends infer Member ? Member extends ConditionScalar ? Member : never : never;
227
- /** `becomes`, offered on a trigger's `where` alone. */
228
- interface BecomesTest<T> {
229
- /** Changed in this write, and now equal to `value`. */
230
- becomes(value: ComparedWith<T>): AutomationBecomesTest;
231
- }
232
- /**
233
- * The paths under a reference to `T`. Where its shape is not known — no schema registered — a
234
- * reference is `any`: an index signature would read every step as possibly undefined under
235
- * `noUncheckedIndexedAccess`, and a typed project registers its schema.
236
- */
237
- type RefChildren<T, B extends boolean> = unknown extends T ? any : NonNullable<T> extends readonly unknown[] ? unknown : NonNullable<T> extends object ? {
238
- readonly [K in keyof NonNullable<T> & string]-?: Ref<NonNullable<T>[K], B>;
239
- } : unknown;
240
- /**
241
- * A reference to a value of type `T` when the step runs: hand it to a step's input, interpolate it
242
- * with {@link tpl}, or test it (`.eq(…)`, `.in([…])`, `.exists()`) for a condition. A field named like
243
- * a test (`eq`, `in`) is not reachable as a path. `B`: whether `becomes` is offered (a `where`).
244
- */
245
- type Ref<T, B extends boolean = false> = {
246
- readonly [REF_VALUE]: T;
247
- } & ConditionTests<T> & (B extends true ? BecomesTest<T> : unknown) & RefChildren<T, B>;
248
- /** A reference whose value is a `T`: what a step's input takes where it takes a `T`. */
249
- type RefTo<T> = {
250
- readonly [REF_VALUE]: T;
251
- };
252
- /** Where a template's parts ride at run time. */
253
- declare const TEMPLATE: unique symbol;
254
- /** Text written with {@link tpl}: literal parts and references, rendered when the step runs. */
255
- interface AutomationTemplate {
256
- readonly [TEMPLATE]: ReadonlyArray<string | AutomationRef>;
257
- }
258
- /** What a step's input takes where its Field takes a `T`. */
259
- type Accepts<T> = T | RefTo<T> | (string extends NonNullable<T> ? AutomationTemplate : never) | AcceptsWithin<NonNullable<T>>;
260
- /**
261
- * A list or object a step's input takes, references at any depth. Distributed over each member of
262
- * `T`, so a union — `AutomationJson`, a webhook's body — takes a list or an object holding
263
- * references, as one member alone does.
264
- */
265
- type AcceptsWithin<T> = T extends ReadonlyArray<infer Member> ? ReadonlyArray<Accepts<Member>> : T extends object ? {
266
- readonly [K in keyof T]: Accepts<T[K]>;
267
- } : never;
268
- /** A step's input: each key as its Field types it, a value or a reference to one. */
269
- type StepInput<V> = {
270
- readonly [K in keyof V]: Accepts<V[K]>;
271
- };
272
- /**
273
- * Text with references in it, rendered when the step runs.
274
- *
275
- * @example
276
- * tpl`Order ${event.record.number} held: ${fraud.output.reason}`
277
- */
278
- declare function tpl(strings: TemplateStringsArray, ...values: ReadonlyArray<RefTo<unknown> | ConditionScalar>): AutomationTemplate;
279
- /** Every test holds. */
280
- declare function and(...conditions: readonly ConditionTree[]): ConditionTree;
281
- declare function and(...conditions: readonly AutomationWhere[]): AutomationWhere;
282
- /** Some test holds. */
283
- declare function or(...conditions: readonly ConditionTree[]): ConditionTree;
284
- declare function or(...conditions: readonly AutomationWhere[]): AutomationWhere;
285
- /** The test does not hold. */
286
- declare function not(condition: ConditionTree): ConditionTree;
287
- declare function not(condition: AutomationWhere): AutomationWhere;
288
- /** Where a trigger's event type rides, for the compiler alone. */
289
- declare const EVENT_TYPE: unique symbol;
290
- /** A trigger, as `on` takes it: its data, and the type of the event it hands `steps`. */
291
- interface AutomationTriggerHandle<E> {
292
- readonly trigger: AutomationTrigger;
293
- readonly [EVENT_TYPE]?: E;
294
- }
295
- /** The Record type names a schema declares, or any name without one. */
296
- type RecordTypeNameIn$1<S> = S extends AnySchemaDefinition ? SchemaRecordTypeNames<S> : string;
297
- type ContentTypeNameIn<S> = S extends AnySchemaDefinition ? SchemaContentTypeNames<S> : string;
298
- /** An entry's values, of one content type, typed by the registered schema when there is one. */
299
- type EntryValuesIn<S, K> = S extends AnySchemaDefinition ? Omit<SchemaEntry<S, K & SchemaContentTypeNames<S>>, '_metadata'> : Record<string, unknown>;
300
- /** A Record of one Record type, typed by the registered schema when there is one. */
301
- type RecordIn$1<S, K> = S extends AnySchemaDefinition ? InferRecordType<NonNullable<S['recordTypes']>[K & keyof NonNullable<S['recordTypes']>]> : BaseRecord;
302
- /** A Record event: the Record as the write left it, and the names of the fields it changed. */
303
- interface RecordEvent<R> {
304
- readonly record: R;
305
- readonly changed: readonly string[];
306
- }
307
- /** An entry event: the entry as the write left it, and the names of the fields it changed. */
308
- interface EntryEvent {
309
- readonly entry: unknown;
310
- readonly changed: readonly string[];
311
- }
312
- /** One field's `where`: its value, or the list grammar's operators and `becomes`. */
313
- type FieldWhere<T> = ComparedWith<T> | ({
314
- readonly becomes?: ComparedWith<T>;
315
- } & {
316
- readonly [Op in 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte']?: ComparedWith<T>;
317
- } & {
318
- readonly in?: ReadonlyArray<ComparedWith<T>>;
319
- readonly nin?: ReadonlyArray<ComparedWith<T>>;
320
- readonly exists?: boolean;
321
- });
322
- /**
323
- * A trigger's `where`: field by field over the item — `{ status: { becomes: 'paid' } }`, every field
324
- * holding — or a condition over the event, written with `becomes` and the list grammar.
325
- */
326
- type TriggerWhere<E, Item> = {
327
- readonly [F in keyof Item & string]?: FieldWhere<Item[F]>;
328
- } | ((event: Ref<E, true>) => AutomationWhere);
329
- /** Where a type's item rides at run time: `records.order` says it is the Record type `order`. */
330
- declare const ITEM: unique symbol;
331
- /** Where one item by uid rides at run time: what `<type>.ref(uid)` returns. */
332
- declare const ITEM_REF: unique symbol;
333
- /** Where a type's or an item's value type rides, for the compiler alone. */
334
- declare const ITEM_TYPE: unique symbol;
335
- /** What a type, or one item of it, holds: a Record of `R`, or an entry with the values `V`. */
336
- type ItemType<R = unknown, V = unknown> = {
337
- readonly kind: 'record';
338
- readonly record: R;
339
- } | {
340
- readonly kind: 'entry';
341
- readonly values: V;
342
- };
343
- /** The type a Record or entry type's handle names, as data. */
344
- type ItemTypeOf = {
345
- readonly kind: 'record';
346
- readonly recordType: string;
347
- } | {
348
- readonly kind: 'entry';
349
- readonly contentType: string;
350
- };
351
- /**
352
- * A uid: a reference to one — `event.record._metadata.id`, a reference field, an earlier step's
353
- * output — or a uid written out.
354
- */
355
- type UidRef = string | RefTo<string | null | undefined>;
356
- /**
357
- * One Record or entry, by its uid, typed by its type: `records.order.ref(event.record._metadata.id)`.
358
- * `step.lookup` reads one, and a run may be declared to be about one (REL-4152).
359
- */
360
- interface AutomationItemHandle<I extends ItemType = ItemType> {
361
- readonly [ITEM_REF]: AutomationItemRef;
362
- readonly [ITEM_TYPE]?: I;
363
- }
364
- /** The triggers of one Record type. */
365
- interface RecordTriggers<R> {
366
- /** A typed reference to one Record of this type, by its uid. */
367
- ref(uid: UidRef): AutomationItemHandle<{
368
- readonly kind: 'record';
369
- readonly record: R;
370
- }>;
371
- readonly [ITEM]: ItemTypeOf;
372
- readonly [ITEM_TYPE]?: {
373
- readonly kind: 'record';
374
- readonly record: R;
375
- };
376
- created(options?: {
377
- where?: TriggerWhere<RecordEvent<R>, R>;
378
- }): AutomationTriggerHandle<RecordEvent<R>>;
379
- updated(options?: {
380
- where?: TriggerWhere<RecordEvent<R>, R>;
381
- }): AutomationTriggerHandle<RecordEvent<R>>;
382
- deleted(options?: {
383
- where?: TriggerWhere<RecordEvent<R>, R>;
384
- }): AutomationTriggerHandle<RecordEvent<R>>;
385
- expired(options?: {
386
- where?: TriggerWhere<RecordEvent<R>, R>;
387
- }): AutomationTriggerHandle<RecordEvent<R>>;
388
- }
389
- /** The triggers of one content type, whose entries hold the values `V`. */
390
- type EntryTriggers<V = Record<string, unknown>> = {
391
- readonly [A in AutomationEntryAction]: (options?: {
392
- where?: TriggerWhere<EntryEvent, Record<string, unknown>>;
393
- }) => AutomationTriggerHandle<EntryEvent>;
394
- } & {
395
- /** A typed reference to one entry of this type, by its uid. */
396
- ref(uid: UidRef): AutomationItemHandle<{
397
- readonly kind: 'entry';
398
- readonly values: V;
399
- }>;
400
- readonly [ITEM]: ItemTypeOf;
401
- readonly [ITEM_TYPE]?: {
402
- readonly kind: 'entry';
403
- readonly values: V;
404
- };
405
- };
406
- /** Each Record type's triggers, by name: typed by the registered schema, any name without one. */
407
- type RecordTriggerTable = string extends RecordTypeNameIn$1<RegisteredSchema> ? {
408
- readonly [recordType: string]: any;
409
- } : {
410
- readonly [K in RecordTypeNameIn$1<RegisteredSchema>]: RecordTriggers<RecordIn$1<RegisteredSchema, K>>;
411
- };
412
- /** Each content type's triggers, by name. */
413
- type EntryTriggerTable = string extends ContentTypeNameIn<RegisteredSchema> ? {
414
- readonly [contentType: string]: any;
415
- } : {
416
- readonly [K in ContentTypeNameIn<RegisteredSchema>]: EntryTriggers<EntryValuesIn<RegisteredSchema, K>>;
417
- };
418
- /**
419
- * `records.<type>.created | updated | deleted | expired`: a Record event of one Record type.
420
- * `records.<type>` itself names the type to `step.lookup`, and `records.<type>.ref(uid)` one Record.
421
- */
422
- declare const records: RecordTriggerTable;
423
- /**
424
- * `entries.<type>.created | updated | published | …`: an entry event of one content type.
425
- * `entries.<type>` itself names the type to `step.lookup`, and `entries.<type>.ref(uid)` one entry.
426
- */
427
- declare const entries: EntryTriggerTable;
428
- /**
429
- * What a run started by an entry of any content type reads under `event` (REL-3861): what every
430
- * entry event holds whatever its type — the entry's uid and content type, and the names of the
431
- * fields the write changed. No field of the entry: no one content type declares it.
432
- */
433
- interface AnyEntryEvent {
434
- readonly entry: {
435
- readonly _metadata: {
436
- readonly id: string;
437
- readonly type: string;
438
- };
439
- };
440
- readonly changed: readonly string[];
441
- }
442
- /** The triggers of an entry of any content type, one per entry action. */
443
- type AnyEntryTriggers = {
444
- readonly [A in AutomationEntryAction]: (options?: {
445
- readonly where?: (event: Ref<AnyEntryEvent>) => ConditionTree;
446
- }) => AutomationTriggerHandle<AnyEntryEvent>;
447
- };
448
- /**
449
- * `anyEntry.created | updated | published | …`: an entry event of any content type — what a site
450
- * that revalidates every page it renders listens to. `where` is a function of the event, which holds
451
- * the entry's `_metadata.id` and `_metadata.type` and `changed` alone, and no `becomes`:
452
- * `anyEntry.published({ where: event => event.entry._metadata.type.in(['post']) })`.
453
- */
454
- declare const anyEntry: AnyEntryTriggers;
455
- /** A clock: `schedule.cron('0 8 * * 1', { timezone: 'Europe/Berlin' })`, on Production only. */
456
- declare const schedule: {
457
- cron(cron: string, options: {
458
- readonly timezone: string;
459
- }): AutomationTriggerHandle<Record<string, never>>;
460
- };
461
- /**
462
- * What a run started by another run's failure reads under `event` (REL-4152): the failed run, its
463
- * Automation and Branch, what it was about, the step it failed at, the error, and the event that set
464
- * it off by type and id. Never that event's body: a Record's values stay on the failed run.
465
- */
466
- interface RunFailedEvent {
467
- readonly runId: string;
468
- /** The Automation whose run failed. */
469
- readonly automation: string;
470
- readonly branchId: string;
471
- /** The Record or entry the failed run was about — and so the one this run is about. */
472
- readonly about: {
473
- readonly kind: 'record' | 'entry';
474
- readonly type: string;
475
- readonly uid: string;
476
- } | null;
477
- readonly step: {
478
- readonly name: string;
479
- /** `function`, `agent`, `action`, `if` or `wait`. */
480
- readonly kind: string;
481
- readonly attempts: number;
482
- };
483
- readonly error: {
484
- readonly code: string;
485
- readonly message: string;
486
- };
487
- readonly trigger: {
488
- readonly eventType: string;
489
- readonly eventId: string;
490
- };
491
- }
492
- /** One value's `where` with no `becomes`: the value, or the list grammar's operators. */
493
- type ValueWhere<T> = ComparedWith<T> | ({
494
- readonly [Op in 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte']?: ComparedWith<T>;
495
- } & {
496
- readonly in?: ReadonlyArray<ComparedWith<T>>;
497
- readonly nin?: ReadonlyArray<ComparedWith<T>>;
498
- readonly exists?: boolean;
499
- });
500
- /** Where each name a failed run's `where` shorthand filters on sits under `event`. */
501
- declare const RUN_FAILED_PATHS: {
502
- readonly automation: readonly ["automation"];
503
- readonly step: readonly ["step", "name"];
504
- readonly code: readonly ["error", "code"];
505
- };
506
- /**
507
- * A failed run's `where`: by its Automation, the step it failed at and the error's code —
508
- * `{ automation: 'order-paid', code: { in: ['send-refused'] } }`, every one holding — or a condition
509
- * over {@link RunFailedEvent}. No `becomes`: a failure changes no field.
510
- */
511
- type RunFailedWhere = {
512
- readonly [K in keyof typeof RUN_FAILED_PATHS]?: ValueWhere<string>;
513
- } | ((event: Ref<RunFailedEvent>) => ConditionTree);
514
- /**
515
- * Another Automation's run failed: `automations.runFailed({ where })`, on the failed run's Branch.
516
- * An Automation never hears its own failure, and a run a failure started never announces its own.
517
- */
518
- declare const automations: {
519
- runFailed(options?: {
520
- readonly where?: RunFailedWhere;
521
- }): AutomationTriggerHandle<RunFailedEvent>;
522
- };
523
- /**
524
- * What a run started by an Extension's Trigger reads under `event`: what the third party sent, as the
525
- * Trigger's payload fields declare it (`event.payload.data.object.id`).
526
- */
527
- interface ExtensionTriggerEvent<P> {
528
- readonly payload: P;
529
- }
530
- /**
531
- * One of an Extension's Triggers, as its handle in `relyio/extensions.ts` builds it: the Extension by
532
- * slug, the Trigger by its slug in the catalog, and `where`, a plain condition over the event — no
533
- * `becomes`, since the third party's event names no field RelyIO saw change. Call the handle
534
- * (`stripe.paymentIntentSucceeded({ where })`) rather than this.
535
- */
536
- declare function extensionTrigger<P>(extension: string, trigger: string, options?: {
537
- readonly where?: (event: Ref<ExtensionTriggerEvent<P>>) => ConditionTree;
538
- }): AutomationTriggerHandle<ExtensionTriggerEvent<P>>;
539
- /**
540
- * Every trigger, under one name: `on.records.order.updated(…)`, as `records.order.updated(…)`. An
541
- * Extension's Trigger is its handle's: `on: stripe.paymentIntentSucceeded()`.
542
- */
543
- declare const on: {
544
- readonly records: {
545
- readonly [recordType: string]: any;
546
- };
547
- readonly entries: {
548
- readonly [contentType: string]: any;
549
- };
550
- readonly anyEntry: AnyEntryTriggers;
551
- readonly schedule: {
552
- cron(cron: string, options: {
553
- readonly timezone: string;
554
- }): AutomationTriggerHandle<Record<string, never>>;
555
- };
556
- readonly automations: {
557
- runFailed(options?: {
558
- readonly where?: RunFailedWhere;
559
- }): AutomationTriggerHandle<RunFailedEvent>;
560
- };
561
- };
562
- /** An Extension's Action, as `relyio/extensions.ts` hands one out (REL-3846): input and output typed. */
563
- interface AutomationAction<I = Record<string, unknown>, O = Record<string, unknown>, E extends string = string, N extends string = string> {
564
- readonly _tag: 'action';
565
- /** The Extension, by slug: a handle from `relyio/extensions.ts` carries it as a literal type. */
566
- readonly extension: E;
567
- /**
568
- * The Action, by its slug in the Extension catalog: what the step stores, and what a Function's
569
- * `actions.<extension>.<action>` names it by (REL-3856).
570
- */
571
- readonly action: N;
572
- /** Never present at run time: the Action's input and output, as types. */
573
- readonly [REF_VALUE]?: {
574
- readonly input: I;
575
- readonly output: O;
576
- };
577
- }
578
- /** A step as `steps` builds it: its data, a Function step's Function still the imported value. */
579
- type AutomationStepDraft = (Omit<Extract<AutomationStep, {
580
- kind: 'function';
581
- }>, 'function'> & {
582
- readonly function: FunctionDefinition;
583
- }) | Exclude<AutomationStep, {
584
- kind: 'function' | 'if';
585
- }> | (Omit<Extract<AutomationStep, {
586
- kind: 'if';
587
- }>, 'then' | 'else'> & {
588
- readonly then: readonly AutomationStepDraft[];
589
- readonly else: readonly AutomationStepDraft[];
590
- });
591
- /** Where a step handle's data rides at run time. */
592
- declare const STEP: unique symbol;
593
- /** A step, as `steps` returns it and an If's branches list it. */
594
- interface StepHandle {
595
- readonly name: string;
596
- readonly [STEP]: AutomationStepDraft;
597
- }
598
- /** A step whose output later steps read: `<step>.output.<field>`. */
599
- interface StepWithOutput<O> extends StepHandle {
600
- readonly output: Ref<O>;
601
- }
602
- /** A Field set's values, as a Function's and an Agent step's output Fields declare them. */
603
- type ValuesOf$1<F extends KeyedMembers> = FieldValues<DeclaredFields<{
604
- readonly fields: readonly KeyedMembersOf<F>[];
605
- }>>;
606
- /** What `step.agent` takes. */
607
- interface AgentStepConfig<O extends KeyedMembers> {
608
- /** The agent, built-in or the project's, by id or slug; RelyIO's default when left out. */
609
- readonly agent?: string;
610
- readonly instructions: string | AutomationTemplate;
611
- /** What the agent is handed to read, by key. */
612
- readonly context?: {
613
- readonly [key: string]: unknown;
614
- };
615
- /** The Fields its answer must fill: a mismatch fails the step. */
616
- readonly output: O;
617
- }
618
- /**
619
- * What a proposing `step.agent` takes besides (REL-4154): the types it may propose a change to —
620
- * `entries.productPage`, `records.order`. It is offered ai-gateway's proposal tools for those types
621
- * alone and makes at most one proposal, which nothing applies until an Ask approves it.
622
- */
623
- interface ProposingAgentStepConfig<O extends KeyedMembers> extends AgentStepConfig<O> {
624
- readonly propose: readonly [LookupType, ...LookupType[]];
625
- }
626
- /** The proposal a proposing Agent step made: what an Ask's `approve` names. */
627
- interface AutomationProposal {
628
- readonly id: string;
629
- /** The proposal's kind: `field_update`, `operation`, `record_update`, … */
630
- readonly kind: string;
631
- /** How many units it changes: entries, or Records. */
632
- readonly counts: {
633
- readonly units: number;
634
- };
635
- }
636
- /** A proposing Agent step's output: its Fields, and the proposal — `null` when it proposed none. */
637
- type ProposingOutput<V> = V & {
638
- readonly proposal: AutomationProposal | null;
639
- };
640
- /**
641
- * What a Look-up of a Record answers: `found`, and the Record as it stands now when it was. Read
642
- * `found` before the Record: an item deleted, never there, or a reference with no value is
643
- * `{ found: false }`.
644
- */
645
- interface LookedUpRecord<R> {
646
- readonly found: boolean;
647
- readonly record?: R;
648
- }
649
- /** The locale codes the registered schema declares, or any code without one. */
650
- type LocaleCodeIn<S> = S extends AnySchemaDefinition ? SchemaLocaleCodes<S> : string;
651
- /** An entry as a Look-up reads it: its shared values, and each locale it admits with its own. */
652
- interface LookedUpEntryItem<V> {
653
- readonly _metadata: {
654
- readonly id: string;
655
- readonly type: string;
656
- };
657
- /** The values of the fields that are not localized. */
658
- readonly fields: Partial<V>;
659
- /** Each locale the state admits: its publication status and its localized values. */
660
- readonly locales: {
661
- readonly [L in LocaleCodeIn<RegisteredSchema>]?: {
662
- readonly status: 'published' | 'draft';
663
- readonly fields: Partial<V>;
664
- };
665
- };
666
- }
667
- /** What a Look-up of an entry answers: `found`, and the entry when it was. */
668
- interface LookedUpEntry<V> {
669
- readonly found: boolean;
670
- readonly entry?: LookedUpEntryItem<V>;
671
- }
672
- type IsAny<T> = 0 extends 1 & T ? true : false;
673
- /** What a Look-up of the type or item `H` answers. */
674
- type LookedUp<H> = IsAny<H> extends true ? {
675
- readonly found: boolean;
676
- readonly record?: any;
677
- readonly entry?: any;
678
- } : H extends {
679
- readonly [ITEM_TYPE]?: infer I;
680
- } ? I extends {
681
- readonly kind: 'record';
682
- readonly record: infer R;
683
- } ? LookedUpRecord<R> : I extends {
684
- readonly kind: 'entry';
685
- readonly values: infer V;
686
- } ? LookedUpEntry<V> : never : never;
687
- /** What a Look-up of `H` takes beside it: an entry's `state`; a Record has no draft. */
688
- type LookupOptions<H> = IsAny<H> extends true ? {
689
- readonly state?: AutomationLookupState;
690
- } : H extends {
691
- readonly [ITEM_TYPE]?: {
692
- readonly kind: 'entry';
693
- };
694
- } ? {
695
- /** `published` (the default): what readers see. `draft`: the editor's view. */
696
- readonly state?: AutomationLookupState;
697
- } : never;
698
- /** A Record or entry type, as `step.lookup` takes it: `records.order`, `entries.product`. */
699
- type LookupType = {
700
- readonly [ITEM]: ItemTypeOf;
701
- };
702
- /** What `step.ask` takes. */
703
- interface AskStepConfig<C extends string> {
704
- /**
705
- * The roles asked: `viewer`, `editor`, `admin` or a custom role the schema declares, as a
706
- * workflow stage's `allowedRoles`. Editors and Admins when left out. People only, never an agent.
707
- */
708
- readonly to?: readonly string[];
709
- /** The question, rendered when the step runs: text, or {@link tpl} over the event and earlier outputs. */
710
- readonly question: string | AutomationTemplate;
711
- /** The answers a person may give. */
712
- readonly choices: readonly C[];
713
- /** How long the question stays open, up to 30 days; 7 days when left out. */
714
- readonly timeout?: AutomationDuration;
715
- /** The answer the step continues with once the timeout falls; without one, the step fails then. */
716
- readonly onTimeout?: NoInfer<C>;
717
- /** The answer a pull request's Preview run and an editor's test give at once; the first choice by default. */
718
- readonly sample?: NoInfer<C>;
719
- }
720
- /** What an Ask answers later steps: the choice made, and by whom, or that the timeout fell. */
721
- interface AskOutput<C extends string> {
722
- readonly answer: C;
723
- /** What the person wrote beside the choice, at most 2,000 characters. */
724
- readonly note?: string;
725
- /** The user who answered; absent on a timeout and a Preview's sample. */
726
- readonly answeredBy?: string;
727
- /** When, as ISO-8601; absent on a timeout and a Preview's sample. */
728
- readonly answeredAt?: string;
729
- /** Whether the step continued with `onTimeout` because nobody answered in time. */
730
- readonly timedOut: boolean;
731
- }
732
- /** An approving Ask's choices, in order: a Preview's sample is the first. */
733
- declare const APPROVE_CHOICES: readonly ["approve", "reject"];
734
- type ApproveChoice = (typeof APPROVE_CHOICES)[number];
735
- /**
736
- * What an approving `step.ask` takes (REL-4154): `approve` names an earlier Agent step's proposal,
737
- * and the choices are `approve` and `reject`. Only members holding `to`'s roles and the authority
738
- * the proposal's apply needs are asked or may answer. A timeout never approves.
739
- */
740
- interface ApproveStepConfig {
741
- readonly to?: readonly string[];
742
- readonly question: string | AutomationTemplate;
743
- /** The proposal: `<agent step>.output.proposal`. */
744
- readonly approve: Ref<AutomationProposal | null>;
745
- readonly timeout?: AutomationDuration;
746
- /** What the step continues with once the timeout falls: only ever `reject`. */
747
- readonly onTimeout?: 'reject';
748
- /** What a Preview answers at once: `approve` by default. */
749
- readonly sample?: ApproveChoice;
750
- }
751
- /** What became of an approved — or not — proposal, by its units. */
752
- interface ApproveCounts {
753
- readonly applied: number;
754
- readonly stale: number;
755
- readonly failed: number;
756
- }
757
- /**
758
- * An approving Ask's output: the answer, and what became of the proposal — `applied`; `rejected`,
759
- * answered so or timed out; `stale`, a Record that moved since the agent read it; or `failed`.
760
- */
761
- interface ApproveOutput extends AskOutput<ApproveChoice> {
762
- readonly outcome: 'applied' | 'rejected' | 'stale' | 'failed';
763
- readonly counts: ApproveCounts;
764
- }
765
- /** What `steps` is handed to build steps with. */
766
- interface StepBuilder {
767
- /** Run one of the project's Functions, taken by import, with its input. */
768
- fn<F extends FunctionDefinition>(name: string, fn: F, input: StepInput<FunctionInputOf<F>>): StepWithOutput<FunctionOutputOf<F>>;
769
- /**
770
- * Ask an agent to read, answer the declared Fields and propose one change to the types `propose`
771
- * names. Nothing it proposes is written until an Ask approves it (`step.ask(…, { approve })`).
772
- */
773
- agent<const O extends KeyedMembers>(name: string, config: ProposingAgentStepConfig<O>): StepWithOutput<ProposingOutput<ValuesOf$1<O>>>;
774
- /** Ask an agent to read and answer the declared Fields. It reads; it never writes or sends. */
775
- agent<const O extends KeyedMembers>(name: string, config: AgentStepConfig<O>): StepWithOutput<ValuesOf$1<O>>;
776
- /** Send through an Extension's Action, from the events worker; Recorded in a Preview without its Connection. */
777
- action<I, O>(name: string, action: AutomationAction<I, O>, input: StepInput<I>): StepWithOutput<O>;
778
- /**
779
- * Read one Record or entry again, as it stands now, by its uid — `found`, or not: an item deleted,
780
- * never there, or a reference with no value is `{ found: false }`, never a failed step. An entry
781
- * reads `published` by default, or the editor's view with `{ state: 'draft' }`. One item, never a
782
- * query; unmetered.
783
- *
784
- * @example
785
- * const recheck = step.lookup('recheck', records.order, event.record._metadata.id)
786
- * step.if('still-unpaid', recheck.output.record.status.ne('paid'), { then: [remind] })
787
- */
788
- lookup<H extends LookupType>(name: string, type: H, uid: UidRef, options?: LookupOptions<H>): StepWithOutput<LookedUp<H>>;
789
- /** Read one item, named by `<type>.ref(uid)`, again as it stands now. */
790
- lookup<H extends AutomationItemHandle>(name: string, item: H, options?: LookupOptions<H>): StepWithOutput<LookedUp<H>>;
791
- /** Then one step list or the other, by a condition over the event and earlier outputs. */
792
- if(name: string, condition: ConditionTree, branches: {
793
- readonly then?: readonly StepHandle[];
794
- readonly else?: readonly StepHandle[];
795
- }): StepHandle;
796
- /** Hold the run, up to 30 days: `'90m'`, `'2h'`, `'3d'`. */
797
- wait(name: string, duration: AutomationDuration): StepHandle;
798
- /**
799
- * Ask the people holding `to`'s roles, through the Studio inbox and an email, and continue with
800
- * the first answer — one of `choices` — or with `onTimeout` once `timeout` falls.
801
- */
802
- ask<const C extends string>(name: string, config: AskStepConfig<C>): StepWithOutput<AskOutput<C>>;
803
- /**
804
- * Ask whether to apply an Agent step's proposal: `approve` applies it through ai-gateway's apply
805
- * path as the person who answered, and the run continues once it is applied, with the outcome.
806
- *
807
- * @example
808
- * const approval = step.ask('approve', { to: ['editor'], question: 'Publish the page?', approve: draft.output.proposal, onTimeout: 'reject' })
809
- * step.if('moved', approval.output.outcome.eq('stale'), { then: [tellOps] })
810
- */
811
- ask(name: string, config: ApproveStepConfig): StepWithOutput<ApproveOutput>;
812
- }
813
- /** What `defineAutomation` takes. */
814
- interface AutomationConfig<E> {
815
- readonly description?: string;
816
- /**
817
- * The trigger: `records.<type>.<action>(…)`, `entries.<type>.<action>(…)`, `anyEntry.<action>(…)`,
818
- * `schedule.cron(…)`,
819
- * `automations.runFailed(…)`, or an Extension's Trigger from `relyio/extensions.ts`.
820
- */
821
- readonly on: AutomationTriggerHandle<E>;
822
- /**
823
- * What each run is about, so the runs about one order are found across Automations: one Record or
824
- * entry, by a uid the event names — `({ event }) =>
825
- * records.order.ref(event.payload.data.object.metadata.orderId)`. Left out, a run is about what its
826
- * trigger names: the Record or entry of a RelyIO event, the outside object of an Extension's
827
- * Trigger (Stripe's payment intent), the failed run's item, or nothing for a clock.
828
- */
829
- readonly about?: (context: {
830
- readonly event: Ref<E>;
831
- }) => AutomationItemHandle;
832
- /**
833
- * Called once, when the Manifest loads, with a reference to the event and the step builder;
834
- * returns the steps in the order a run takes them.
835
- */
836
- readonly steps: (context: {
837
- readonly event: Ref<E>;
838
- readonly step: StepBuilder;
839
- }) => readonly StepHandle[];
840
- }
841
- /**
842
- * What an Automation file default-exports: its definition as data, each Function step still naming
843
- * the Function it imported. The CLI names those by their files ({@link resolveAutomation}).
844
- */
845
- interface AutomationFile {
846
- readonly _tag: 'automation';
847
- readonly description?: string;
848
- readonly on: AutomationTrigger;
849
- readonly about?: AutomationItemRef;
850
- readonly steps: readonly AutomationStepDraft[];
851
- }
852
- /**
853
- * Declare an Automation. The file's name is its name; `relyio deploy` reads it into the Manifest,
854
- * plans it and ships it with the rest.
855
- */
856
- declare function defineAutomation<E>(config: AutomationConfig<E>): AutomationFile;
857
- /** Whether `value` is what `defineAutomation` returns: how the CLI reads an Automation file. */
858
- declare function isAutomationFile(value: unknown): value is AutomationFile;
859
- /**
860
- * The Automation as the Manifest carries it: each Function step's Function named by `nameOf` — the
861
- * CLI's, which knows which file under `relyio/functions/` exported it. A Function no file exported
862
- * is refused by name.
863
- */
864
- declare function resolveAutomation(file: AutomationFile, nameOf: (fn: FunctionDefinition) => string | undefined): AutomationDefinition;
865
-
866
- /**
867
- * `@relyio/sdk/functions` — a Function, declared (spec 2, REL-3819; ADR 0021).
868
- *
869
- * One file per Function at `relyio/functions/<name>.ts`, default-exporting what
870
- * {@link defineFunction} returns; the file's name is the Function's. Everything but `run` is data —
871
- * its input and output Fields, its reach, its Secrets and its Ways in — which `relyio deploy` reads
872
- * into the Manifest and plans. `run` is the code: the CLI bundles the file and uploads the bundle.
873
- *
874
- * @example
875
- * // relyio/functions/checkout.ts
876
- * import { defineFunction, fields } from '@relyio/sdk/functions'
877
- *
878
- * export default defineFunction({
879
- * input: { cartId: fields.shortText({ required: true }) },
880
- * output: { orderId: fields.shortText({ required: true }) },
881
- * records: { read: ['cart', 'product'], write: ['order', 'inventory'] },
882
- * network: [{ host: 'api.stripe.com' }],
883
- * secrets: { STRIPE_SECRET_KEY: { hosts: ['api.stripe.com'] } },
884
- * route: { method: 'POST', path: '/checkout' },
885
- * async run({ input, records }) {
886
- * const cart = await records.cart.get(input.cartId)
887
- * // records.review here is a type error: checkout does not declare it
888
- * …
889
- * },
890
- * })
891
- *
892
- * **Typed from the schema.** Once `relyio generate-types` has registered the schema (`Register`), a
893
- * Record type the reach names must be one the schema declares, and `records.<type>` is typed by its
894
- * fields. A type the reach does not name is not on `records` at all.
895
- *
896
- * The capability object's runtime is the Functions runner's (spec 2, F2); this module declares its
897
- * types and the data `defineFunction` evaluates to.
898
- */
899
-
900
- /** Where a Function runs: a Dynamic Worker by default, a Container when it says so. */
901
- type FunctionRuntime = 'isolate' | 'container';
902
- /** A Container's instance type (Cloudflare's names): up to `standard-4`, 4 vCPU and 12 GiB. */
903
- type FunctionContainerSize = 'lite' | 'basic' | 'standard-1' | 'standard-2' | 'standard-3' | 'standard-4';
904
- /** A whole number of seconds or minutes: `'30s'`, `'5m'`. */
905
- type FunctionDuration = `${number}s` | `${number}m`;
906
- /** The methods a route answers. */
907
- type FunctionRouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
908
- /** A host a Function may call. `preview: 'send'`: a Preview branch's request to it is sent, not Recorded. */
909
- interface FunctionNetworkHost {
910
- readonly host: string;
911
- readonly preview?: 'send';
912
- }
913
- /**
914
- * An Extension's Action a Function may send through (spec 3, REL-3856), as the declaration carries
915
- * it: the Extension's and the Action's catalog slugs.
916
- */
917
- interface FunctionActionReach {
918
- readonly extension: string;
919
- readonly action: string;
920
- }
921
- /**
922
- * An Action handle `reach.actions` takes: what `relyio/extensions.ts`' handles hand out
923
- * (`resend.send`), its Extension and Action slugs and its input and output carried as types.
924
- */
925
- type FunctionActionHandle = AutomationAction<unknown, unknown>;
926
- /** A Secret a Function declares: the hosts it may be sent to. Its value is set per Environment. */
927
- interface FunctionSecretDeclaration {
928
- readonly hosts: readonly string[];
929
- }
930
- /** An HTTP route: static segments and `:params` — `'/orders/:id'`. */
931
- interface FunctionRoute {
932
- readonly method: FunctionRouteMethod;
933
- readonly path: string;
934
- /** Present: a Public route on the Project's host, called without a key, 60 calls a minute per address unless `perIp` says otherwise. */
935
- readonly public?: {
936
- readonly perIp?: number;
937
- /** A Secret this Function declares, holding the Turnstile secret key a call's token is verified with. */
938
- readonly turnstile?: string;
939
- };
940
- /** Browser origins allowed to call the route: `['https://shop.example.com']`. */
941
- readonly cors?: readonly string[];
942
- }
943
- /** An agent tool, offered in the AI Workspace and over MCP. */
944
- interface FunctionTool {
945
- readonly description: string;
946
- }
947
- /** A schedule, to the minute, on Production only: `{ cron: '0 8 * * 1', timezone: 'Europe/Berlin' }`. */
948
- interface FunctionSchedule {
949
- readonly cron: string;
950
- readonly timezone: string;
951
- }
952
- /**
953
- * A stored Field, as the content model compiles a keyed one. Plain data: what the Manifest carries
954
- * and `@relyio/manifest` validates.
955
- */
956
- type FunctionFieldDeclaration = object;
957
- /**
958
- * What a Function declares besides its code, every default filled: the Functions area's data shape
959
- * (`@relyio/manifest`'s `FunctionDeclaration`, which the CLI's type test holds this to).
960
- */
961
- interface FunctionDeclaration {
962
- readonly description?: string;
963
- readonly runtime: FunctionRuntime;
964
- readonly container?: {
965
- readonly size: FunctionContainerSize;
966
- };
967
- readonly limits?: {
968
- readonly cpu?: FunctionDuration;
969
- readonly duration?: FunctionDuration;
970
- };
971
- readonly input: readonly FunctionFieldDeclaration[];
972
- readonly output?: readonly FunctionFieldDeclaration[];
973
- readonly records: {
974
- readonly read: readonly string[];
975
- readonly write: readonly string[];
976
- };
977
- readonly content: 'published' | 'none';
978
- readonly network: readonly FunctionNetworkHost[];
979
- readonly secrets: Readonly<Record<string, FunctionSecretDeclaration>>;
980
- /** The Actions it may send (REL-3856); absent when it declares none. */
981
- readonly actions?: readonly FunctionActionReach[];
982
- readonly route?: FunctionRoute;
983
- readonly tool?: FunctionTool;
984
- readonly schedule?: FunctionSchedule;
985
- }
986
- /**
987
- * The Record type names a schema declares, or any name without one. Generic over the schema on
988
- * purpose: written over `RegisteredSchema` directly, the conditional was resolved once, before the
989
- * program's `Register` augmentation was in view, and answered `string` (measured).
990
- */
991
- type RecordTypeNameIn<S> = S extends AnySchemaDefinition ? SchemaRecordTypeNames<S> : string;
992
- /** The Record type names the registered schema declares, or any name before one is registered. */
993
- type FunctionRecordTypeName = RecordTypeNameIn<RegisteredSchema>;
994
- /** A Record type of a schema, by name. */
995
- type RecordTypeIn<S, K> = S extends AnySchemaDefinition ? NonNullable<S['recordTypes']>[K & keyof NonNullable<S['recordTypes']>] : never;
996
- /** A Record of one Record type as a read answers it, typed by the schema when there is one. */
997
- type RecordIn<S, K> = S extends AnySchemaDefinition ? InferRecordType<RecordTypeIn<S, K>> : BaseRecord;
998
- /** What a create of one Record type takes. */
999
- type WriteIn<S, K> = S extends AnySchemaDefinition ? RecordWriteFieldsOf<RecordTypeIn<S, K>> : Record<string, unknown>;
1000
- /** What an update of one Record type takes: the create's values without its Counters. */
1001
- type UpdateIn<S, K> = S extends AnySchemaDefinition ? RecordUpdateFieldsOf<RecordTypeIn<S, K>> : Record<string, unknown>;
1002
- /** A Record of one Record type of the registered schema. */
1003
- type RecordOf<K> = RecordIn<RegisteredSchema, K>;
1004
- /**
1005
- * A File a run sets (REL-3832), as `records.file(bytes, { name })` answers it: its name, media type
1006
- * and size, and the bytes held beside it until the write naming it is sent. Set it as the value of
1007
- * a File field in a create, an update or a batch; the run asks RelyIO for the upload, puts the bytes
1008
- * and sends the write naming it, so a retried run names the File its first attempt stored.
1009
- */
1010
- interface FunctionFile {
1011
- readonly name: string;
1012
- /** The media type: as given, else read off the name's extension, else `application/octet-stream`. */
1013
- readonly type: string;
1014
- /** In bytes. */
1015
- readonly size: number;
1016
- }
1017
- /** What a write takes: a File field takes a {@link FunctionFile} where it takes an upload. */
1018
- type WithFunctionFiles<T> = {
1019
- [F in keyof T]: FileUpload extends NonNullable<T[F]> ? T[F] | FunctionFile : T[F];
1020
- };
1021
- /** A Counter move in a run: the Record by `id`, `where` or both, the Counter, and how far. */
1022
- type FunctionCounterMove = RecordBatchTarget & {
1023
- readonly field: string;
1024
- /** A whole number above zero. */
1025
- readonly by: number;
1026
- };
1027
- /**
1028
- * What a run may do with a Record type it only reads (REL-3822), on the run's Dataset, through spec
1029
- * 1's Record reader. `get` answers `null` for a Record not stored. A Record type the reach does not
1030
- * name is refused at run time too, not only by these types.
1031
- */
1032
- interface FunctionRecordReader<K> {
1033
- get(id: string): Promise<RecordOf<K> | null>;
1034
- list(options?: {
1035
- /** Field conditions, in the grammar `relyio.records(type).list({ where })` takes. */
1036
- where?: Record<string, unknown>;
1037
- /** One key and its direction: `createdAt:desc` when absent. */
1038
- sort?: `${string}:${'asc' | 'desc'}`;
1039
- /** At most 100. */
1040
- limit?: number;
1041
- cursor?: string;
1042
- }): Promise<{
1043
- data: RecordOf<K>[];
1044
- page: {
1045
- nextCursor: string | null;
1046
- hasMore: boolean;
1047
- };
1048
- }>;
1049
- count(options?: {
1050
- where?: Record<string, unknown>;
1051
- }): Promise<number>;
1052
- }
1053
- /**
1054
- * What a run may do with a Record type it writes: read it, and write it one operation at a time —
1055
- * each sent as a batch of one, keyed as every batch of the run is, so a retried run writes it once.
1056
- * A refusal throws {@link FunctionBatchRefused} naming operation 0.
1057
- */
1058
- interface FunctionRecordWriter<K> extends FunctionRecordReader<K> {
1059
- create(fields: WithFunctionFiles<WriteIn<RegisteredSchema, K>>): Promise<RecordOf<K>>;
1060
- update(id: string, fields: {
1061
- [F in keyof UpdateIn<RegisteredSchema, K>]?: WithFunctionFiles<UpdateIn<RegisteredSchema, K>>[F] | null;
1062
- }, options?: {
1063
- revision?: number;
1064
- }): Promise<RecordOf<K>>;
1065
- delete(id: string): Promise<void>;
1066
- increment(move: FunctionCounterMove): Promise<RecordOf<K>>;
1067
- decrement(move: FunctionCounterMove): Promise<RecordOf<K>>;
1068
- }
1069
- /**
1070
- * The synchronous collector `records.batch` hands its callback: each call adds one operation, over
1071
- * the Record types the Function writes, and nothing is read inside it. The batch is sent once the
1072
- * callback returns — all or none. Each answers `undefined`, and the callback must too: one that
1073
- * awaits returns a promise, which is a type error here and refused at run time.
1074
- */
1075
- interface FunctionRecordBatch<W extends string> {
1076
- create(type: W, fields: Record<string, unknown>): undefined;
1077
- update(type: W, target: RecordBatchTarget & {
1078
- fields: Record<string, unknown>;
1079
- revision?: number;
1080
- }): undefined;
1081
- delete(type: W, target: RecordBatchTarget): undefined;
1082
- increment(type: W, move: FunctionCounterMove): undefined;
1083
- decrement(type: W, move: FunctionCounterMove): undefined;
1084
- }
1085
- /** What a committed batch answers: the Records it created, in order, and every operation's outcome. */
1086
- type FunctionBatchResult = RecordBatchResult & {
1087
- /** The Records its creates stored, in the order the batch sent them. */
1088
- readonly created: BaseRecord[];
1089
- };
1090
- /**
1091
- * What a refused batch throws in a run (REL-3822), a one-operation write's included: nothing of the
1092
- * batch was written. `operation` is the refused operation's index from 0, `code` the API's code
1093
- * (`RESOURCE_CONFLICT`, `CONTENT_INVALID`, `ACCESS_DENIED`, …), `reason` what it named — a
1094
- * blockage's kind such as `counter-out-of-bounds`, or an issue's code — and `field` the Record field
1095
- * it is about, when it names one: which line of a checkout ran out of stock.
1096
- */
1097
- interface FunctionBatchRefused extends Error {
1098
- readonly name: 'BatchRefused';
1099
- readonly operation: number | null;
1100
- readonly code: string;
1101
- readonly reason: string | null;
1102
- readonly field: string | null;
1103
- readonly details: Readonly<Record<string, unknown>>;
1104
- }
1105
- /** Whether `error` is a run's refused batch — what `records.batch` and every single write throw. */
1106
- declare function isBatchRefused(error: unknown): error is FunctionBatchRefused;
1107
- /** `records` in a run: exactly the Record types the reach names, and a batch over those it writes. */
1108
- type FunctionRecords<R extends string, W extends string> = {
1109
- readonly [K in R | W]: K extends W ? FunctionRecordWriter<K> : FunctionRecordReader<K>;
1110
- } & {
1111
- batch(collect: (batch: FunctionRecordBatch<W>) => undefined): Promise<FunctionBatchResult>;
1112
- /**
1113
- * A File for a File field of a Record type the Function writes (REL-3832): the bytes and the
1114
- * name, and the media type when the name's extension does not say it. Answers at once — inside a
1115
- * batch's collector too — and is set by the write that names it.
1116
- */
1117
- file(bytes: Uint8Array | ArrayBuffer, options: {
1118
- readonly name: string;
1119
- readonly type?: string;
1120
- }): FunctionFile;
1121
- };
1122
- /**
1123
- * Which Way in started a run, or `editor`: a test run from the Function editor, which always runs in
1124
- * the person's own Preview branch.
1125
- */
1126
- type FunctionWayIn = 'sdk' | 'route' | 'tool' | 'schedule' | 'automation' | 'editor';
1127
- /** What a run knows of itself: its id survives every retry. */
1128
- interface FunctionRunInfo {
1129
- readonly id: string;
1130
- readonly attempt: number;
1131
- readonly wayIn: FunctionWayIn;
1132
- /**
1133
- * Who called, as the run record names them: `api-key:<keyId>`, `task:<taskId>` for a scheduled or
1134
- * Automation run, or `user:<userId>` for a person's tool call or test run.
1135
- */
1136
- readonly caller: string;
1137
- readonly environment: 'production' | 'preview';
1138
- /**
1139
- * The Branch the run runs on (spec 3, REL-3853): what a checkout hands Stripe as
1140
- * `metadata.relyio_branch`, so a Preview payment's events run that Branch's Automations.
1141
- */
1142
- readonly branchId: string;
1143
- /**
1144
- * What started a run no request started: a schedule's firing — `{ type: 'function.schedule',
1145
- * scheduledFor }`, the UTC instant it was for — or the event an Automation step reacts to.
1146
- * Absent from a run an SDK call, a route or a tool started.
1147
- */
1148
- readonly event?: Readonly<Record<string, unknown>>;
1149
- }
1150
- /** Published content, read through the read core: present when the reach declares `content: 'published'`. */
1151
- interface FunctionContent {
1152
- get(type: string, id: string): Promise<Record<string, unknown> | null>;
1153
- list(type: string, options?: {
1154
- where?: Record<string, RecordConditionValue>;
1155
- limit?: number;
1156
- }): Promise<{
1157
- data: Record<string, unknown>[];
1158
- }>;
1159
- }
1160
- /** A Function's input or output values, as its Fields declare them. */
1161
- type ValuesOf<F extends KeyedMembers> = FieldValues<DeclaredFields<{
1162
- readonly fields: readonly KeyedMembersOf<F>[];
1163
- }>>;
1164
- /** What one Action handle's call takes and answers. */
1165
- type ActionCallOf<H> = H extends AutomationAction<infer I, infer O, string, string> ? (input: I) => Promise<O> : never;
1166
- /**
1167
- * `actions` in a run (REL-3856): `actions.<extension>.<action>(input)` for exactly the Actions the
1168
- * reach declares, typed by the Extension's own declaration. A call is sent through the events
1169
- * worker's one send point with the run's Environment — the run holds no key — and answers the
1170
- * Action's result; in a Preview without a Preview Connection, the Action's sample, the call Recorded
1171
- * on the run. A refusal throws {@link FunctionActionRefused}.
1172
- */
1173
- type FunctionActions<A extends FunctionActionHandle> = {
1174
- readonly [E in A['extension']]: {
1175
- readonly [N in Extract<A, {
1176
- readonly extension: E;
1177
- }>['action']]: ActionCallOf<Extract<A, {
1178
- readonly extension: E;
1179
- readonly action: N;
1180
- }>>;
1181
- };
1182
- };
1183
- /**
1184
- * What a refused Action call throws in a run (REL-3856): nothing stands sent. `code` names why —
1185
- * `extension-not-connected` (the Extension has no Connection in the run's Environment: Functions are
1186
- * never paused, their call fails), `action-input-invalid`, `action-send-failed`, or the API's own
1187
- * (`ACCESS_DENIED` for an Action outside the reach) — and `retryable` whether another attempt could
1188
- * send it.
1189
- */
1190
- interface FunctionActionRefused extends Error {
1191
- readonly name: 'ActionRefused';
1192
- readonly code: string;
1193
- readonly retryable: boolean;
1194
- readonly extension: string;
1195
- readonly action: string;
1196
- }
1197
- /** Whether `error` is a run's refused Action call. */
1198
- declare function isActionRefused(error: unknown): error is FunctionActionRefused;
1199
- /** Everything a run is handed (spec 2, "The capability object"). No key, no project id. */
1200
- interface FunctionCapabilities<I extends KeyedMembers, R extends string, W extends string, C extends 'published' | 'none', S extends string, A extends FunctionActionHandle = never> {
1201
- readonly input: ValuesOf<I>;
1202
- readonly records: FunctionRecords<R, W>;
1203
- /** The Actions the reach declares, each sent without the run holding its key (REL-3856). */
1204
- readonly actions: FunctionActions<A>;
1205
- /** Published entries; `undefined` unless the reach declares `content: 'published'`. */
1206
- readonly content: C extends 'published' ? FunctionContent : undefined;
1207
- /** The gateway's fetch: only the hosts the reach declares answer. */
1208
- readonly fetch: typeof globalThis.fetch;
1209
- /** Each declared Secret as a placeholder the gateway swaps for its value on the way to its hosts. */
1210
- readonly secrets: {
1211
- readonly [K in S]: string;
1212
- };
1213
- readonly run: FunctionRunInfo;
1214
- /** The HTTP request, for a run a route started. */
1215
- readonly request: Request | undefined;
1216
- }
1217
- /**
1218
- * A response a route Function shapes itself (REL-3829): return `respond({ … })` from `run` and the
1219
- * route answers with that status, those headers and that body — a redirect after a form post, a
1220
- * `201`, a webhook's plain-text `ok`. A string body is sent as it is; any other value as JSON;
1221
- * `null` or none sends no body. Any other output a route Function returns is answered as JSON with
1222
- * `200`. The hop's own headers (`content-length`, `transfer-encoding`, …) are RelyIO's to set.
1223
- */
1224
- interface FunctionResponse {
1225
- readonly _tag: 'function-response';
1226
- readonly status: number;
1227
- readonly headers: Readonly<Record<string, string>>;
1228
- readonly body: unknown;
1229
- }
1230
- /**
1231
- * Shape a route Function's response.
1232
- *
1233
- * @example
1234
- * return respond({ status: 303, headers: { location: 'https://acme.example/thanks' } })
1235
- */
1236
- declare function respond(response: {
1237
- /** 200–599. */
1238
- readonly status: number;
1239
- readonly headers?: Readonly<Record<string, string>>;
1240
- readonly body?: unknown;
1241
- }): FunctionResponse;
1242
- /** What `defineFunction` takes. Every part but `run` is data. */
1243
- interface FunctionConfig<I extends KeyedMembers, O extends KeyedMembers, R extends FunctionRecordTypeName, W extends FunctionRecordTypeName, C extends 'published' | 'none', S extends string, A extends FunctionActionHandle = never> {
1244
- description?: string;
1245
- /** `'isolate'` when left out. */
1246
- runtime?: FunctionRuntime;
1247
- container?: {
1248
- size: FunctionContainerSize;
1249
- };
1250
- limits?: {
1251
- cpu?: FunctionDuration;
1252
- duration?: FunctionDuration;
1253
- };
1254
- /** The input's Fields, under their ids, as the content model's `fields.*` write them. */
1255
- input?: I;
1256
- output?: O;
1257
- /** Reach: the Record types it reads and writes, by name. None when left out. */
1258
- records?: {
1259
- read?: readonly R[];
1260
- write?: readonly W[];
1261
- };
1262
- /** Reach: `'published'` to read published content. `'none'` when left out. */
1263
- content?: C;
1264
- /** Reach: the hosts it calls. None when left out. */
1265
- network?: readonly FunctionNetworkHost[];
1266
- secrets?: {
1267
- readonly [K in S]: FunctionSecretDeclaration;
1268
- };
1269
- /**
1270
- * Reach: the Extensions' Actions it may send, by the handles `relyio/extensions.ts` gives —
1271
- * `actions: [resend.send]`. None when left out; `actions.<extension>.<action>` for any other is a
1272
- * type error, and refused at run time.
1273
- */
1274
- actions?: readonly A[];
1275
- route?: FunctionRoute;
1276
- tool?: FunctionTool;
1277
- schedule?: FunctionSchedule;
1278
- run(capabilities: FunctionCapabilities<I, R, W, C, S, A>): Promise<ValuesOf<O> | FunctionResponse | void> | ValuesOf<O> | FunctionResponse | void;
1279
- }
1280
- /** Where a Function's input and output types ride on its definition, for the compiler alone. */
1281
- declare const FUNCTION_FIELDS: unique symbol;
1282
- /**
1283
- * What a Function file default-exports: its declaration as data, and its code. `I` and `O` are its
1284
- * input and output Fields, carried for the compiler alone, so an Automation's Function step that
1285
- * takes it by import types its input and its output from them (spec 3, REL-3845).
1286
- */
1287
- interface FunctionDefinition<I extends KeyedMembers = KeyedMembers, O extends KeyedMembers = KeyedMembers> {
1288
- readonly _tag: 'function';
1289
- readonly declaration: FunctionDeclaration;
1290
- readonly run: (capabilities: never) => unknown;
1291
- /** Never present at run time: the input and output Fields, as types. */
1292
- readonly [FUNCTION_FIELDS]?: {
1293
- readonly input: I;
1294
- readonly output: O;
1295
- };
1296
- }
1297
- /** A Function's input values, as its Fields declare them. */
1298
- type FunctionInputOf<F> = F extends FunctionDefinition<infer I, KeyedMembers> ? ValuesOf<I> : never;
1299
- /** A Function's output values, as its Fields declare them. */
1300
- type FunctionOutputOf<F> = F extends FunctionDefinition<KeyedMembers, infer O> ? ValuesOf<O> : never;
1301
- /**
1302
- * Declare a Function. The file's name is its name; `relyio deploy` reads the declaration, bundles the
1303
- * file and ships both with the schema.
1304
- */
1305
- declare function defineFunction<const I extends KeyedMembers = Record<never, never>, const O extends KeyedMembers = Record<never, never>, const R extends FunctionRecordTypeName = never, const W extends FunctionRecordTypeName = never, const C extends 'published' | 'none' = 'none', const S extends string = never, const A extends FunctionActionHandle = never>(config: FunctionConfig<I, O, R, W, C, S, A>): FunctionDefinition<I, O>;
1306
- /** Whether `value` is what `defineFunction` returns: how the CLI reads a Function file's default export. */
1307
- declare function isFunctionDefinition(value: unknown): value is FunctionDefinition;
1308
-
1309
- export { type FunctionActionRefused as A, type Accepts, type AgentStepConfig, type AnyEntryEvent, type AnyEntryTriggers, type ApproveCounts, type ApproveOutput, type ApproveStepConfig, type AskOutput, type AskStepConfig, type AutomationAction, type AutomationBecomesTest, type AutomationConfig, type AutomationDefinition, type AutomationDuration, type AutomationEntryAction, type AutomationFile, type AutomationInput, type AutomationItemHandle, type AutomationItemRef, type AutomationJson, type AutomationLookupState, type AutomationProposal, type AutomationProposeTarget, type AutomationRecordAction, type AutomationRef, type AutomationStep, type AutomationStepDraft, type AutomationTemplate, type AutomationTrigger, type AutomationTriggerHandle, type AutomationValue, type AutomationWhere, isActionRefused as B, type FunctionCapabilities as C, type FunctionResponse as D, respond as E, type EntryEvent, type EntryTriggers, type ExtensionTriggerEvent, type FunctionRuntime as F, type FunctionConfig as G, type FunctionDefinition as H, type FunctionInputOf as I, type FunctionOutputOf as J, defineFunction as K, isFunctionDefinition as L, type LookedUp, type LookedUpEntry, type LookedUpEntryItem, type LookedUpRecord, type LookupOptions, type ProposingAgentStepConfig, type ProposingOutput, type RecordEvent, type RecordTriggers, type Ref, type RunFailedEvent, type RunFailedWhere, type StepBuilder, type StepHandle, type StepInput, type StepWithOutput, type TriggerWhere, type UidRef, type FunctionContainerSize as a, and, anyEntry, automations, type FunctionDuration as b, type FunctionRouteMethod as c, type FunctionNetworkHost as d, defineAutomation, type FunctionActionReach as e, entries, extensionTrigger, type FunctionActionHandle as f, type FunctionSecretDeclaration as g, type FunctionRoute as h, type FunctionTool as i, isAutomationFile, type FunctionSchedule as j, type FunctionFieldDeclaration as k, type FunctionDeclaration as l, type FunctionRecordTypeName as m, type FunctionFile as n, not, type FunctionCounterMove as o, on, or, type FunctionRecordReader as p, type FunctionRecordWriter as q, type FunctionRecordBatch as r, records, resolveAutomation, type FunctionBatchResult as s, schedule, type FunctionBatchRefused as t, tpl, isBatchRefused as u, type FunctionRecords as v, type FunctionWayIn as w, type FunctionRunInfo as x, type FunctionContent as y, type FunctionActions as z };