@teamkeel/functions-runtime 0.423.2 → 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 +65 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -20
- package/dist/index.d.ts +77 -20
- package/dist/index.js +65 -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,
|
|
@@ -2864,6 +2867,28 @@ var dataGridInput = /* @__PURE__ */ __name((name, options) => {
|
|
|
2864
2867
|
};
|
|
2865
2868
|
}, "dataGridInput");
|
|
2866
2869
|
|
|
2870
|
+
// src/flows/ui/elements/input/datePicker.ts
|
|
2871
|
+
var datePickerInput = /* @__PURE__ */ __name((name, options) => {
|
|
2872
|
+
return {
|
|
2873
|
+
__type: "input",
|
|
2874
|
+
uiConfig: {
|
|
2875
|
+
__type: "ui.input.datePicker",
|
|
2876
|
+
name,
|
|
2877
|
+
label: options?.label || name,
|
|
2878
|
+
optional: options?.optional || false,
|
|
2879
|
+
disabled: options?.disabled || false,
|
|
2880
|
+
helpText: options?.helpText,
|
|
2881
|
+
defaultValue: options?.defaultValue,
|
|
2882
|
+
mode: options?.mode,
|
|
2883
|
+
min: options?.min,
|
|
2884
|
+
max: options?.max
|
|
2885
|
+
},
|
|
2886
|
+
validate: options?.validate,
|
|
2887
|
+
onLeave: options?.onLeave,
|
|
2888
|
+
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2889
|
+
};
|
|
2890
|
+
}, "datePickerInput");
|
|
2891
|
+
|
|
2867
2892
|
// src/flows/ui/elements/iterator.ts
|
|
2868
2893
|
var iterator = /* @__PURE__ */ __name((name, options) => {
|
|
2869
2894
|
return {
|
|
@@ -2884,17 +2909,22 @@ var iterator = /* @__PURE__ */ __name((name, options) => {
|
|
|
2884
2909
|
var print = /* @__PURE__ */ __name(async (options) => {
|
|
2885
2910
|
const dataConfig = Array.isArray(options.jobs) ? options.jobs : [options.jobs];
|
|
2886
2911
|
const dataPromises = dataConfig.map(async (d) => {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
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
|
+
};
|
|
2896
2924
|
});
|
|
2897
|
-
const data = (await Promise.all(dataPromises)).filter(
|
|
2925
|
+
const data = (await Promise.all(dataPromises)).filter(
|
|
2926
|
+
(x) => x !== null
|
|
2927
|
+
);
|
|
2898
2928
|
return {
|
|
2899
2929
|
uiConfig: {
|
|
2900
2930
|
__type: "ui.interactive.print",
|
|
@@ -2932,7 +2962,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
|
2932
2962
|
};
|
|
2933
2963
|
})
|
|
2934
2964
|
},
|
|
2935
|
-
validate: /* @__PURE__ */ __name(async (data) => {
|
|
2965
|
+
validate: /* @__PURE__ */ __name(async (data, action) => {
|
|
2936
2966
|
if (!("items" in data)) {
|
|
2937
2967
|
return "Missing items in response";
|
|
2938
2968
|
}
|
|
@@ -2944,7 +2974,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
|
2944
2974
|
)) {
|
|
2945
2975
|
return "Invalid data";
|
|
2946
2976
|
}
|
|
2947
|
-
return options?.validate?.(data) ?? true;
|
|
2977
|
+
return options?.validate?.(data, action) ?? true;
|
|
2948
2978
|
}, "validate"),
|
|
2949
2979
|
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2950
2980
|
};
|
|
@@ -2984,8 +3014,8 @@ var scan = /* @__PURE__ */ __name((name, options) => {
|
|
|
2984
3014
|
autoContinue: options.autoContinue
|
|
2985
3015
|
} : {}
|
|
2986
3016
|
},
|
|
2987
|
-
validate: /* @__PURE__ */ __name(async (data) => {
|
|
2988
|
-
return options?.validate?.(data) ?? true;
|
|
3017
|
+
validate: /* @__PURE__ */ __name(async (data, action) => {
|
|
3018
|
+
return options?.validate?.(data, action) ?? true;
|
|
2989
3019
|
}, "validate"),
|
|
2990
3020
|
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2991
3021
|
};
|
|
@@ -3156,7 +3186,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
3156
3186
|
});
|
|
3157
3187
|
}, "step"),
|
|
3158
3188
|
ui: {
|
|
3159
|
-
page: /* @__PURE__ */ __name(async (name, options) => {
|
|
3189
|
+
page: /* @__PURE__ */ __name((async (name, options) => {
|
|
3160
3190
|
return withSpan(`Page - ${name}`, async (span) => {
|
|
3161
3191
|
const db = useDatabase();
|
|
3162
3192
|
const isCallback = element && callback;
|
|
@@ -3252,12 +3282,13 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
3252
3282
|
}
|
|
3253
3283
|
return data;
|
|
3254
3284
|
});
|
|
3255
|
-
}, "page"),
|
|
3285
|
+
}), "page"),
|
|
3256
3286
|
inputs: {
|
|
3257
3287
|
text: textInput,
|
|
3258
3288
|
number: numberInput,
|
|
3259
3289
|
boolean: booleanInput,
|
|
3260
3290
|
dataGrid: dataGridInput,
|
|
3291
|
+
datePicker: datePickerInput,
|
|
3261
3292
|
scan
|
|
3262
3293
|
},
|
|
3263
3294
|
display: {
|