@teamkeel/functions-runtime 0.421.0 → 0.421.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.d.cts CHANGED
@@ -593,8 +593,8 @@ interface UiElementIteratorApiResponse extends BaseUiDisplayResponse<"ui.iterato
593
593
  }>;
594
594
  }
595
595
 
596
- type UiElementPrint = DisplayElementWithRequiredConfig<{
597
- jobs: PrintData[] | PrintData;
596
+ type UiElementPrint<H extends NullableHardware> = DisplayElementWithRequiredConfig<{
597
+ jobs: PrintData<H>[] | PrintData<H>;
598
598
  title?: string;
599
599
  description?: string;
600
600
  /** If true, the jobs will be automatically printed. */
@@ -602,8 +602,9 @@ type UiElementPrint = DisplayElementWithRequiredConfig<{
602
602
  /** If true, the flow will continue after the jobs are complete. */
603
603
  autoContinue?: boolean;
604
604
  }>;
605
- type PrintData = {
605
+ type PrintData<H extends NullableHardware> = {
606
606
  type: "zpl";
607
+ printer?: H extends Hardware ? H["printers"][number]["name"] : never;
607
608
  name?: string;
608
609
  data: string | string[];
609
610
  };
@@ -614,6 +615,7 @@ interface UiElementPrintApiResponse extends BaseUiDisplayResponse<"ui.interactiv
614
615
  type: "url" | "text" | "html" | "zpl";
615
616
  data?: string[];
616
617
  url?: string;
618
+ printer?: string;
617
619
  }[];
618
620
  autoPrint: boolean;
619
621
  }
@@ -625,6 +627,7 @@ type PickListResponseItem = {
625
627
  id: string;
626
628
  quantity: number;
627
629
  targetQuantity: number;
630
+ scannedBarcodes?: string[];
628
631
  };
629
632
  type PickListItem = {
630
633
  id: string;
@@ -637,7 +640,7 @@ type PickListItem = {
637
640
  type ListOptions<T> = {
638
641
  data: T[];
639
642
  render: (data: T) => PickListItem;
640
- validate?: ValidateFn<PickListResponseItem>;
643
+ validate?: ValidateFn<PickListResponseItem[]>;
641
644
  };
642
645
  interface UiElementPickListApiResponse extends BaseUiMinimalInputResponse<"ui.interactive.pickList"> {
643
646
  data: PickListItem[];
@@ -704,13 +707,13 @@ interface UiElementFileApiResponse extends BaseUiDisplayResponse<"ui.display.fil
704
707
  };
705
708
  }
706
709
 
707
- interface UI<C extends FlowConfig> {
710
+ interface UI<C extends FlowConfig, H extends NullableHardware> {
708
711
  page: UiPage<C>;
709
712
  display: UiDisplayElements;
710
713
  inputs: UiInputsElements;
711
714
  select: UiSelectElements;
712
715
  iterator: UiElementIterator;
713
- interactive: UiInteractiveElements;
716
+ interactive: UiInteractiveElements<H>;
714
717
  }
715
718
  type UiInputsElements = {
716
719
  text: UiElementInputText;
@@ -736,8 +739,8 @@ type UiDisplayElements = {
736
739
  keyValue: UiElementKeyValue;
737
740
  file: UiElementFile;
738
741
  };
739
- type UiInteractiveElements = {
740
- print: UiElementPrint;
742
+ type UiInteractiveElements<H extends NullableHardware> = {
743
+ print: UiElementPrint<H>;
741
744
  pickList: UiElementPickList;
742
745
  };
743
746
  type InputElement<TValueType, TConfig extends any = never> = <N extends string>(name: N, options?: BaseInputConfig<TValueType> & TConfig) => InputElementResponse<N, TValueType>;
@@ -858,15 +861,22 @@ declare const RetryConstant: (intervalS: number) => RetryPolicyFn;
858
861
  * @param intervalS the base duration in seconds.
859
862
  */
860
863
  declare const RetryBackoffExponential: (intervalS: number) => RetryPolicyFn;
861
- interface FlowContext<C extends FlowConfig, E, S, Id, I> {
864
+ interface FlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardware> {
862
865
  step: Step<C>;
863
- ui: UI<C>;
866
+ ui: UI<C, H>;
864
867
  complete: Complete<C, I>;
865
868
  env: E;
866
869
  now: Date;
867
870
  secrets: S;
868
871
  identity: Id;
869
872
  }
873
+ type NullableHardware = Hardware | undefined;
874
+ type Hardware = {
875
+ printers: Printer[];
876
+ };
877
+ interface Printer {
878
+ name: string;
879
+ }
870
880
  type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
871
881
  [key: string]: JsonSerializable;
872
882
  };
@@ -913,7 +923,7 @@ interface FlowConfigAPI {
913
923
  title: string;
914
924
  description?: string;
915
925
  }
916
- type FlowFunction<C extends FlowConfig, E, S, Id, I = undefined> = (ctx: FlowContext<C, E, S, Id, I>, inputs: I) => Promise<CompleteOptions<C, I> | any | void>;
926
+ type FlowFunction<C extends FlowConfig, E, S, Id, I = undefined, H extends NullableHardware = undefined> = (ctx: FlowContext<C, E, S, Id, I, H>, inputs: I) => Promise<CompleteOptions<C, I> | any | void>;
917
927
  type ExtractStageKeys<T extends FlowConfig> = T extends {
918
928
  stages: infer S;
919
929
  } ? S extends ReadonlyArray<infer U> ? U extends string ? U : U extends {
@@ -930,12 +940,12 @@ type StageConfigObject = {
930
940
  initiallyHidden?: boolean;
931
941
  };
932
942
  type StageConfig = string | StageConfigObject;
933
- declare function createFlowContext<C extends FlowConfig, E, S, Id, I>(runId: string, data: any, action: string | null, callback: string | null, element: string | null, spanId: string, ctx: {
943
+ declare function createFlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardware>(runId: string, data: any, action: string | null, callback: string | null, element: string | null, spanId: string, ctx: {
934
944
  env: E;
935
945
  now: Date;
936
946
  secrets: S;
937
947
  identity: Id;
938
- }): FlowContext<C, E, S, Id, I>;
948
+ }): FlowContext<C, E, S, Id, I, H>;
939
949
 
940
950
  declare function ksuid(): string;
941
951
 
@@ -1105,4 +1115,4 @@ type dateDuration = `${number}Y${number}M${number}D` | `${number}Y${number}M` |
1105
1115
  type timeDuration = `${number}H${number}M${number}S` | `${number}H${number}M` | `${number}M${number}S` | `${number}H${number}S` | `${number}H` | `${number}M` | `${number}S`;
1106
1116
  type DurationString = `P${dateDuration}T${timeDuration}` | `P${dateDuration}` | `PT${timeDuration}`;
1107
1117
 
1108
- export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
1118
+ export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
package/dist/index.d.ts CHANGED
@@ -593,8 +593,8 @@ interface UiElementIteratorApiResponse extends BaseUiDisplayResponse<"ui.iterato
593
593
  }>;
594
594
  }
595
595
 
596
- type UiElementPrint = DisplayElementWithRequiredConfig<{
597
- jobs: PrintData[] | PrintData;
596
+ type UiElementPrint<H extends NullableHardware> = DisplayElementWithRequiredConfig<{
597
+ jobs: PrintData<H>[] | PrintData<H>;
598
598
  title?: string;
599
599
  description?: string;
600
600
  /** If true, the jobs will be automatically printed. */
@@ -602,8 +602,9 @@ type UiElementPrint = DisplayElementWithRequiredConfig<{
602
602
  /** If true, the flow will continue after the jobs are complete. */
603
603
  autoContinue?: boolean;
604
604
  }>;
605
- type PrintData = {
605
+ type PrintData<H extends NullableHardware> = {
606
606
  type: "zpl";
607
+ printer?: H extends Hardware ? H["printers"][number]["name"] : never;
607
608
  name?: string;
608
609
  data: string | string[];
609
610
  };
@@ -614,6 +615,7 @@ interface UiElementPrintApiResponse extends BaseUiDisplayResponse<"ui.interactiv
614
615
  type: "url" | "text" | "html" | "zpl";
615
616
  data?: string[];
616
617
  url?: string;
618
+ printer?: string;
617
619
  }[];
618
620
  autoPrint: boolean;
619
621
  }
@@ -625,6 +627,7 @@ type PickListResponseItem = {
625
627
  id: string;
626
628
  quantity: number;
627
629
  targetQuantity: number;
630
+ scannedBarcodes?: string[];
628
631
  };
629
632
  type PickListItem = {
630
633
  id: string;
@@ -637,7 +640,7 @@ type PickListItem = {
637
640
  type ListOptions<T> = {
638
641
  data: T[];
639
642
  render: (data: T) => PickListItem;
640
- validate?: ValidateFn<PickListResponseItem>;
643
+ validate?: ValidateFn<PickListResponseItem[]>;
641
644
  };
642
645
  interface UiElementPickListApiResponse extends BaseUiMinimalInputResponse<"ui.interactive.pickList"> {
643
646
  data: PickListItem[];
@@ -704,13 +707,13 @@ interface UiElementFileApiResponse extends BaseUiDisplayResponse<"ui.display.fil
704
707
  };
705
708
  }
706
709
 
707
- interface UI<C extends FlowConfig> {
710
+ interface UI<C extends FlowConfig, H extends NullableHardware> {
708
711
  page: UiPage<C>;
709
712
  display: UiDisplayElements;
710
713
  inputs: UiInputsElements;
711
714
  select: UiSelectElements;
712
715
  iterator: UiElementIterator;
713
- interactive: UiInteractiveElements;
716
+ interactive: UiInteractiveElements<H>;
714
717
  }
715
718
  type UiInputsElements = {
716
719
  text: UiElementInputText;
@@ -736,8 +739,8 @@ type UiDisplayElements = {
736
739
  keyValue: UiElementKeyValue;
737
740
  file: UiElementFile;
738
741
  };
739
- type UiInteractiveElements = {
740
- print: UiElementPrint;
742
+ type UiInteractiveElements<H extends NullableHardware> = {
743
+ print: UiElementPrint<H>;
741
744
  pickList: UiElementPickList;
742
745
  };
743
746
  type InputElement<TValueType, TConfig extends any = never> = <N extends string>(name: N, options?: BaseInputConfig<TValueType> & TConfig) => InputElementResponse<N, TValueType>;
@@ -858,15 +861,22 @@ declare const RetryConstant: (intervalS: number) => RetryPolicyFn;
858
861
  * @param intervalS the base duration in seconds.
859
862
  */
860
863
  declare const RetryBackoffExponential: (intervalS: number) => RetryPolicyFn;
861
- interface FlowContext<C extends FlowConfig, E, S, Id, I> {
864
+ interface FlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardware> {
862
865
  step: Step<C>;
863
- ui: UI<C>;
866
+ ui: UI<C, H>;
864
867
  complete: Complete<C, I>;
865
868
  env: E;
866
869
  now: Date;
867
870
  secrets: S;
868
871
  identity: Id;
869
872
  }
873
+ type NullableHardware = Hardware | undefined;
874
+ type Hardware = {
875
+ printers: Printer[];
876
+ };
877
+ interface Printer {
878
+ name: string;
879
+ }
870
880
  type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
871
881
  [key: string]: JsonSerializable;
872
882
  };
@@ -913,7 +923,7 @@ interface FlowConfigAPI {
913
923
  title: string;
914
924
  description?: string;
915
925
  }
916
- type FlowFunction<C extends FlowConfig, E, S, Id, I = undefined> = (ctx: FlowContext<C, E, S, Id, I>, inputs: I) => Promise<CompleteOptions<C, I> | any | void>;
926
+ type FlowFunction<C extends FlowConfig, E, S, Id, I = undefined, H extends NullableHardware = undefined> = (ctx: FlowContext<C, E, S, Id, I, H>, inputs: I) => Promise<CompleteOptions<C, I> | any | void>;
917
927
  type ExtractStageKeys<T extends FlowConfig> = T extends {
918
928
  stages: infer S;
919
929
  } ? S extends ReadonlyArray<infer U> ? U extends string ? U : U extends {
@@ -930,12 +940,12 @@ type StageConfigObject = {
930
940
  initiallyHidden?: boolean;
931
941
  };
932
942
  type StageConfig = string | StageConfigObject;
933
- declare function createFlowContext<C extends FlowConfig, E, S, Id, I>(runId: string, data: any, action: string | null, callback: string | null, element: string | null, spanId: string, ctx: {
943
+ declare function createFlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardware>(runId: string, data: any, action: string | null, callback: string | null, element: string | null, spanId: string, ctx: {
934
944
  env: E;
935
945
  now: Date;
936
946
  secrets: S;
937
947
  identity: Id;
938
- }): FlowContext<C, E, S, Id, I>;
948
+ }): FlowContext<C, E, S, Id, I, H>;
939
949
 
940
950
  declare function ksuid(): string;
941
951
 
@@ -1105,4 +1115,4 @@ type dateDuration = `${number}Y${number}M${number}D` | `${number}Y${number}M` |
1105
1115
  type timeDuration = `${number}H${number}M${number}S` | `${number}H${number}M` | `${number}M${number}S` | `${number}H${number}S` | `${number}H` | `${number}M` | `${number}S`;
1106
1116
  type DurationString = `P${dateDuration}T${timeDuration}` | `P${dateDuration}` | `PT${timeDuration}`;
1107
1117
 
1108
- export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
1118
+ export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
package/dist/index.js CHANGED
@@ -2850,7 +2850,8 @@ var print = /* @__PURE__ */ __name(async (options) => {
2850
2850
  return {
2851
2851
  type: d.type,
2852
2852
  name: d.name,
2853
- data: Array.isArray(d.data) ? d.data : [d.data]
2853
+ data: Array.isArray(d.data) ? d.data : [d.data],
2854
+ printer: d.printer
2854
2855
  };
2855
2856
  }
2856
2857
  return null;
@@ -2894,7 +2895,7 @@ var pickList = /* @__PURE__ */ __name((name, options) => {
2894
2895
  return "Items must be an array";
2895
2896
  }
2896
2897
  if (data.items.some(
2897
- (item) => typeof item !== "object" || typeof item.id !== "string" || typeof item.qty !== "number"
2898
+ (item) => typeof item !== "object" || typeof item.id !== "string" || typeof item.quantity !== "number" || typeof item.targetQuantity !== "number" || item.scannedBarcodes && !Array.isArray(item.scannedBarcodes)
2898
2899
  )) {
2899
2900
  return "Invalid data";
2900
2901
  }