@teamkeel/functions-runtime 0.413.3 → 0.413.5
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 +55 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +55 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/oas.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2318,7 +2318,7 @@ async function handleRoute(request, config) {
|
|
|
2318
2318
|
}
|
|
2319
2319
|
__name(handleRoute, "handleRoute");
|
|
2320
2320
|
|
|
2321
|
-
// src/handleFlow.
|
|
2321
|
+
// src/handleFlow.ts
|
|
2322
2322
|
var import_json_rpc_26 = require("json-rpc-2.0");
|
|
2323
2323
|
var opentelemetry6 = __toESM(require("@opentelemetry/api"), 1);
|
|
2324
2324
|
|
|
@@ -2441,18 +2441,39 @@ var selectOne = /* @__PURE__ */ __name((name, options) => {
|
|
|
2441
2441
|
}, "selectOne");
|
|
2442
2442
|
|
|
2443
2443
|
// src/flows/ui/page.ts
|
|
2444
|
-
|
|
2444
|
+
async function page(options, data) {
|
|
2445
2445
|
const content = options.content;
|
|
2446
|
-
|
|
2446
|
+
let hasValidationErrors = false;
|
|
2447
|
+
const contentUiConfig = await Promise.all(
|
|
2448
|
+
content.map(async (c) => {
|
|
2449
|
+
const isInput = "__type" in c && c.__type == "input";
|
|
2450
|
+
const hasData = data && c.uiConfig.name in data;
|
|
2451
|
+
if (isInput && hasData && c.validate) {
|
|
2452
|
+
const validationError = await c.validate(data[c.uiConfig.name]);
|
|
2453
|
+
if (typeof validationError === "string") {
|
|
2454
|
+
hasValidationErrors = true;
|
|
2455
|
+
return {
|
|
2456
|
+
...c.uiConfig,
|
|
2457
|
+
validationError
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return c.uiConfig;
|
|
2462
|
+
}).filter(Boolean)
|
|
2463
|
+
);
|
|
2447
2464
|
return {
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2465
|
+
page: {
|
|
2466
|
+
__type: "ui.page",
|
|
2467
|
+
stage: options.stage,
|
|
2468
|
+
title: options.title,
|
|
2469
|
+
description: options.description,
|
|
2470
|
+
content: contentUiConfig,
|
|
2471
|
+
actions: options.actions
|
|
2472
|
+
},
|
|
2473
|
+
hasValidationErrors
|
|
2454
2474
|
};
|
|
2455
|
-
}
|
|
2475
|
+
}
|
|
2476
|
+
__name(page, "page");
|
|
2456
2477
|
|
|
2457
2478
|
// src/flows/disrupts.ts
|
|
2458
2479
|
var FlowDisrupt = class {
|
|
@@ -2666,10 +2687,14 @@ function createFlowContext(runId, data, spanId) {
|
|
|
2666
2687
|
type: "UI" /* UI */,
|
|
2667
2688
|
startTime: /* @__PURE__ */ new Date()
|
|
2668
2689
|
}).returningAll().executeTakeFirst();
|
|
2669
|
-
throw new UIRenderDisrupt(step?.id, page(options));
|
|
2690
|
+
throw new UIRenderDisrupt(step?.id, (await page(options, null)).page);
|
|
2670
2691
|
}
|
|
2671
2692
|
if (!data) {
|
|
2672
|
-
throw new UIRenderDisrupt(step?.id, page(options));
|
|
2693
|
+
throw new UIRenderDisrupt(step?.id, (await page(options, null)).page);
|
|
2694
|
+
}
|
|
2695
|
+
const p = await page(options, data);
|
|
2696
|
+
if (p.hasValidationErrors) {
|
|
2697
|
+
throw new UIRenderDisrupt(step?.id, p.page);
|
|
2673
2698
|
}
|
|
2674
2699
|
await db.updateTable("keel.flow_step").set({
|
|
2675
2700
|
status: "COMPLETED" /* COMPLETED */,
|
|
@@ -2716,7 +2741,8 @@ function withTimeout(promiseFn, timeout) {
|
|
|
2716
2741
|
}
|
|
2717
2742
|
__name(withTimeout, "withTimeout");
|
|
2718
2743
|
|
|
2719
|
-
// src/handleFlow.
|
|
2744
|
+
// src/handleFlow.ts
|
|
2745
|
+
var import_change_case2 = require("change-case");
|
|
2720
2746
|
async function handleFlow(request, config) {
|
|
2721
2747
|
const activeContext = opentelemetry6.propagation.extract(
|
|
2722
2748
|
opentelemetry6.context.active(),
|
|
@@ -2757,7 +2783,20 @@ async function handleFlow(request, config) {
|
|
|
2757
2783
|
span.spanContext().spanId
|
|
2758
2784
|
);
|
|
2759
2785
|
const flowFunction = flows[request.method].fn;
|
|
2760
|
-
|
|
2786
|
+
const rawFlowConfig = flows[request.method].config;
|
|
2787
|
+
flowConfig = {
|
|
2788
|
+
...rawFlowConfig,
|
|
2789
|
+
title: rawFlowConfig.title || (0, import_change_case2.sentenceCase)(request.method || "flow"),
|
|
2790
|
+
stages: rawFlowConfig.stages?.map((stage) => {
|
|
2791
|
+
if (typeof stage === "string") {
|
|
2792
|
+
return {
|
|
2793
|
+
key: stage,
|
|
2794
|
+
name: stage
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
return stage;
|
|
2798
|
+
})
|
|
2799
|
+
};
|
|
2761
2800
|
const inputs = parseInputs(flowRun.input);
|
|
2762
2801
|
try {
|
|
2763
2802
|
await tryExecuteFlow(db, async () => {
|
|
@@ -2782,7 +2821,7 @@ async function handleFlow(request, config) {
|
|
|
2782
2821
|
span.recordException(e);
|
|
2783
2822
|
span.setStatus({
|
|
2784
2823
|
code: opentelemetry6.SpanStatusCode.ERROR,
|
|
2785
|
-
message: e.message
|
|
2824
|
+
message: e instanceof Error ? e.message : "unknown error"
|
|
2786
2825
|
});
|
|
2787
2826
|
if (e instanceof ExhuastedRetriesDisrupt) {
|
|
2788
2827
|
return (0, import_json_rpc_26.createJSONRPCSuccessResponse)(request.id, {
|
|
@@ -2795,7 +2834,7 @@ async function handleFlow(request, config) {
|
|
|
2795
2834
|
return (0, import_json_rpc_26.createJSONRPCSuccessResponse)(request.id, {
|
|
2796
2835
|
runId,
|
|
2797
2836
|
runCompleted: true,
|
|
2798
|
-
error: e.message,
|
|
2837
|
+
error: e instanceof Error ? e.message : "unknown error",
|
|
2799
2838
|
config: flowConfig
|
|
2800
2839
|
});
|
|
2801
2840
|
}
|