@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.d.cts
CHANGED
|
@@ -630,19 +630,51 @@ type UiElementPrint<H extends NullableHardware> = DisplayElementWithRequiredConf
|
|
|
630
630
|
autoContinue?: boolean;
|
|
631
631
|
}>;
|
|
632
632
|
type PrintData<H extends NullableHardware> = {
|
|
633
|
-
|
|
634
|
-
printer?: H extends Hardware ? H["printers"][number]["name"] : never;
|
|
633
|
+
/** The name of the print job. */
|
|
635
634
|
name?: string;
|
|
635
|
+
/** The printer to use for the print job. Printers are defined in keelconfig.yaml. */
|
|
636
|
+
printer?: H extends Hardware ? H["printers"][number]["name"] : never;
|
|
637
|
+
} & (PrintDataZpl | PrintDataRawPdf);
|
|
638
|
+
type PrintDataZpl = {
|
|
639
|
+
type: "zpl";
|
|
640
|
+
} & ({
|
|
636
641
|
data: string | string[];
|
|
642
|
+
url?: never;
|
|
643
|
+
} | {
|
|
644
|
+
data?: never;
|
|
645
|
+
url: string;
|
|
646
|
+
});
|
|
647
|
+
type PrintDataRawPdf = {
|
|
648
|
+
type: "rawPdf";
|
|
649
|
+
url: string;
|
|
650
|
+
data?: never;
|
|
651
|
+
/** The DPI of the PDF
|
|
652
|
+
* @default 300
|
|
653
|
+
*/
|
|
654
|
+
dpi?: number;
|
|
655
|
+
/** The width of the page in dots.
|
|
656
|
+
* e.g. 4" at 300 dpi is 1200 dots.
|
|
657
|
+
* @default 1200
|
|
658
|
+
*/
|
|
659
|
+
pageWidth?: number;
|
|
660
|
+
/** The height of the page in dots.
|
|
661
|
+
* e.g. 6" at 300 dpi is 1800 dots.
|
|
662
|
+
* @default 1800
|
|
663
|
+
*/
|
|
664
|
+
pageHeight?: number;
|
|
637
665
|
};
|
|
638
666
|
interface UiElementPrintApiResponse extends BaseUiDisplayResponse<"ui.interactive.print"> {
|
|
639
667
|
title?: string;
|
|
640
668
|
description?: string;
|
|
641
669
|
data: {
|
|
642
|
-
type: "
|
|
670
|
+
type: "zpl" | "rawPdf";
|
|
671
|
+
name?: string;
|
|
643
672
|
data?: string[];
|
|
644
673
|
url?: string;
|
|
645
674
|
printer?: string;
|
|
675
|
+
dpi?: number;
|
|
676
|
+
pageWidth?: number;
|
|
677
|
+
pageHeight?: number;
|
|
646
678
|
}[];
|
|
647
679
|
autoPrint: boolean;
|
|
648
680
|
autoContinue: boolean;
|
|
@@ -835,7 +867,7 @@ interface BaseInputConfig<T, O extends boolean = boolean> {
|
|
|
835
867
|
validate?: ValidateFn<T>;
|
|
836
868
|
onLeave?: CallbackFn<T, T>;
|
|
837
869
|
}
|
|
838
|
-
type ValidateFn<T> = (data: T) => Promise<boolean | string> | boolean | string;
|
|
870
|
+
type ValidateFn<T> = (data: T, action?: string) => Promise<boolean | string> | boolean | string;
|
|
839
871
|
type CallbackFn<InputT, OutputT> = (data: InputT) => Promise<OutputT> | OutputT;
|
|
840
872
|
interface BaseUiInputResponse<K, TData> {
|
|
841
873
|
__type: K;
|
package/dist/index.d.ts
CHANGED
|
@@ -630,19 +630,51 @@ type UiElementPrint<H extends NullableHardware> = DisplayElementWithRequiredConf
|
|
|
630
630
|
autoContinue?: boolean;
|
|
631
631
|
}>;
|
|
632
632
|
type PrintData<H extends NullableHardware> = {
|
|
633
|
-
|
|
634
|
-
printer?: H extends Hardware ? H["printers"][number]["name"] : never;
|
|
633
|
+
/** The name of the print job. */
|
|
635
634
|
name?: string;
|
|
635
|
+
/** The printer to use for the print job. Printers are defined in keelconfig.yaml. */
|
|
636
|
+
printer?: H extends Hardware ? H["printers"][number]["name"] : never;
|
|
637
|
+
} & (PrintDataZpl | PrintDataRawPdf);
|
|
638
|
+
type PrintDataZpl = {
|
|
639
|
+
type: "zpl";
|
|
640
|
+
} & ({
|
|
636
641
|
data: string | string[];
|
|
642
|
+
url?: never;
|
|
643
|
+
} | {
|
|
644
|
+
data?: never;
|
|
645
|
+
url: string;
|
|
646
|
+
});
|
|
647
|
+
type PrintDataRawPdf = {
|
|
648
|
+
type: "rawPdf";
|
|
649
|
+
url: string;
|
|
650
|
+
data?: never;
|
|
651
|
+
/** The DPI of the PDF
|
|
652
|
+
* @default 300
|
|
653
|
+
*/
|
|
654
|
+
dpi?: number;
|
|
655
|
+
/** The width of the page in dots.
|
|
656
|
+
* e.g. 4" at 300 dpi is 1200 dots.
|
|
657
|
+
* @default 1200
|
|
658
|
+
*/
|
|
659
|
+
pageWidth?: number;
|
|
660
|
+
/** The height of the page in dots.
|
|
661
|
+
* e.g. 6" at 300 dpi is 1800 dots.
|
|
662
|
+
* @default 1800
|
|
663
|
+
*/
|
|
664
|
+
pageHeight?: number;
|
|
637
665
|
};
|
|
638
666
|
interface UiElementPrintApiResponse extends BaseUiDisplayResponse<"ui.interactive.print"> {
|
|
639
667
|
title?: string;
|
|
640
668
|
description?: string;
|
|
641
669
|
data: {
|
|
642
|
-
type: "
|
|
670
|
+
type: "zpl" | "rawPdf";
|
|
671
|
+
name?: string;
|
|
643
672
|
data?: string[];
|
|
644
673
|
url?: string;
|
|
645
674
|
printer?: string;
|
|
675
|
+
dpi?: number;
|
|
676
|
+
pageWidth?: number;
|
|
677
|
+
pageHeight?: number;
|
|
646
678
|
}[];
|
|
647
679
|
autoPrint: boolean;
|
|
648
680
|
autoContinue: boolean;
|
|
@@ -835,7 +867,7 @@ interface BaseInputConfig<T, O extends boolean = boolean> {
|
|
|
835
867
|
validate?: ValidateFn<T>;
|
|
836
868
|
onLeave?: CallbackFn<T, T>;
|
|
837
869
|
}
|
|
838
|
-
type ValidateFn<T> = (data: T) => Promise<boolean | string> | boolean | string;
|
|
870
|
+
type ValidateFn<T> = (data: T, action?: string) => Promise<boolean | string> | boolean | string;
|
|
839
871
|
type CallbackFn<InputT, OutputT> = (data: InputT) => Promise<OutputT> | OutputT;
|
|
840
872
|
interface BaseUiInputResponse<K, TData> {
|
|
841
873
|
__type: K;
|
package/dist/index.js
CHANGED
|
@@ -875,9 +875,7 @@ var File = class _File extends InlineFile {
|
|
|
875
875
|
const url = await getSignedUrl(s3Client, command, { expiresIn: 60 * 60 });
|
|
876
876
|
return new URL(url);
|
|
877
877
|
} else {
|
|
878
|
-
|
|
879
|
-
const dataurl = `data:${this.contentType};name=${this.filename};base64,${contents.toString("base64")}`;
|
|
880
|
-
return new URL(dataurl);
|
|
878
|
+
return new URL(`${process.env.KEEL_API_URL}/files/${this.key}`);
|
|
881
879
|
}
|
|
882
880
|
}
|
|
883
881
|
// Persists the file
|
|
@@ -2489,14 +2487,15 @@ async function page(options, data, action) {
|
|
|
2489
2487
|
const elementData = data && typeof data === "object" && resolvedC.uiConfig.name in data ? data[resolvedC.uiConfig.name] : void 0;
|
|
2490
2488
|
const { uiConfig, validationErrors } = await recursivelyProcessElement(
|
|
2491
2489
|
c,
|
|
2492
|
-
elementData
|
|
2490
|
+
elementData,
|
|
2491
|
+
options.actions && options.actions.length > 0 ? action : null
|
|
2493
2492
|
);
|
|
2494
2493
|
if (validationErrors) hasValidationErrors = true;
|
|
2495
2494
|
return uiConfig;
|
|
2496
2495
|
})
|
|
2497
2496
|
);
|
|
2498
2497
|
if (data && options.validate) {
|
|
2499
|
-
const validationResult = await options.validate(data);
|
|
2498
|
+
const validationResult = options.actions && action !== null ? await options.validate(data, action) : await options.validate(data);
|
|
2500
2499
|
if (typeof validationResult === "string") {
|
|
2501
2500
|
hasValidationErrors = true;
|
|
2502
2501
|
validationError = validationResult;
|
|
@@ -2526,19 +2525,21 @@ async function page(options, data, action) {
|
|
|
2526
2525
|
};
|
|
2527
2526
|
}
|
|
2528
2527
|
__name(page, "page");
|
|
2529
|
-
var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data) => {
|
|
2528
|
+
var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data, action) => {
|
|
2530
2529
|
const resolvedC = await c;
|
|
2531
2530
|
const elementType = "__type" in resolvedC ? resolvedC.__type : null;
|
|
2532
2531
|
switch (elementType) {
|
|
2533
2532
|
case "input":
|
|
2534
2533
|
return processInputElement(
|
|
2535
2534
|
resolvedC,
|
|
2536
|
-
data
|
|
2535
|
+
data,
|
|
2536
|
+
action
|
|
2537
2537
|
);
|
|
2538
2538
|
case "iterator":
|
|
2539
2539
|
return processIteratorElement(
|
|
2540
2540
|
resolvedC,
|
|
2541
|
-
data
|
|
2541
|
+
data,
|
|
2542
|
+
action
|
|
2542
2543
|
);
|
|
2543
2544
|
default:
|
|
2544
2545
|
return {
|
|
@@ -2547,7 +2548,7 @@ var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data) => {
|
|
|
2547
2548
|
};
|
|
2548
2549
|
}
|
|
2549
2550
|
}, "recursivelyProcessElement");
|
|
2550
|
-
var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
2551
|
+
var processInputElement = /* @__PURE__ */ __name(async (element, data, action) => {
|
|
2551
2552
|
const hasData = data !== void 0 && data !== null;
|
|
2552
2553
|
if (!hasData || !element.validate) {
|
|
2553
2554
|
return {
|
|
@@ -2555,7 +2556,7 @@ var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
|
2555
2556
|
validationErrors: false
|
|
2556
2557
|
};
|
|
2557
2558
|
}
|
|
2558
|
-
const validationError = await element.validate(data);
|
|
2559
|
+
const validationError = action !== null ? await element.validate(data, action) : await element.validate(data);
|
|
2559
2560
|
const hasValidationErrors = typeof validationError === "string";
|
|
2560
2561
|
return {
|
|
2561
2562
|
uiConfig: {
|
|
@@ -2565,19 +2566,23 @@ var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
|
2565
2566
|
validationErrors: hasValidationErrors
|
|
2566
2567
|
};
|
|
2567
2568
|
}, "processInputElement");
|
|
2568
|
-
var processIteratorElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
2569
|
+
var processIteratorElement = /* @__PURE__ */ __name(async (element, data, action) => {
|
|
2569
2570
|
const elements = element.uiConfig.content;
|
|
2570
2571
|
const dataArr = data;
|
|
2571
2572
|
const ui = [];
|
|
2572
2573
|
for (const el of elements) {
|
|
2573
|
-
const result = await recursivelyProcessElement(el, void 0);
|
|
2574
|
+
const result = await recursivelyProcessElement(el, void 0, action);
|
|
2574
2575
|
ui.push(result.uiConfig);
|
|
2575
2576
|
}
|
|
2576
|
-
const validationErrors = await validateIteratorData(
|
|
2577
|
+
const validationErrors = await validateIteratorData(
|
|
2578
|
+
elements,
|
|
2579
|
+
dataArr,
|
|
2580
|
+
action
|
|
2581
|
+
);
|
|
2577
2582
|
let hasValidationErrors = validationErrors.length > 0;
|
|
2578
2583
|
let validationError = void 0;
|
|
2579
2584
|
if (dataArr && element.validate) {
|
|
2580
|
-
const v = await element.validate(dataArr);
|
|
2585
|
+
const v = action !== null ? await element.validate(dataArr, action) : await element.validate(dataArr);
|
|
2581
2586
|
if (typeof v === "string") {
|
|
2582
2587
|
hasValidationErrors = true;
|
|
2583
2588
|
validationError = v;
|
|
@@ -2593,7 +2598,7 @@ var processIteratorElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
|
2593
2598
|
validationErrors: hasValidationErrors
|
|
2594
2599
|
};
|
|
2595
2600
|
}, "processIteratorElement");
|
|
2596
|
-
var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr) => {
|
|
2601
|
+
var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr, action) => {
|
|
2597
2602
|
const validationErrors = [];
|
|
2598
2603
|
if (!dataArr || dataArr.length === 0) {
|
|
2599
2604
|
return validationErrors;
|
|
@@ -2605,9 +2610,7 @@ var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr) => {
|
|
|
2605
2610
|
if ("__type" in resolvedEl && resolvedEl.__type === "input" && "validate" in resolvedEl && resolvedEl.validate && typeof resolvedEl.validate === "function") {
|
|
2606
2611
|
const fieldName = resolvedEl.uiConfig.name;
|
|
2607
2612
|
if (rowData && typeof rowData === "object" && fieldName in rowData) {
|
|
2608
|
-
const validationError = await resolvedEl.validate(
|
|
2609
|
-
rowData[fieldName]
|
|
2610
|
-
);
|
|
2613
|
+
const validationError = action !== null ? await resolvedEl.validate(rowData[fieldName], action) : await resolvedEl.validate(rowData[fieldName]);
|
|
2611
2614
|
if (typeof validationError === "string") {
|
|
2612
2615
|
validationErrors.push({
|
|
2613
2616
|
index: i,
|
|
@@ -2876,17 +2879,22 @@ var iterator = /* @__PURE__ */ __name((name, options) => {
|
|
|
2876
2879
|
var print = /* @__PURE__ */ __name(async (options) => {
|
|
2877
2880
|
const dataConfig = Array.isArray(options.jobs) ? options.jobs : [options.jobs];
|
|
2878
2881
|
const dataPromises = dataConfig.map(async (d) => {
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2882
|
+
return {
|
|
2883
|
+
type: d.type,
|
|
2884
|
+
name: d.name,
|
|
2885
|
+
data: "data" in d && d.data ? Array.isArray(d.data) ? d.data : [d.data] : void 0,
|
|
2886
|
+
printer: d.printer,
|
|
2887
|
+
url: "url" in d && d.url ? d.url : void 0,
|
|
2888
|
+
...d.type === "rawPdf" ? {
|
|
2889
|
+
dpi: d.dpi,
|
|
2890
|
+
pageWidth: d.pageWidth,
|
|
2891
|
+
pageHeight: d.pageHeight
|
|
2892
|
+
} : {}
|
|
2893
|
+
};
|
|
2888
2894
|
});
|
|
2889
|
-
const data = (await Promise.all(dataPromises)).filter(
|
|
2895
|
+
const data = (await Promise.all(dataPromises)).filter(
|
|
2896
|
+
(x) => x !== null
|
|
2897
|
+
);
|
|
2890
2898
|
return {
|
|
2891
2899
|
uiConfig: {
|
|
2892
2900
|
__type: "ui.interactive.print",
|
|
@@ -2924,7 +2932,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
|
2924
2932
|
};
|
|
2925
2933
|
})
|
|
2926
2934
|
},
|
|
2927
|
-
validate: /* @__PURE__ */ __name(async (data) => {
|
|
2935
|
+
validate: /* @__PURE__ */ __name(async (data, action) => {
|
|
2928
2936
|
if (!("items" in data)) {
|
|
2929
2937
|
return "Missing items in response";
|
|
2930
2938
|
}
|
|
@@ -2936,7 +2944,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
|
|
|
2936
2944
|
)) {
|
|
2937
2945
|
return "Invalid data";
|
|
2938
2946
|
}
|
|
2939
|
-
return options?.validate?.(data) ?? true;
|
|
2947
|
+
return options?.validate?.(data, action) ?? true;
|
|
2940
2948
|
}, "validate"),
|
|
2941
2949
|
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2942
2950
|
};
|
|
@@ -2976,8 +2984,8 @@ var scan = /* @__PURE__ */ __name((name, options) => {
|
|
|
2976
2984
|
autoContinue: options.autoContinue
|
|
2977
2985
|
} : {}
|
|
2978
2986
|
},
|
|
2979
|
-
validate: /* @__PURE__ */ __name(async (data) => {
|
|
2980
|
-
return options?.validate?.(data) ?? true;
|
|
2987
|
+
validate: /* @__PURE__ */ __name(async (data, action) => {
|
|
2988
|
+
return options?.validate?.(data, action) ?? true;
|
|
2981
2989
|
}, "validate"),
|
|
2982
2990
|
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2983
2991
|
};
|
|
@@ -3148,7 +3156,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
3148
3156
|
});
|
|
3149
3157
|
}, "step"),
|
|
3150
3158
|
ui: {
|
|
3151
|
-
page: /* @__PURE__ */ __name(async (name, options) => {
|
|
3159
|
+
page: /* @__PURE__ */ __name((async (name, options) => {
|
|
3152
3160
|
return withSpan(`Page - ${name}`, async (span) => {
|
|
3153
3161
|
const db = useDatabase();
|
|
3154
3162
|
const isCallback = element && callback;
|
|
@@ -3244,7 +3252,7 @@ function createFlowContext(runId, data, action, callback, element, spanId, ctx)
|
|
|
3244
3252
|
}
|
|
3245
3253
|
return data;
|
|
3246
3254
|
});
|
|
3247
|
-
}, "page"),
|
|
3255
|
+
}), "page"),
|
|
3248
3256
|
inputs: {
|
|
3249
3257
|
text: textInput,
|
|
3250
3258
|
number: numberInput,
|