@relyio/sdk 0.17.0 → 0.19.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 (74) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/automations/index.cjs +71 -0
  3. package/dist/automations/index.d.cts +1590 -0
  4. package/dist/automations/index.d.ts +1590 -0
  5. package/dist/automations/index.js +6 -0
  6. package/dist/{chunk-RSHMA4KT.cjs → chunk-2SPPU2WG.cjs} +68 -68
  7. package/dist/{chunk-VS2DEUTN.js → chunk-356SF5Y2.js} +463 -26
  8. package/dist/chunk-5F3YYPLZ.cjs +19237 -0
  9. package/dist/chunk-7I3SC7SV.cjs +40 -0
  10. package/dist/chunk-DBYMG6MQ.cjs +535 -0
  11. package/dist/chunk-DI6KFDBO.js +43 -0
  12. package/dist/chunk-HDHBYYEY.js +36 -0
  13. package/dist/chunk-L6DXCKVQ.cjs +50 -0
  14. package/dist/{chunk-TZL374LS.cjs → chunk-M7MWNV3Q.cjs} +21 -21
  15. package/dist/{chunk-H6IBQSMM.js → chunk-NJQK5STK.js} +3 -3
  16. package/dist/chunk-NN45CSPZ.cjs +872 -0
  17. package/dist/{chunk-6E22GYPB.cjs → chunk-P23G5NXD.cjs} +781 -337
  18. package/dist/chunk-PZCDJFMA.js +19195 -0
  19. package/dist/chunk-T7LGREB3.js +848 -0
  20. package/dist/{chunk-BBUB7C2Z.js → chunk-W2A4OTCI.js} +3 -3
  21. package/dist/chunk-W2GRVXDG.js +520 -0
  22. package/dist/{chunk-5UMY6CS4.js → chunk-ZAKEY6DY.js} +3 -3
  23. package/dist/{chunk-LSRPMNPT.cjs → chunk-ZO6QDYJG.cjs} +7 -7
  24. package/dist/client/index.cjs +8 -7
  25. package/dist/client/index.d.cts +4 -3
  26. package/dist/client/index.d.ts +4 -3
  27. package/dist/client/index.js +6 -5
  28. package/dist/{define-content-type-AuL9-oz6.d.cts → define-content-type-BZ6X8GvL.d.cts} +4547 -842
  29. package/dist/{define-content-type-BGoQxqLf.d.ts → define-content-type-C12jh8cY.d.ts} +4547 -842
  30. package/dist/{define-schema-DgCX9YB7.d.ts → define-schema-BPlZl4a2.d.cts} +258 -10
  31. package/dist/{define-schema-DkXwpp0I.d.cts → define-schema-CK7TtYot.d.ts} +258 -10
  32. package/dist/dev-handshake/index.cjs +9 -9
  33. package/dist/dev-handshake/index.js +2 -2
  34. package/dist/extensions/index.cjs +100 -0
  35. package/dist/extensions/index.d.cts +6 -0
  36. package/dist/extensions/index.d.ts +6 -0
  37. package/dist/extensions/index.js +96 -0
  38. package/dist/functions/index.cjs +71 -0
  39. package/dist/functions/index.d.cts +6 -0
  40. package/dist/functions/index.d.ts +6 -0
  41. package/dist/functions/index.js +62 -0
  42. package/dist/{index-BBp8_tn9.d.ts → index-BxNnlc5D.d.ts} +167 -494
  43. package/dist/{index-DaMZ4FQ_.d.ts → index-C-MymZTe.d.ts} +1 -1
  44. package/dist/{index-DxRmKPrR.d.cts → index-D5jyIeQ5.d.cts} +167 -494
  45. package/dist/{index-Bp4AiNT3.d.cts → index-DN0l8RHw.d.cts} +1 -1
  46. package/dist/index.cjs +208 -185
  47. package/dist/index.d.cts +147 -17
  48. package/dist/index.d.ts +147 -17
  49. package/dist/index.js +11 -16
  50. package/dist/markdown/index.cjs +382 -382
  51. package/dist/markdown/index.js +1 -1
  52. package/dist/preview/index.cjs +11 -10
  53. package/dist/preview/index.js +3 -2
  54. package/dist/register-BiMQKVp-.d.ts +693 -0
  55. package/dist/register-DeMsaurp.d.cts +693 -0
  56. package/dist/rich-text/index.cjs +12 -12
  57. package/dist/rich-text/index.d.cts +2 -2
  58. package/dist/rich-text/index.d.ts +2 -2
  59. package/dist/rich-text/index.js +2 -2
  60. package/dist/schema/index.cjs +63 -34
  61. package/dist/schema/index.d.cts +14 -5
  62. package/dist/schema/index.d.ts +14 -5
  63. package/dist/schema/index.js +3 -2
  64. package/dist/types/index.d.cts +1 -1
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/utils/index.cjs +20 -20
  67. package/dist/utils/index.js +2 -2
  68. package/package.json +23 -5
  69. package/dist/chunk-6PTRZP5U.cjs +0 -433
  70. package/dist/chunk-DIZY6CKM.js +0 -950
  71. package/dist/chunk-GHYB6IZK.cjs +0 -983
  72. package/dist/chunk-MWMSFIWN.cjs +0 -17
  73. package/dist/chunk-OVMIHAYK.js +0 -411
  74. package/dist/chunk-XQ4QHWZE.js +0 -13
@@ -1,4 +1,4 @@
1
- import { __name } from './chunk-XQ4QHWZE.js';
1
+ import { __name } from './chunk-DI6KFDBO.js';
2
2
 
3
3
  /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
4
4
 
@@ -77,5 +77,5 @@ function parseDevEnv(env, now) {
77
77
  __name(parseDevEnv, "parseDevEnv");
78
78
 
79
79
  export { DEV_CONTEXT_DIR, DEV_CONTEXT_FILE, DEV_CONTEXT_FILENAME, DEV_ENV, buildDevEnv, parseDevContextFile, parseDevEnv };
80
- //# sourceMappingURL=chunk-BBUB7C2Z.js.map
81
- //# sourceMappingURL=chunk-BBUB7C2Z.js.map
80
+ //# sourceMappingURL=chunk-W2A4OTCI.js.map
81
+ //# sourceMappingURL=chunk-W2A4OTCI.js.map
@@ -0,0 +1,520 @@
1
+ import { conditionRoot, compileKeyedMembers } from './chunk-PZCDJFMA.js';
2
+ import { __name } from './chunk-DI6KFDBO.js';
3
+
4
+ /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
5
+
6
+ // src/automations/index.ts
7
+ var REF = /* @__PURE__ */ Symbol("relyio.automation.ref");
8
+ var TEMPLATE = /* @__PURE__ */ Symbol("relyio.automation.template");
9
+ var TESTS = /* @__PURE__ */ new Set([
10
+ "eq",
11
+ "ne",
12
+ "gt",
13
+ "gte",
14
+ "lt",
15
+ "lte",
16
+ "in",
17
+ "nin",
18
+ "exists",
19
+ "isNull",
20
+ "isEmpty",
21
+ "hasValue",
22
+ "contains",
23
+ "notContains",
24
+ "between"
25
+ ]);
26
+ function refAt(root, path, becomes) {
27
+ return new Proxy(/* @__PURE__ */ Object.create(null), {
28
+ get(_target, key) {
29
+ if (key === REF) return { kind: "ref", root, path };
30
+ if (typeof key !== "string" || key === "then") return void 0;
31
+ if (TESTS.has(key)) return conditionRoot(root, path)[key];
32
+ if (becomes && key === "becomes") {
33
+ return (value) => ({
34
+ root: "event",
35
+ path,
36
+ operator: "becomes",
37
+ value
38
+ });
39
+ }
40
+ return refAt(root, [...path, key], becomes);
41
+ }
42
+ });
43
+ }
44
+ __name(refAt, "refAt");
45
+ function refOf(value) {
46
+ if (typeof value !== "object" || value === null) return void 0;
47
+ const held = value[REF];
48
+ return held === void 0 ? void 0 : held;
49
+ }
50
+ __name(refOf, "refOf");
51
+ function tpl(strings, ...values) {
52
+ const parts = [];
53
+ const literal = /* @__PURE__ */ __name((text) => {
54
+ const last = parts[parts.length - 1];
55
+ if (typeof last === "string") parts[parts.length - 1] = last + text;
56
+ else if (text !== "") parts.push(text);
57
+ }, "literal");
58
+ for (const [index, text] of strings.entries()) {
59
+ literal(text);
60
+ if (index >= values.length) continue;
61
+ const value = values[index];
62
+ const ref = refOf(value);
63
+ if (ref === void 0) literal(String(value));
64
+ else parts.push(ref);
65
+ }
66
+ return { [TEMPLATE]: parts };
67
+ }
68
+ __name(tpl, "tpl");
69
+ function isPlainObject(value) {
70
+ if (typeof value !== "object" || value === null) return false;
71
+ const prototype = Object.getPrototypeOf(value);
72
+ return prototype === Object.prototype || prototype === null;
73
+ }
74
+ __name(isPlainObject, "isPlainObject");
75
+ function valueOf(value, at) {
76
+ const ref = refOf(value);
77
+ if (ref !== void 0) return ref;
78
+ if (typeof value === "object" && value !== null && TEMPLATE in value) {
79
+ return { kind: "template", parts: [...value[TEMPLATE]] };
80
+ }
81
+ if (Array.isArray(value)) {
82
+ const items = value.map((item, index) => valueOf(item, `${at}[${index}]`));
83
+ return items.every((item) => item.kind === "literal") ? { kind: "literal", value: items.map((item) => item.value) } : { kind: "list", items };
84
+ }
85
+ if (isPlainObject(value)) {
86
+ const entries2 = Object.entries(value).filter(([, held]) => held !== void 0).map(([key, held]) => [key, valueOf(held, `${at}.${key}`)]);
87
+ return entries2.every(([, held]) => held.kind === "literal") ? {
88
+ kind: "literal",
89
+ value: Object.fromEntries(
90
+ entries2.map(([key, held]) => [key, held.value])
91
+ )
92
+ } : { kind: "object", fields: Object.fromEntries(entries2) };
93
+ }
94
+ if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
95
+ return { kind: "literal", value };
96
+ }
97
+ throw new TypeError(
98
+ `${at} is ${typeof value}: a step is handed data \u2014 a value, a reference or tpl\`\u2026\` \u2014 never code`
99
+ );
100
+ }
101
+ __name(valueOf, "valueOf");
102
+ function inputOf(input, at) {
103
+ return Object.fromEntries(
104
+ Object.entries(input).filter(([, value]) => value !== void 0).map(([key, value]) => [key, valueOf(value, `${at}.${key}`)])
105
+ );
106
+ }
107
+ __name(inputOf, "inputOf");
108
+ function and(...conditions) {
109
+ return { and: conditions };
110
+ }
111
+ __name(and, "and");
112
+ function or(...conditions) {
113
+ return { or: conditions };
114
+ }
115
+ __name(or, "or");
116
+ function not(condition) {
117
+ return { not: condition };
118
+ }
119
+ __name(not, "not");
120
+ var FIELD_OPERATORS = ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin", "exists"];
121
+ function whereOf(where, item) {
122
+ if (typeof where === "function") {
123
+ return where(refAt("event", [], true));
124
+ }
125
+ if (!isPlainObject(where)) {
126
+ throw new TypeError(
127
+ "A where is { field: value | { becomes, eq, \u2026 } }, or a function of the event"
128
+ );
129
+ }
130
+ const tests = [];
131
+ for (const [field, held] of Object.entries(where)) {
132
+ const path = [item, field];
133
+ if (!isPlainObject(held)) {
134
+ tests.push({ root: "event", path, operator: "eq", value: held });
135
+ continue;
136
+ }
137
+ for (const [operator, value] of Object.entries(held)) {
138
+ if (operator === "becomes") {
139
+ tests.push({ root: "event", path, operator: "becomes", value });
140
+ } else if (FIELD_OPERATORS.includes(operator)) {
141
+ tests.push({
142
+ root: "event",
143
+ path,
144
+ operator,
145
+ value
146
+ });
147
+ } else {
148
+ throw new TypeError(`where.${field}: ${operator} is not becomes or a list grammar operator`);
149
+ }
150
+ }
151
+ }
152
+ const [only] = tests;
153
+ return tests.length === 1 && only !== void 0 ? only : { and: tests };
154
+ }
155
+ __name(whereOf, "whereOf");
156
+ var ITEM = /* @__PURE__ */ Symbol("relyio.automation.item");
157
+ var ITEM_REF = /* @__PURE__ */ Symbol("relyio.automation.item-ref");
158
+ function uidOf(uid, at) {
159
+ const value = valueOf(uid, at);
160
+ if (value.kind === "ref") return value;
161
+ if (value.kind === "literal" && typeof value.value === "string" && value.value !== "") {
162
+ return value;
163
+ }
164
+ throw new TypeError(
165
+ `${at} is a uid: a reference to one (event.record._metadata.id, a reference field, an earlier step's output) or a uid written out`
166
+ );
167
+ }
168
+ __name(uidOf, "uidOf");
169
+ function itemRefOf(type, uid, at) {
170
+ const held = uidOf(uid, at);
171
+ return type.kind === "record" ? { kind: "record", recordType: type.recordType, uid: held } : { kind: "entry", contentType: type.contentType, uid: held };
172
+ }
173
+ __name(itemRefOf, "itemRefOf");
174
+ var RECORD_ACTIONS = [
175
+ "created",
176
+ "updated",
177
+ "deleted",
178
+ "expired"
179
+ ];
180
+ var ENTRY_ACTIONS = [
181
+ "created",
182
+ "updated",
183
+ "published",
184
+ "unpublished",
185
+ "deleted",
186
+ "archived",
187
+ "restored"
188
+ ];
189
+ function triggersByType(make) {
190
+ return new Proxy(/* @__PURE__ */ Object.create(null), {
191
+ get(_target, key) {
192
+ if (typeof key !== "string" || key === "then") return void 0;
193
+ return make(key);
194
+ }
195
+ });
196
+ }
197
+ __name(triggersByType, "triggersByType");
198
+ function itemHandleOf(type) {
199
+ const name = type.kind === "record" ? `records.${type.recordType}` : `entries.${type.contentType}`;
200
+ return {
201
+ [ITEM]: type,
202
+ ref: /* @__PURE__ */ __name((uid) => ({
203
+ [ITEM_REF]: itemRefOf(type, uid, `${name}.ref`)
204
+ }), "ref")
205
+ };
206
+ }
207
+ __name(itemHandleOf, "itemHandleOf");
208
+ var records = triggersByType((recordType) => ({
209
+ ...itemHandleOf({ kind: "record", recordType }),
210
+ ...Object.fromEntries(
211
+ RECORD_ACTIONS.map((action) => [
212
+ action,
213
+ (options) => ({
214
+ trigger: {
215
+ kind: "record",
216
+ recordType,
217
+ action,
218
+ ...options?.where === void 0 ? {} : { where: whereOf(options.where, "record") }
219
+ }
220
+ })
221
+ ])
222
+ )
223
+ }));
224
+ var entries = triggersByType((contentType) => ({
225
+ ...itemHandleOf({ kind: "entry", contentType }),
226
+ ...Object.fromEntries(
227
+ ENTRY_ACTIONS.map((action) => [
228
+ action,
229
+ (options) => ({
230
+ trigger: {
231
+ kind: "entry",
232
+ contentType,
233
+ action,
234
+ ...options?.where === void 0 ? {} : { where: whereOf(options.where, "entry") }
235
+ }
236
+ })
237
+ ])
238
+ )
239
+ }));
240
+ var anyEntry = Object.fromEntries(
241
+ ENTRY_ACTIONS.map((action) => [
242
+ action,
243
+ (options) => {
244
+ const where = options?.where;
245
+ return {
246
+ trigger: {
247
+ kind: "anyEntry",
248
+ action,
249
+ ...where === void 0 ? {} : { where: where(refAt("event", [], false)) }
250
+ }
251
+ };
252
+ }
253
+ ])
254
+ );
255
+ var schedule = {
256
+ cron(cron, options) {
257
+ return { trigger: { kind: "schedule", cron, timezone: options.timezone } };
258
+ }
259
+ };
260
+ var RUN_FAILED_PATHS = {
261
+ automation: ["automation"],
262
+ step: ["step", "name"],
263
+ code: ["error", "code"]
264
+ };
265
+ function runFailedWhereOf(where) {
266
+ if (typeof where === "function") {
267
+ return where(refAt("event", [], false));
268
+ }
269
+ if (!isPlainObject(where)) {
270
+ throw new TypeError(
271
+ "A failed run\u2019s where is { automation, step, code }, or a function of the event"
272
+ );
273
+ }
274
+ const tests = [];
275
+ for (const [name, held] of Object.entries(where)) {
276
+ if (!Object.keys(RUN_FAILED_PATHS).includes(name)) {
277
+ throw new TypeError(`where.${name}: a failed run is filtered on automation, step and code`);
278
+ }
279
+ const path = RUN_FAILED_PATHS[name];
280
+ if (!isPlainObject(held)) {
281
+ tests.push({ root: "event", path, operator: "eq", value: held });
282
+ continue;
283
+ }
284
+ for (const [operator, value] of Object.entries(held)) {
285
+ if (!FIELD_OPERATORS.includes(operator)) {
286
+ throw new TypeError(`where.${name}: ${operator} is not a list grammar operator`);
287
+ }
288
+ tests.push({
289
+ root: "event",
290
+ path,
291
+ operator,
292
+ value
293
+ });
294
+ }
295
+ }
296
+ const [only] = tests;
297
+ return tests.length === 1 && only !== void 0 ? only : { and: tests };
298
+ }
299
+ __name(runFailedWhereOf, "runFailedWhereOf");
300
+ var automations = {
301
+ runFailed(options) {
302
+ return {
303
+ trigger: {
304
+ kind: "runFailed",
305
+ ...options?.where === void 0 ? {} : { where: runFailedWhereOf(options.where) }
306
+ }
307
+ };
308
+ }
309
+ };
310
+ function extensionTrigger(extension, trigger, options) {
311
+ const where = options?.where;
312
+ return {
313
+ trigger: {
314
+ kind: "extension",
315
+ extension,
316
+ trigger,
317
+ ...where === void 0 ? {} : { where: where(refAt("event", [], false)) }
318
+ }
319
+ };
320
+ }
321
+ __name(extensionTrigger, "extensionTrigger");
322
+ var on = { records, entries, anyEntry, schedule, automations };
323
+ var STEP = /* @__PURE__ */ Symbol("relyio.automation.step");
324
+ var ASK_DEFAULT_ROLES = ["editor", "admin"];
325
+ var ASK_DEFAULT_TIMEOUT = "7d";
326
+ var APPROVE_CHOICES = ["approve", "reject"];
327
+ function handle(draft, output) {
328
+ const step = { name: draft.name, [STEP]: draft };
329
+ if (!output) return step;
330
+ const withOutput = {
331
+ ...step,
332
+ output: refAt(draft.name, ["output"], false)
333
+ };
334
+ return withOutput;
335
+ }
336
+ __name(handle, "handle");
337
+ function draftsOf(steps, at) {
338
+ return steps.map((step, index) => {
339
+ const draft = step[STEP];
340
+ if (draft === void 0) {
341
+ throw new TypeError(`${at}[${index}] is not a step: build one with step.fn, step.if, \u2026`);
342
+ }
343
+ return draft;
344
+ });
345
+ }
346
+ __name(draftsOf, "draftsOf");
347
+ var STEP_BUILDER = {
348
+ fn(name, fn, input) {
349
+ return handle(
350
+ { kind: "function", name, function: fn, input: inputOf(input, `${name}.input`) },
351
+ true
352
+ );
353
+ },
354
+ agent(name, config) {
355
+ const { propose } = config;
356
+ return handle(
357
+ {
358
+ kind: "agent",
359
+ name,
360
+ ...config.agent === void 0 ? {} : { agent: config.agent },
361
+ instructions: valueOf(config.instructions, `${name}.instructions`),
362
+ context: inputOf(config.context ?? {}, `${name}.context`),
363
+ output: compileKeyedMembers(config.output),
364
+ ...propose === void 0 ? {} : {
365
+ propose: propose.map(
366
+ (type, index) => proposeTargetOf(type, `${name}.propose[${index}]`)
367
+ )
368
+ }
369
+ },
370
+ true
371
+ );
372
+ },
373
+ action(name, action, input) {
374
+ return handle(
375
+ {
376
+ kind: "action",
377
+ name,
378
+ extension: action.extension,
379
+ action: action.action,
380
+ input: inputOf(input, `${name}.input`)
381
+ },
382
+ true
383
+ );
384
+ },
385
+ lookup(name, type, uidOrOptions, options) {
386
+ const held = type ?? {};
387
+ let item;
388
+ let given;
389
+ if (held[ITEM_REF] !== void 0) {
390
+ item = held[ITEM_REF];
391
+ given = uidOrOptions;
392
+ } else if (held[ITEM] !== void 0) {
393
+ item = itemRefOf(held[ITEM], uidOrOptions, `${name}.uid`);
394
+ given = options;
395
+ } else {
396
+ throw new TypeError(
397
+ `${name} looks up a Record or entry type \u2014 records.<type>, entries.<type> \u2014 or one item, <type>.ref(uid)`
398
+ );
399
+ }
400
+ const { state } = given ?? {};
401
+ if (item.kind === "record") {
402
+ if (state !== void 0) {
403
+ throw new TypeError(`${name}: a Record has no draft; state is an entry Look-up's alone`);
404
+ }
405
+ return handle({ kind: "lookup", name, item }, true);
406
+ }
407
+ return handle({ kind: "lookup", name, item, state: state ?? "published" }, true);
408
+ },
409
+ if(name, condition, branches) {
410
+ return handle(
411
+ {
412
+ kind: "if",
413
+ name,
414
+ condition,
415
+ then: draftsOf(branches.then ?? [], `${name}.then`),
416
+ else: draftsOf(branches.else ?? [], `${name}.else`)
417
+ },
418
+ false
419
+ );
420
+ },
421
+ wait(name, duration) {
422
+ return handle({ kind: "wait", name, duration }, false);
423
+ },
424
+ ask(name, config) {
425
+ const approving = "approve" in config;
426
+ const approve = approving ? valueOf(config.approve, `${name}.approve`) : void 0;
427
+ if (approve !== void 0 && approve.kind !== "ref") {
428
+ throw new TypeError(`${name}.approve names an Agent step's proposal: <step>.output.proposal`);
429
+ }
430
+ return handle(
431
+ {
432
+ kind: "ask",
433
+ name,
434
+ to: [...config.to ?? ASK_DEFAULT_ROLES],
435
+ question: valueOf(config.question, `${name}.question`),
436
+ choices: approving ? [...APPROVE_CHOICES] : [...config.choices],
437
+ timeout: config.timeout ?? ASK_DEFAULT_TIMEOUT,
438
+ ...config.onTimeout === void 0 ? {} : { onTimeout: config.onTimeout },
439
+ ...config.sample === void 0 ? {} : { sample: config.sample },
440
+ ...approve === void 0 ? {} : { approve }
441
+ },
442
+ true
443
+ );
444
+ }
445
+ };
446
+ function proposeTargetOf(type, at) {
447
+ const held = type ?? {};
448
+ const named = held[ITEM];
449
+ if (named === void 0) {
450
+ throw new TypeError(`${at} is a Record or content type: records.<type>, entries.<type>`);
451
+ }
452
+ return named.kind === "record" ? { kind: "record", recordType: named.recordType } : { kind: "entry", contentType: named.contentType };
453
+ }
454
+ __name(proposeTargetOf, "proposeTargetOf");
455
+ function defineAutomation(config) {
456
+ const event = refAt("event", [], false);
457
+ const steps = config.steps({ event, step: STEP_BUILDER });
458
+ return {
459
+ _tag: "automation",
460
+ ...config.description === void 0 ? {} : { description: config.description },
461
+ on: config.on.trigger,
462
+ ...config.about === void 0 ? {} : { about: aboutOf(config.about({ event })) },
463
+ steps: draftsOf(steps, "steps")
464
+ };
465
+ }
466
+ __name(defineAutomation, "defineAutomation");
467
+ function aboutOf(handle2) {
468
+ const item = handle2?.[ITEM_REF];
469
+ if (item === void 0) {
470
+ throw new TypeError(
471
+ "about is one Record or entry: return records.<type>.ref(uid) or entries.<type>.ref(uid)"
472
+ );
473
+ }
474
+ return item;
475
+ }
476
+ __name(aboutOf, "aboutOf");
477
+ function isAutomationFile(value) {
478
+ return typeof value === "object" && value !== null && value._tag === "automation" && Array.isArray(value.steps) && typeof value.on === "object";
479
+ }
480
+ __name(isAutomationFile, "isAutomationFile");
481
+ function resolveAutomation(file, nameOf) {
482
+ const resolve = /* @__PURE__ */ __name((steps) => steps.map((step) => {
483
+ switch (step.kind) {
484
+ case "function": {
485
+ const name = nameOf(step.function);
486
+ if (name === void 0) {
487
+ throw new Error(
488
+ `Step ${step.name} takes a Function no file under relyio/functions/ exports: import the Function file's default export`
489
+ );
490
+ }
491
+ return { kind: "function", name: step.name, function: name, input: step.input };
492
+ }
493
+ case "if": {
494
+ return { ...step, then: resolve(step.then), else: resolve(step.else) };
495
+ }
496
+ case "agent":
497
+ case "action":
498
+ case "lookup":
499
+ case "wait":
500
+ case "ask": {
501
+ return step;
502
+ }
503
+ default: {
504
+ const unhandled = step;
505
+ throw new Error(`No step kind ${JSON.stringify(unhandled)}`);
506
+ }
507
+ }
508
+ }), "resolve");
509
+ return {
510
+ ...file.description === void 0 ? {} : { description: file.description },
511
+ on: file.on,
512
+ ...file.about === void 0 ? {} : { about: file.about },
513
+ steps: resolve(file.steps)
514
+ };
515
+ }
516
+ __name(resolveAutomation, "resolveAutomation");
517
+
518
+ export { and, anyEntry, automations, defineAutomation, entries, extensionTrigger, isAutomationFile, not, on, or, records, resolveAutomation, schedule, tpl };
519
+ //# sourceMappingURL=chunk-W2GRVXDG.js.map
520
+ //# sourceMappingURL=chunk-W2GRVXDG.js.map
@@ -1,4 +1,4 @@
1
- import { __name } from './chunk-XQ4QHWZE.js';
1
+ import { __name } from './chunk-DI6KFDBO.js';
2
2
 
3
3
  /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
4
4
 
@@ -1088,5 +1088,5 @@ function escapeLineStarts(paragraph) {
1088
1088
  __name(escapeLineStarts, "escapeLineStarts");
1089
1089
 
1090
1090
  export { RICH_TEXT_VOID_TAGS, entryHeadingAnchors, escapeHtml, formatKeyPath, isDeclaredRichTextNode, parseKeyPath, relyioField, renderRichText, richTextHeadingAnchors, richTextHeadingSlug, richTextToHtml, richTextToMarkdown, safeRichTextHref };
1091
- //# sourceMappingURL=chunk-5UMY6CS4.js.map
1092
- //# sourceMappingURL=chunk-5UMY6CS4.js.map
1091
+ //# sourceMappingURL=chunk-ZAKEY6DY.js.map
1092
+ //# sourceMappingURL=chunk-ZAKEY6DY.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMWMSFIWN_cjs = require('./chunk-MWMSFIWN.cjs');
3
+ var chunkL6DXCKVQ_cjs = require('./chunk-L6DXCKVQ.cjs');
4
4
 
5
5
  /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
6
6
 
@@ -20,7 +20,7 @@ function readDeadline(raw, now) {
20
20
  if (!Number.isFinite(deadline)) return { state: "unreadable" };
21
21
  return deadline <= now ? { state: "passed", expiredAt: raw } : { state: "live", expiresAt: raw };
22
22
  }
23
- chunkMWMSFIWN_cjs.__name(readDeadline, "readDeadline");
23
+ chunkL6DXCKVQ_cjs.__name(readDeadline, "readDeadline");
24
24
  function parseDevContextFile(raw, now) {
25
25
  let parsed;
26
26
  try {
@@ -46,7 +46,7 @@ function parseDevContextFile(raw, now) {
46
46
  };
47
47
  return deadline.state === "passed" ? { state: "expired", context, expiredAt: deadline.expiredAt } : { state: "active", context };
48
48
  }
49
- chunkMWMSFIWN_cjs.__name(parseDevContextFile, "parseDevContextFile");
49
+ chunkL6DXCKVQ_cjs.__name(parseDevContextFile, "parseDevContextFile");
50
50
  function buildDevEnv(context) {
51
51
  const env = {
52
52
  [DEV_ENV.dataset]: context.datasetId,
@@ -57,7 +57,7 @@ function buildDevEnv(context) {
57
57
  }
58
58
  return env;
59
59
  }
60
- chunkMWMSFIWN_cjs.__name(buildDevEnv, "buildDevEnv");
60
+ chunkL6DXCKVQ_cjs.__name(buildDevEnv, "buildDevEnv");
61
61
  function parseDevEnv(env, now) {
62
62
  const dataset = env?.[DEV_ENV.dataset];
63
63
  const apiKey = env?.[DEV_ENV.apiKey];
@@ -76,7 +76,7 @@ function parseDevEnv(env, now) {
76
76
  return { state: "active", credentials: { dataset, apiKey }, expiresAt: null };
77
77
  }
78
78
  }
79
- chunkMWMSFIWN_cjs.__name(parseDevEnv, "parseDevEnv");
79
+ chunkL6DXCKVQ_cjs.__name(parseDevEnv, "parseDevEnv");
80
80
 
81
81
  exports.DEV_CONTEXT_DIR = DEV_CONTEXT_DIR;
82
82
  exports.DEV_CONTEXT_FILE = DEV_CONTEXT_FILE;
@@ -85,5 +85,5 @@ exports.DEV_ENV = DEV_ENV;
85
85
  exports.buildDevEnv = buildDevEnv;
86
86
  exports.parseDevContextFile = parseDevContextFile;
87
87
  exports.parseDevEnv = parseDevEnv;
88
- //# sourceMappingURL=chunk-LSRPMNPT.cjs.map
89
- //# sourceMappingURL=chunk-LSRPMNPT.cjs.map
88
+ //# sourceMappingURL=chunk-ZO6QDYJG.cjs.map
89
+ //# sourceMappingURL=chunk-ZO6QDYJG.cjs.map
@@ -1,20 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunk6E22GYPB_cjs = require('../chunk-6E22GYPB.cjs');
4
- require('../chunk-LSRPMNPT.cjs');
5
- require('../chunk-6PTRZP5U.cjs');
6
- require('../chunk-TZL374LS.cjs');
7
- require('../chunk-MWMSFIWN.cjs');
3
+ var chunkP23G5NXD_cjs = require('../chunk-P23G5NXD.cjs');
4
+ require('../chunk-M7MWNV3Q.cjs');
5
+ require('../chunk-ZO6QDYJG.cjs');
6
+ require('../chunk-7I3SC7SV.cjs');
7
+ require('../chunk-NN45CSPZ.cjs');
8
+ require('../chunk-L6DXCKVQ.cjs');
8
9
 
9
10
 
10
11
 
11
12
  Object.defineProperty(exports, "TypedRelyIOClient", {
12
13
  enumerable: true,
13
- get: function () { return chunk6E22GYPB_cjs.TypedRelyIOClient; }
14
+ get: function () { return chunkP23G5NXD_cjs.TypedRelyIOClient; }
14
15
  });
15
16
  Object.defineProperty(exports, "createClient", {
16
17
  enumerable: true,
17
- get: function () { return chunk6E22GYPB_cjs.createClient; }
18
+ get: function () { return chunkP23G5NXD_cjs.createClient; }
18
19
  });
19
20
  //# sourceMappingURL=index.cjs.map
20
21
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,6 @@
1
- export { e as ClientDefaults, f as ClientSchema, R as Register, h as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-DxRmKPrR.cjs';
2
- import '../define-content-type-AuL9-oz6.cjs';
1
+ export { e as ClientDefaults, f as ClientSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-D5jyIeQ5.cjs';
2
+ export { c as Register, R as RegisteredSchema } from '../register-DeMsaurp.cjs';
3
+ import '../define-content-type-BZ6X8GvL.cjs';
3
4
  import '../rich-text.d-BWc-5gX1.cjs';
4
- import '../define-schema-DkXwpp0I.cjs';
5
+ import '../define-schema-BPlZl4a2.cjs';
5
6
  import '../dev-handshake/index.cjs';
@@ -1,5 +1,6 @@
1
- export { e as ClientDefaults, f as ClientSchema, R as Register, h as RegisteredSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-BBp8_tn9.js';
2
- import '../define-content-type-BGoQxqLf.js';
1
+ export { e as ClientDefaults, f as ClientSchema, d as TypedClientConfig, T as TypedRelyIOClient, c as createClient } from '../index-BxNnlc5D.js';
2
+ export { c as Register, R as RegisteredSchema } from '../register-BiMQKVp-.js';
3
+ import '../define-content-type-C12jh8cY.js';
3
4
  import '../rich-text.d-BWc-5gX1.js';
4
- import '../define-schema-DgCX9YB7.js';
5
+ import '../define-schema-CK7TtYot.js';
5
6
  import '../dev-handshake/index.js';
@@ -1,7 +1,8 @@
1
- export { TypedRelyIOClient, createClient } from '../chunk-VS2DEUTN.js';
2
- import '../chunk-BBUB7C2Z.js';
3
- import '../chunk-OVMIHAYK.js';
4
- import '../chunk-H6IBQSMM.js';
5
- import '../chunk-XQ4QHWZE.js';
1
+ export { TypedRelyIOClient, createClient } from '../chunk-356SF5Y2.js';
2
+ import '../chunk-NJQK5STK.js';
3
+ import '../chunk-W2A4OTCI.js';
4
+ import '../chunk-HDHBYYEY.js';
5
+ import '../chunk-T7LGREB3.js';
6
+ import '../chunk-DI6KFDBO.js';
6
7
  //# sourceMappingURL=index.js.map
7
8
  //# sourceMappingURL=index.js.map