@teamkeel/functions-runtime 0.414.7 → 0.415.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.
- package/dist/index.cjs +70 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -4
- package/dist/index.d.ts +71 -4
- package/dist/index.js +70 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2482,10 +2482,11 @@ async function page(options, data, action) {
|
|
|
2482
2482
|
}
|
|
2483
2483
|
}
|
|
2484
2484
|
const contentUiConfig = await Promise.all(
|
|
2485
|
-
content.map(async (
|
|
2485
|
+
content.map(async (content2) => {
|
|
2486
|
+
let c = await content2;
|
|
2486
2487
|
const isInput = "__type" in c && c.__type == "input";
|
|
2487
2488
|
const hasData = data && c.uiConfig.name in data;
|
|
2488
|
-
if (isInput && hasData && c.validate) {
|
|
2489
|
+
if (isInput && hasData && "validate" in c && c.validate) {
|
|
2489
2490
|
const validationError2 = await c.validate(data[c.uiConfig.name]);
|
|
2490
2491
|
if (typeof validationError2 === "string") {
|
|
2491
2492
|
hasValidationErrors = true;
|
|
@@ -2729,6 +2730,68 @@ var dataGridInput = /* @__PURE__ */ __name((name, options) => {
|
|
|
2729
2730
|
};
|
|
2730
2731
|
}, "dataGridInput");
|
|
2731
2732
|
|
|
2733
|
+
// src/flows/ui/elements/interactive/print.ts
|
|
2734
|
+
var print = /* @__PURE__ */ __name(async (options) => {
|
|
2735
|
+
const dataConfig = Array.isArray(options.jobs) ? options.jobs : [options.jobs];
|
|
2736
|
+
const dataPromises = dataConfig.map(async (d) => {
|
|
2737
|
+
if ("type" in d && d.type) {
|
|
2738
|
+
return {
|
|
2739
|
+
type: d.type,
|
|
2740
|
+
name: d.name,
|
|
2741
|
+
data: Array.isArray(d.data) ? d.data : [d.data]
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
return null;
|
|
2745
|
+
});
|
|
2746
|
+
const data = (await Promise.all(dataPromises)).filter((x) => x !== null);
|
|
2747
|
+
return {
|
|
2748
|
+
uiConfig: {
|
|
2749
|
+
__type: "ui.interactive.print",
|
|
2750
|
+
title: options.title,
|
|
2751
|
+
description: options.description,
|
|
2752
|
+
data,
|
|
2753
|
+
autoPrint: options.autoPrint ?? false
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2756
|
+
}, "print");
|
|
2757
|
+
|
|
2758
|
+
// src/flows/ui/elements/interactive/pickList.ts
|
|
2759
|
+
var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
2760
|
+
return {
|
|
2761
|
+
__type: "input",
|
|
2762
|
+
uiConfig: {
|
|
2763
|
+
__type: "ui.interactive.pickList",
|
|
2764
|
+
name,
|
|
2765
|
+
data: options.data.map((item) => {
|
|
2766
|
+
const rendered = options.render(item);
|
|
2767
|
+
return {
|
|
2768
|
+
id: rendered.id,
|
|
2769
|
+
targetQuantity: rendered.targetQuantity,
|
|
2770
|
+
title: rendered.title,
|
|
2771
|
+
description: rendered.description,
|
|
2772
|
+
image: rendered.image ?? void 0,
|
|
2773
|
+
barcodes: rendered.barcodes ?? void 0
|
|
2774
|
+
};
|
|
2775
|
+
})
|
|
2776
|
+
},
|
|
2777
|
+
validate: /* @__PURE__ */ __name(async (data) => {
|
|
2778
|
+
if (!("items" in data)) {
|
|
2779
|
+
return "Missing items in response";
|
|
2780
|
+
}
|
|
2781
|
+
if (!Array.isArray(data.items)) {
|
|
2782
|
+
return "Items must be an array";
|
|
2783
|
+
}
|
|
2784
|
+
if (data.items.some(
|
|
2785
|
+
(item) => typeof item !== "object" || typeof item.id !== "string" || typeof item.qty !== "number"
|
|
2786
|
+
)) {
|
|
2787
|
+
return "Invalid data";
|
|
2788
|
+
}
|
|
2789
|
+
return options?.validate?.(data) ?? true;
|
|
2790
|
+
}, "validate"),
|
|
2791
|
+
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2792
|
+
};
|
|
2793
|
+
}, "pickList");
|
|
2794
|
+
|
|
2732
2795
|
// src/flows/errors.ts
|
|
2733
2796
|
var NonRetriableError = class extends Error {
|
|
2734
2797
|
static {
|
|
@@ -2955,6 +3018,10 @@ function createFlowContext(runId, data, action, spanId, ctx) {
|
|
|
2955
3018
|
select: {
|
|
2956
3019
|
one: selectOne,
|
|
2957
3020
|
table: selectTable
|
|
3021
|
+
},
|
|
3022
|
+
interactive: {
|
|
3023
|
+
print,
|
|
3024
|
+
pickList
|
|
2958
3025
|
}
|
|
2959
3026
|
}
|
|
2960
3027
|
};
|
|
@@ -2979,7 +3046,7 @@ async function complete(options) {
|
|
|
2979
3046
|
const content = options.content || [];
|
|
2980
3047
|
const contentUiConfig = await Promise.all(
|
|
2981
3048
|
content.map(async (c) => {
|
|
2982
|
-
return c.uiConfig;
|
|
3049
|
+
return (await c).uiConfig;
|
|
2983
3050
|
})
|
|
2984
3051
|
);
|
|
2985
3052
|
return {
|