@teamkeel/functions-runtime 0.415.0 → 0.415.2
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 +122 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +122 -16
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -545,6 +545,25 @@ type DataGridColumn = {
|
|
|
545
545
|
editable: boolean;
|
|
546
546
|
};
|
|
547
547
|
|
|
548
|
+
type UiElementIterator = <N extends string, T extends UIElements>(name: N, options: {
|
|
549
|
+
content: T;
|
|
550
|
+
validate?: ValidateFn<ExtractFormData<T>[]>;
|
|
551
|
+
max?: number;
|
|
552
|
+
min?: number;
|
|
553
|
+
}) => IteratorElementResponse<N, T>;
|
|
554
|
+
interface UiElementIteratorApiResponse extends BaseUiDisplayResponse<"ui.iterator"> {
|
|
555
|
+
name: string;
|
|
556
|
+
content: UiElementApiResponses;
|
|
557
|
+
max?: number;
|
|
558
|
+
min?: number;
|
|
559
|
+
validationError?: string;
|
|
560
|
+
contentValidationErrors?: Array<{
|
|
561
|
+
index: number;
|
|
562
|
+
name: string;
|
|
563
|
+
validationError: string;
|
|
564
|
+
}>;
|
|
565
|
+
}
|
|
566
|
+
|
|
548
567
|
type UiElementPrint = DisplayElementWithRequiredConfig<{
|
|
549
568
|
jobs: PrintData[] | PrintData;
|
|
550
569
|
title?: string;
|
|
@@ -600,6 +619,7 @@ interface UI<C extends FlowConfig> {
|
|
|
600
619
|
display: UiDisplayElements;
|
|
601
620
|
inputs: UiInputsElements;
|
|
602
621
|
select: UiSelectElements;
|
|
622
|
+
iterator: UiElementIterator;
|
|
603
623
|
interactive: UiInteractiveElements;
|
|
604
624
|
}
|
|
605
625
|
type UiInputsElements = {
|
|
@@ -631,7 +651,8 @@ type UiInteractiveElements = {
|
|
|
631
651
|
type InputElement<TValueType, TConfig extends any = never> = <N extends string>(name: N, options?: BaseInputConfig<TValueType> & TConfig) => InputElementResponse<N, TValueType>;
|
|
632
652
|
type DisplayElement<TConfig extends any = never> = (options?: TConfig) => DisplayElementResponse;
|
|
633
653
|
type DisplayElementWithRequiredConfig<TConfig extends any = never> = (options: TConfig) => DisplayElementResponse;
|
|
634
|
-
type
|
|
654
|
+
type UIElement = InputElementResponse<string, any> | DisplayElementResponse | IteratorElementResponse<string, any>;
|
|
655
|
+
type UIElements = UIElement[];
|
|
635
656
|
interface UIElementBase {
|
|
636
657
|
_type: string;
|
|
637
658
|
}
|
|
@@ -643,6 +664,11 @@ interface InputElementResponse<N extends string, V> extends UIElementBase {
|
|
|
643
664
|
interface DisplayElementResponse extends UIElementBase {
|
|
644
665
|
_type: "display";
|
|
645
666
|
}
|
|
667
|
+
interface IteratorElementResponse<N extends string, E extends UIElements> extends UIElementBase {
|
|
668
|
+
_type: "iterator";
|
|
669
|
+
name: N;
|
|
670
|
+
contentData: ExtractFormData<E>[];
|
|
671
|
+
}
|
|
646
672
|
interface BaseInputConfig<T> {
|
|
647
673
|
label?: string;
|
|
648
674
|
defaultValue?: T;
|
|
@@ -693,11 +719,14 @@ type UIApiResponses = {
|
|
|
693
719
|
one: UiElementSelectOneApiResponse;
|
|
694
720
|
table: UiElementSelectTableApiResponse;
|
|
695
721
|
};
|
|
722
|
+
iterator: UiElementIteratorApiResponse;
|
|
696
723
|
interactive: {
|
|
697
724
|
print: UiElementPrintApiResponse;
|
|
698
725
|
pickList: UiElementPickListApiResponse;
|
|
699
726
|
};
|
|
700
727
|
};
|
|
728
|
+
type UiElementApiResponse = UiElementDividerApiResponse | UiElementMarkdownApiResponse | UiElementHeaderApiResponse | UiElementBannerApiResponse | UiElementImageApiResponse | UiElementCodeApiResponse | UiElementGridApiResponse | UiElementListApiResponse | UiElementTableApiResponse | UiElementKeyValueApiResponse | UiElementInputTextApiResponse | UiElementInputNumberApiResponse | UiElementInputBooleanApiResponse | UiElementInputDataGridApiResponse | UiElementSelectOneApiResponse | UiElementSelectTableApiResponse | UiElementIteratorApiResponse | UiElementPrintApiResponse | UiElementPickListApiResponse;
|
|
729
|
+
type UiElementApiResponses = UiElementApiResponse[];
|
|
701
730
|
|
|
702
731
|
declare class NonRetriableError extends Error {
|
|
703
732
|
constructor(message?: string);
|
package/dist/index.d.ts
CHANGED
|
@@ -545,6 +545,25 @@ type DataGridColumn = {
|
|
|
545
545
|
editable: boolean;
|
|
546
546
|
};
|
|
547
547
|
|
|
548
|
+
type UiElementIterator = <N extends string, T extends UIElements>(name: N, options: {
|
|
549
|
+
content: T;
|
|
550
|
+
validate?: ValidateFn<ExtractFormData<T>[]>;
|
|
551
|
+
max?: number;
|
|
552
|
+
min?: number;
|
|
553
|
+
}) => IteratorElementResponse<N, T>;
|
|
554
|
+
interface UiElementIteratorApiResponse extends BaseUiDisplayResponse<"ui.iterator"> {
|
|
555
|
+
name: string;
|
|
556
|
+
content: UiElementApiResponses;
|
|
557
|
+
max?: number;
|
|
558
|
+
min?: number;
|
|
559
|
+
validationError?: string;
|
|
560
|
+
contentValidationErrors?: Array<{
|
|
561
|
+
index: number;
|
|
562
|
+
name: string;
|
|
563
|
+
validationError: string;
|
|
564
|
+
}>;
|
|
565
|
+
}
|
|
566
|
+
|
|
548
567
|
type UiElementPrint = DisplayElementWithRequiredConfig<{
|
|
549
568
|
jobs: PrintData[] | PrintData;
|
|
550
569
|
title?: string;
|
|
@@ -600,6 +619,7 @@ interface UI<C extends FlowConfig> {
|
|
|
600
619
|
display: UiDisplayElements;
|
|
601
620
|
inputs: UiInputsElements;
|
|
602
621
|
select: UiSelectElements;
|
|
622
|
+
iterator: UiElementIterator;
|
|
603
623
|
interactive: UiInteractiveElements;
|
|
604
624
|
}
|
|
605
625
|
type UiInputsElements = {
|
|
@@ -631,7 +651,8 @@ type UiInteractiveElements = {
|
|
|
631
651
|
type InputElement<TValueType, TConfig extends any = never> = <N extends string>(name: N, options?: BaseInputConfig<TValueType> & TConfig) => InputElementResponse<N, TValueType>;
|
|
632
652
|
type DisplayElement<TConfig extends any = never> = (options?: TConfig) => DisplayElementResponse;
|
|
633
653
|
type DisplayElementWithRequiredConfig<TConfig extends any = never> = (options: TConfig) => DisplayElementResponse;
|
|
634
|
-
type
|
|
654
|
+
type UIElement = InputElementResponse<string, any> | DisplayElementResponse | IteratorElementResponse<string, any>;
|
|
655
|
+
type UIElements = UIElement[];
|
|
635
656
|
interface UIElementBase {
|
|
636
657
|
_type: string;
|
|
637
658
|
}
|
|
@@ -643,6 +664,11 @@ interface InputElementResponse<N extends string, V> extends UIElementBase {
|
|
|
643
664
|
interface DisplayElementResponse extends UIElementBase {
|
|
644
665
|
_type: "display";
|
|
645
666
|
}
|
|
667
|
+
interface IteratorElementResponse<N extends string, E extends UIElements> extends UIElementBase {
|
|
668
|
+
_type: "iterator";
|
|
669
|
+
name: N;
|
|
670
|
+
contentData: ExtractFormData<E>[];
|
|
671
|
+
}
|
|
646
672
|
interface BaseInputConfig<T> {
|
|
647
673
|
label?: string;
|
|
648
674
|
defaultValue?: T;
|
|
@@ -693,11 +719,14 @@ type UIApiResponses = {
|
|
|
693
719
|
one: UiElementSelectOneApiResponse;
|
|
694
720
|
table: UiElementSelectTableApiResponse;
|
|
695
721
|
};
|
|
722
|
+
iterator: UiElementIteratorApiResponse;
|
|
696
723
|
interactive: {
|
|
697
724
|
print: UiElementPrintApiResponse;
|
|
698
725
|
pickList: UiElementPickListApiResponse;
|
|
699
726
|
};
|
|
700
727
|
};
|
|
728
|
+
type UiElementApiResponse = UiElementDividerApiResponse | UiElementMarkdownApiResponse | UiElementHeaderApiResponse | UiElementBannerApiResponse | UiElementImageApiResponse | UiElementCodeApiResponse | UiElementGridApiResponse | UiElementListApiResponse | UiElementTableApiResponse | UiElementKeyValueApiResponse | UiElementInputTextApiResponse | UiElementInputNumberApiResponse | UiElementInputBooleanApiResponse | UiElementInputDataGridApiResponse | UiElementSelectOneApiResponse | UiElementSelectTableApiResponse | UiElementIteratorApiResponse | UiElementPrintApiResponse | UiElementPickListApiResponse;
|
|
729
|
+
type UiElementApiResponses = UiElementApiResponse[];
|
|
701
730
|
|
|
702
731
|
declare class NonRetriableError extends Error {
|
|
703
732
|
constructor(message?: string);
|
package/dist/index.js
CHANGED
|
@@ -2455,22 +2455,16 @@ async function page(options, data, action) {
|
|
|
2455
2455
|
}
|
|
2456
2456
|
}
|
|
2457
2457
|
const contentUiConfig = await Promise.all(
|
|
2458
|
-
content.map(async (
|
|
2459
|
-
|
|
2460
|
-
const
|
|
2461
|
-
const
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
validationError: validationError2
|
|
2469
|
-
};
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
|
-
return c.uiConfig;
|
|
2473
|
-
}).filter(Boolean)
|
|
2458
|
+
content.map(async (c) => {
|
|
2459
|
+
const resolvedC = await c;
|
|
2460
|
+
const elementData = data && typeof data === "object" && resolvedC.uiConfig.name in data ? data[resolvedC.uiConfig.name] : void 0;
|
|
2461
|
+
const { uiConfig, validationErrors } = await recursivelyProcessElement(
|
|
2462
|
+
c,
|
|
2463
|
+
elementData
|
|
2464
|
+
);
|
|
2465
|
+
if (validationErrors) hasValidationErrors = true;
|
|
2466
|
+
return uiConfig;
|
|
2467
|
+
})
|
|
2474
2468
|
);
|
|
2475
2469
|
if (data && options.validate) {
|
|
2476
2470
|
const validationResult = await options.validate(data);
|
|
@@ -2501,6 +2495,101 @@ async function page(options, data, action) {
|
|
|
2501
2495
|
};
|
|
2502
2496
|
}
|
|
2503
2497
|
__name(page, "page");
|
|
2498
|
+
var recursivelyProcessElement = /* @__PURE__ */ __name(async (c, data) => {
|
|
2499
|
+
const resolvedC = await c;
|
|
2500
|
+
const elementType = "__type" in resolvedC ? resolvedC.__type : null;
|
|
2501
|
+
switch (elementType) {
|
|
2502
|
+
case "input":
|
|
2503
|
+
return processInputElement(
|
|
2504
|
+
resolvedC,
|
|
2505
|
+
data
|
|
2506
|
+
);
|
|
2507
|
+
case "iterator":
|
|
2508
|
+
return processIteratorElement(
|
|
2509
|
+
resolvedC,
|
|
2510
|
+
data
|
|
2511
|
+
);
|
|
2512
|
+
default:
|
|
2513
|
+
return {
|
|
2514
|
+
uiConfig: { ...resolvedC.uiConfig },
|
|
2515
|
+
validationErrors: false
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
}, "recursivelyProcessElement");
|
|
2519
|
+
var processInputElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
2520
|
+
const hasData = data !== void 0 && data !== null;
|
|
2521
|
+
if (!hasData || !element.validate) {
|
|
2522
|
+
return {
|
|
2523
|
+
uiConfig: { ...element.uiConfig },
|
|
2524
|
+
validationErrors: false
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
const validationError = await element.validate(data);
|
|
2528
|
+
const hasValidationErrors = typeof validationError === "string";
|
|
2529
|
+
return {
|
|
2530
|
+
uiConfig: {
|
|
2531
|
+
...element.uiConfig,
|
|
2532
|
+
validationError: hasValidationErrors ? validationError : void 0
|
|
2533
|
+
},
|
|
2534
|
+
validationErrors: hasValidationErrors
|
|
2535
|
+
};
|
|
2536
|
+
}, "processInputElement");
|
|
2537
|
+
var processIteratorElement = /* @__PURE__ */ __name(async (element, data) => {
|
|
2538
|
+
const elements = element.uiConfig.content;
|
|
2539
|
+
const dataArr = data;
|
|
2540
|
+
const ui = [];
|
|
2541
|
+
for (const el of elements) {
|
|
2542
|
+
const result = await recursivelyProcessElement(el, void 0);
|
|
2543
|
+
ui.push(result.uiConfig);
|
|
2544
|
+
}
|
|
2545
|
+
const validationErrors = await validateIteratorData(elements, dataArr);
|
|
2546
|
+
let hasValidationErrors = validationErrors.length > 0;
|
|
2547
|
+
let validationError = void 0;
|
|
2548
|
+
if (dataArr && element.validate) {
|
|
2549
|
+
const v = await element.validate(dataArr);
|
|
2550
|
+
if (typeof v === "string") {
|
|
2551
|
+
hasValidationErrors = true;
|
|
2552
|
+
validationError = v;
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
return {
|
|
2556
|
+
uiConfig: {
|
|
2557
|
+
...element.uiConfig,
|
|
2558
|
+
content: ui,
|
|
2559
|
+
validationError,
|
|
2560
|
+
contentValidationErrors: hasValidationErrors ? validationErrors : void 0
|
|
2561
|
+
},
|
|
2562
|
+
validationErrors: hasValidationErrors
|
|
2563
|
+
};
|
|
2564
|
+
}, "processIteratorElement");
|
|
2565
|
+
var validateIteratorData = /* @__PURE__ */ __name(async (elements, dataArr) => {
|
|
2566
|
+
const validationErrors = [];
|
|
2567
|
+
if (!dataArr || dataArr.length === 0) {
|
|
2568
|
+
return validationErrors;
|
|
2569
|
+
}
|
|
2570
|
+
for (let i = 0; i < dataArr.length; i++) {
|
|
2571
|
+
const rowData = dataArr[i];
|
|
2572
|
+
for (const el of elements) {
|
|
2573
|
+
const resolvedEl = await el;
|
|
2574
|
+
if ("__type" in resolvedEl && resolvedEl.__type === "input" && "validate" in resolvedEl && resolvedEl.validate && typeof resolvedEl.validate === "function") {
|
|
2575
|
+
const fieldName = resolvedEl.uiConfig.name;
|
|
2576
|
+
if (rowData && typeof rowData === "object" && fieldName in rowData) {
|
|
2577
|
+
const validationError = await resolvedEl.validate(
|
|
2578
|
+
rowData[fieldName]
|
|
2579
|
+
);
|
|
2580
|
+
if (typeof validationError === "string") {
|
|
2581
|
+
validationErrors.push({
|
|
2582
|
+
index: i,
|
|
2583
|
+
name: fieldName,
|
|
2584
|
+
validationError
|
|
2585
|
+
});
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
return validationErrors;
|
|
2592
|
+
}, "validateIteratorData");
|
|
2504
2593
|
|
|
2505
2594
|
// src/flows/disrupts.ts
|
|
2506
2595
|
var FlowDisrupt = class {
|
|
@@ -2703,6 +2792,22 @@ var dataGridInput = /* @__PURE__ */ __name((name, options) => {
|
|
|
2703
2792
|
};
|
|
2704
2793
|
}, "dataGridInput");
|
|
2705
2794
|
|
|
2795
|
+
// src/flows/ui/elements/iterator.ts
|
|
2796
|
+
var iterator = /* @__PURE__ */ __name((name, options) => {
|
|
2797
|
+
return {
|
|
2798
|
+
__type: "iterator",
|
|
2799
|
+
uiConfig: {
|
|
2800
|
+
__type: "ui.iterator",
|
|
2801
|
+
name,
|
|
2802
|
+
content: options.content,
|
|
2803
|
+
max: options.max,
|
|
2804
|
+
min: options.min
|
|
2805
|
+
},
|
|
2806
|
+
validate: options?.validate,
|
|
2807
|
+
getData: /* @__PURE__ */ __name((x) => x, "getData")
|
|
2808
|
+
};
|
|
2809
|
+
}, "iterator");
|
|
2810
|
+
|
|
2706
2811
|
// src/flows/ui/elements/interactive/print.ts
|
|
2707
2812
|
var print = /* @__PURE__ */ __name(async (options) => {
|
|
2708
2813
|
const dataConfig = Array.isArray(options.jobs) ? options.jobs : [options.jobs];
|
|
@@ -2992,6 +3097,7 @@ function createFlowContext(runId, data, action, spanId, ctx) {
|
|
|
2992
3097
|
one: selectOne,
|
|
2993
3098
|
table: selectTable
|
|
2994
3099
|
},
|
|
3100
|
+
iterator,
|
|
2995
3101
|
interactive: {
|
|
2996
3102
|
print,
|
|
2997
3103
|
pickList
|