@teamkeel/functions-runtime 0.423.3 → 0.424.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 +42 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.js +42 -34
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -925,9 +925,7 @@ var File = class _File extends InlineFile {
|
|
|
925
925
|
const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
|
|
926
926
|
return new URL(url);
|
|
927
927
|
} else {
|
|
928
|
-
|
|
929
|
-
const dataurl = `data:${this.contentType};name=${this.filename};base64,${contents.toString("base64")}`;
|
|
930
|
-
return new URL(dataurl);
|
|
928
|
+
return new URL(`${process.env.KEEL_API_URL}/files/${this.key}`);
|
|
931
929
|
}
|
|
932
930
|
}
|
|
933
931
|
// Persists the file
|
|
@@ -2519,14 +2517,15 @@ async function page(options, data, action) {
|
|
|
2519
2517
|
const elementData = data && typeof data === "object" && resolvedC.uiConfig.name in data ? data[resolvedC.uiConfig.name] : void 0;
|
|
2520
2518
|
const { uiConfig, validationErrors } = await recursivelyProcessElement(
|
|
2521
2519
|
c,
|
|
2522
|
-
elementData
|
|
2520
|
+
elementData,
|
|
2521
|
+
options.actions && options.actions.length > 0 ? action : null
|
|
2523
2522
|
);
|
|
2524
2523
|
if (validationErrors) hasValidationErrors = true;
|
|
2525
2524
|
return uiConfig;
|
|
2526
2525
|
})
|
|
2527
2526
|
);
|
|
2528
2527
|
if (data && options.validate) {
|
|
2529
|
-
const validationResult = await options.validate(data);
|
|
2528
|
+
const validationResult = options.actions && action !== null ? await options.validate(data, action) : await options.validate(data);
|
|
2530
2529
|
if (typeof validationResult === "string") {
|
|
2531
2530
|
hasValidationErrors = true;
|
|
2532
2531
|
validationError = validationResult;
|
|
@@ -2556,19 +2555,21 @@ async function page(options, data, action) {
|
|
|
2556
2555
|
};
|
|
2557
2556
|
}
|
|
2558
2557
|
__name(page, "page");
|
|
2559
|
-
var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data) => {
|
|
2558
|
+
var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data, action) => {
|
|
2560
2559
|
const resolvedC = await c;
|
|
2561
2560
|
const elementType = "__type" in resolvedC ? resolvedC.__type : null;
|
|
2562
2561
|
switch (elementType) {
|
|
2563
2562
|
case "input":
|
|
2564
2563
|
return processInputElement(
|
|
2565
2564
|
resolvedC,
|
|
2566
|
-
data
|
|
2565
|
+
data,
|
|
2566
|
+
action
|
|
2567
2567
|
);
|
|
2568
2568
|
case "iterator":
|
|
2569
2569
|
return processIteratorElement(
|
|
2570
2570
|
resolvedC,
|
|
2571
|
-
data
|
|
2571
|
+
data,
|
|
2572
|
+
action
|
|
2572
2573
|
);
|
|
2573
2574
|
default:
|
|
2574
2575
|
return {
|
|
@@ -2577,7 +2578,7 @@ var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data) => {
|
|
|
2577
2578
|
};
|
|
2578
2579
|
}
|
|
2579
2580
|
}, "recursivelyProcessElement");
|
|
2580
|
-
var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
2581
|
+
var processInputElement = /* @__PURE__ */ __name(async (element, data, action) => {
|
|
2581
2582
|
const hasData = data !== void 0 && data !== null;
|
|
2582
2583
|
if (!hasData || !element.validate) {
|
|
2583
2584
|
return {
|
|
@@ -2585,7 +2586,7 @@ var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
|
2585
2586
|
validationErrors: false
|
|
2586
2587
|
};
|
|
2587
2588
|
}
|
|
2588
|
-
const validationError = await element.validate(data);
|
|
2589
|
+
const validationError = action !== null ? await element.validate(data, action) : await element.validate(data);
|
|
2589
2590
|
const hasValidationErrors = typeof validationError === "string";
|
|
2590
2591
|
return {
|
|
2591
2592
|
uiConfig: {
|
|
@@ -2595,19 +2596,23 @@ var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
|
2595
2596
|
validationErrors: hasValidationErrors
|
|
2596
2597
|
};
|
|
2597
2598
|
}, "processInputElement");
|
|
2598
|
-
var processIteratorElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
2599
|
+
var processIteratorElement = /* @__PURE__ */ __name(async (element, data, action) => {
|
|
2599
2600
|
const elements = element.uiConfig.content;
|
|
2600
2601
|
const dataArr = data;
|
|
2601
2602
|
const ui = [];
|
|
2602
2603
|
for (const el of elements) {
|
|
2603
|
-
const result = await recursivelyProcessElement(el, void 0);
|
|
2604
|
+
const result = await recursivelyProcessElement(el, void 0, action);
|
|
2604
2605
|
ui.push(result.uiConfig);
|
|
2605
2606
|
}
|
|
2606
|
-
const validationErrors = await validateIteratorData(
|
|
2607
|
+
const validationErrors = await validateIteratorData(
|
|
2608
|
+
elements,
|
|
2609
|
+
dataArr,
|
|
2610
|
+
action
|
|
2611
|
+
);
|
|
2607
2612
|
let hasValidationErrors = validationErrors.length > 0;
|
|
2608
2613
|
let validationError = void 0;
|
|
2609
2614
|
if (dataArr && element.validate) {
|
|
2610
|
-
const v = await element.validate(dataArr);
|
|
2615
|
+
const v = action !== null ? await element.validate(dataArr, action) : await element.validate(dataArr);
|
|
2611
2616
|
if (typeof v === "string") {
|
|
2612
2617
|
hasValidationErrors = true;
|
|
2613
2618
|
validationError = v;
|
|
@@ -2623,7 +2628,7 @@ var processIteratorElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
|
2623
2628
|
validationErrors: hasValidationErrors
|
|
2624
2629
|
};
|
|
2625
2630
|
}, "processIteratorElement");
|
|
2626
|
-
var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr) => {
|
|
2631
|
+
var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr, action) => {
|
|
2627
2632
|
const validationErrors = [];
|
|
2628
2633
|
if (!dataArr || dataArr.length === 0) {
|
|
2629
2634
|
return validationErrors;
|
|
@@ -2635,9 +2640,7 @@ var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr) => {
|
|
|
2635
2640
|
if ("__type" in resolvedEl && resolvedEl.__type === "input" && "validate" in resolvedEl && resolvedEl.validate && typeof resolvedEl.validate === "function") {
|
|
2636
2641
|
const fieldName = resolvedEl.uiConfig.name;
|
|
2637
2642
|
if (rowData && typeof rowData === "object" && fieldName in rowData) {
|
|
2638
|
-
const validationError = await resolvedEl.validate(
|
|
2639
|
-
rowData[fieldName]
|
|
2640
|
-
);
|
|
2643
|
+
const validationError = action !== null ? await resolvedEl.validate(rowData[fieldName], action) : await resolvedEl.validate(rowData[fieldName]);
|
|
2641
2644
|
if (typeof validationError === "string") {
|
|
2642
2645
|
validationErrors.push({
|
|
2643
2646
|
index: i,
|
|
@@ -2906,17 +2909,22 @@ var iterator = /* @__PURE__ */ __name((name, options) => {
|
|
|
2906
2909
|
var print = /* @__PURE__ */ __name(async (options) => {
|
|
2907
2910
|
const dataConfig = Array.isArray(options.jobs) ? options.jobs : [options.jobs];
|
|
2908
2911
|
const dataPromises = dataConfig.map(async (d) => {
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2912
|
+
return {
|
|
2913
|
+
type: d.type,
|
|
2914
|
+
name: d.name,
|
|
2915
|
+
data: "data" in d && d.data ? Array.isArray(d.data) ? d.data : [d.data] : void 0,
|
|
2916
|
+
printer: d.printer,
|
|
2917
|
+
url: "url" in d && d.url ? d.url : void 0,
|
|
2918
|
+
...d.type === "rawPdf" ? {
|
|
2919
|
+
dpi: d.dpi,
|
|
2920
|
+
pageWidth: d.pageWidth,
|
|
2921
|
+
pageHeight: d.pageHeight
|
|
2922
|
+
} : {}
|
|
2923
|
+
};
|
|
2918
2924
|
});
|
|
2919
|
-
const data = (await Promise.all(dataPromises)).filter(
|
|
2925
|
+
const data = (await Promise.all(dataPromises)).filter(
|
|
2926
|
+
(x) => x !== null
|
|
2927
|
+
);
|
|
2920
2928
|
return {
|
|
2921
2929
|
uiConfig: {
|
|
2922
2930
|
__type: "ui.interactive.print",
|
|
@@ -2954,7 +2962,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
|
2954
2962
|
};
|
|
2955
2963
|
})
|
|
2956
2964
|
},
|
|
2957
|
-
validate: /* @__PURE__ */ __name(async (data) => {
|
|
2965
|
+
validate: /* @__PURE__ */ __name(async (data, action) => {
|
|
2958
2966
|
if (!("items" in data)) {
|
|
2959
2967
|
return "Missing items in response";
|
|
2960
2968
|
}
|
|
@@ -2966,7 +2974,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
|
2966
2974
|
)) {
|
|
2967
2975
|
return "Invalid data";
|
|
2968
2976
|
}
|
|
2969
|
-
return options?.validate?.(data) ?? true;
|
|
2977
|
+
return options?.validate?.(data, action) ?? true;
|
|
2970
2978
|
}, "validate"),
|
|
2971
2979
|
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2972
2980
|
};
|
|
@@ -3006,8 +3014,8 @@ var scan = /* @__PURE__ */ __name((name, options) => {
|
|
|
3006
3014
|
autoContinue: options.autoContinue
|
|
3007
3015
|
} : {}
|
|
3008
3016
|
},
|
|
3009
|
-
validate: /* @__PURE__ */ __name(async (data) => {
|
|
3010
|
-
return options?.validate?.(data) ?? true;
|
|
3017
|
+
validate: /* @__PURE__ */ __name(async (data, action) => {
|
|
3018
|
+
return options?.validate?.(data, action) ?? true;
|
|
3011
3019
|
}, "validate"),
|
|
3012
3020
|
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
3013
3021
|
};
|
|
@@ -3178,7 +3186,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
3178
3186
|
});
|
|
3179
3187
|
}, "step"),
|
|
3180
3188
|
ui: {
|
|
3181
|
-
page: /* @__PURE__ */ __name(async (name, options) => {
|
|
3189
|
+
page: /* @__PURE__ */ __name((async (name, options) => {
|
|
3182
3190
|
return withSpan(`Page - ${name}`, async (span) => {
|
|
3183
3191
|
const db = useDatabase();
|
|
3184
3192
|
const isCallback = element && callback;
|
|
@@ -3274,7 +3282,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
3274
3282
|
}
|
|
3275
3283
|
return data;
|
|
3276
3284
|
});
|
|
3277
|
-
}, "page"),
|
|
3285
|
+
}), "page"),
|
|
3278
3286
|
inputs: {
|
|
3279
3287
|
text: textInput,
|
|
3280
3288
|
number: numberInput,
|