@teamkeel/functions-runtime 0.413.4 → 0.413.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +36 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +36 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -497,7 +497,7 @@ interface BaseInputConfig<T> {
|
|
|
497
497
|
helpText?: string;
|
|
498
498
|
optional?: boolean;
|
|
499
499
|
disabled?: boolean;
|
|
500
|
-
validate?: (data: T) => Promise<
|
|
500
|
+
validate?: (data: T) => Promise<null | string> | string | null;
|
|
501
501
|
}
|
|
502
502
|
interface BaseUiInputResponse<K, TData> {
|
|
503
503
|
__type: K;
|
|
@@ -507,6 +507,7 @@ interface BaseUiInputResponse<K, TData> {
|
|
|
507
507
|
helpText?: string;
|
|
508
508
|
optional?: boolean;
|
|
509
509
|
disabled?: boolean;
|
|
510
|
+
validationError?: string;
|
|
510
511
|
}
|
|
511
512
|
interface BaseUiDisplayResponse<K> {
|
|
512
513
|
__type: K;
|
package/dist/index.d.ts
CHANGED
|
@@ -497,7 +497,7 @@ interface BaseInputConfig<T> {
|
|
|
497
497
|
helpText?: string;
|
|
498
498
|
optional?: boolean;
|
|
499
499
|
disabled?: boolean;
|
|
500
|
-
validate?: (data: T) => Promise<
|
|
500
|
+
validate?: (data: T) => Promise<null | string> | string | null;
|
|
501
501
|
}
|
|
502
502
|
interface BaseUiInputResponse<K, TData> {
|
|
503
503
|
__type: K;
|
|
@@ -507,6 +507,7 @@ interface BaseUiInputResponse<K, TData> {
|
|
|
507
507
|
helpText?: string;
|
|
508
508
|
optional?: boolean;
|
|
509
509
|
disabled?: boolean;
|
|
510
|
+
validationError?: string;
|
|
510
511
|
}
|
|
511
512
|
interface BaseUiDisplayResponse<K> {
|
|
512
513
|
__type: K;
|
package/dist/index.js
CHANGED
|
@@ -2417,18 +2417,39 @@ var selectOne = /* @__PURE__ */ __name((name, options) => {
|
|
|
2417
2417
|
}, "selectOne");
|
|
2418
2418
|
|
|
2419
2419
|
// src/flows/ui/page.ts
|
|
2420
|
-
|
|
2420
|
+
async function page(options, data) {
|
|
2421
2421
|
const content = options.content;
|
|
2422
|
-
|
|
2422
|
+
let hasValidationErrors = false;
|
|
2423
|
+
const contentUiConfig = await Promise.all(
|
|
2424
|
+
content.map(async (c) => {
|
|
2425
|
+
const isInput = "__type" in c && c.__type == "input";
|
|
2426
|
+
const hasData = data && c.uiConfig.name in data;
|
|
2427
|
+
if (isInput && hasData && c.validate) {
|
|
2428
|
+
const validationError = await c.validate(data[c.uiConfig.name]);
|
|
2429
|
+
if (typeof validationError === "string") {
|
|
2430
|
+
hasValidationErrors = true;
|
|
2431
|
+
return {
|
|
2432
|
+
...c.uiConfig,
|
|
2433
|
+
validationError
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
return c.uiConfig;
|
|
2438
|
+
}).filter(Boolean)
|
|
2439
|
+
);
|
|
2423
2440
|
return {
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2441
|
+
page: {
|
|
2442
|
+
__type: "ui.page",
|
|
2443
|
+
stage: options.stage,
|
|
2444
|
+
title: options.title,
|
|
2445
|
+
description: options.description,
|
|
2446
|
+
content: contentUiConfig,
|
|
2447
|
+
actions: options.actions
|
|
2448
|
+
},
|
|
2449
|
+
hasValidationErrors
|
|
2430
2450
|
};
|
|
2431
|
-
}
|
|
2451
|
+
}
|
|
2452
|
+
__name(page, "page");
|
|
2432
2453
|
|
|
2433
2454
|
// src/flows/disrupts.ts
|
|
2434
2455
|
var FlowDisrupt = class {
|
|
@@ -2642,10 +2663,14 @@ function createFlowContext(runId, data, spanId) {
|
|
|
2642
2663
|
type: "UI" /* UI */,
|
|
2643
2664
|
startTime: /* @__PURE__ */ new Date()
|
|
2644
2665
|
}).returningAll().executeTakeFirst();
|
|
2645
|
-
throw new UIRenderDisrupt(step?.id, page(options));
|
|
2666
|
+
throw new UIRenderDisrupt(step?.id, (await page(options, null)).page);
|
|
2646
2667
|
}
|
|
2647
2668
|
if (!data) {
|
|
2648
|
-
throw new UIRenderDisrupt(step?.id, page(options));
|
|
2669
|
+
throw new UIRenderDisrupt(step?.id, (await page(options, null)).page);
|
|
2670
|
+
}
|
|
2671
|
+
const p = await page(options, data);
|
|
2672
|
+
if (p.hasValidationErrors) {
|
|
2673
|
+
throw new UIRenderDisrupt(step?.id, p.page);
|
|
2649
2674
|
}
|
|
2650
2675
|
await db.updateTable("keel.flow_step").set({
|
|
2651
2676
|
status: "COMPLETED" /* COMPLETED */,
|