@teamkeel/functions-runtime 0.413.3 → 0.413.4

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
@@ -557,18 +557,24 @@ interface FlowConfig {
557
557
  title?: string;
558
558
  description?: string;
559
559
  }
560
+ interface FlowConfigAPI {
561
+ stages?: StageConfigObject[];
562
+ title: string;
563
+ description?: string;
564
+ }
560
565
  type FlowFunction<C extends FlowConfig, I extends any = {}> = (ctx: FlowContext<C>, inputs: I) => Promise<void>;
561
566
  type ExtractStageKeys<T extends FlowConfig> = T extends {
562
567
  stages: infer S;
563
568
  } ? S extends ReadonlyArray<infer U> ? U extends string ? U : U extends {
564
569
  key: infer K extends string;
565
570
  } ? K : never : never : never;
566
- type StageConfig = string | {
571
+ type StageConfigObject = {
567
572
  key: string;
568
573
  name: string;
569
574
  description?: string;
570
575
  initiallyHidden?: boolean;
571
576
  };
577
+ type StageConfig = string | StageConfigObject;
572
578
  declare function createFlowContext<C extends FlowConfig>(runId: string, data: any, spanId: string): FlowContext<C>;
573
579
 
574
580
  declare function ksuid(): string;
@@ -739,4 +745,4 @@ type dateDuration = `${number}Y${number}M${number}D` | `${number}Y${number}M` |
739
745
  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`;
740
746
  type DurationString = `P${dateDuration}T${timeDuration}` | `P${dateDuration}` | `PT${timeDuration}`;
741
747
 
742
- 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 FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type IDWhereCondition, InlineFile, ModelAPI, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders, type Response, 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 };
748
+ 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, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders, type Response, 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
@@ -557,18 +557,24 @@ interface FlowConfig {
557
557
  title?: string;
558
558
  description?: string;
559
559
  }
560
+ interface FlowConfigAPI {
561
+ stages?: StageConfigObject[];
562
+ title: string;
563
+ description?: string;
564
+ }
560
565
  type FlowFunction<C extends FlowConfig, I extends any = {}> = (ctx: FlowContext<C>, inputs: I) => Promise<void>;
561
566
  type ExtractStageKeys<T extends FlowConfig> = T extends {
562
567
  stages: infer S;
563
568
  } ? S extends ReadonlyArray<infer U> ? U extends string ? U : U extends {
564
569
  key: infer K extends string;
565
570
  } ? K : never : never : never;
566
- type StageConfig = string | {
571
+ type StageConfigObject = {
567
572
  key: string;
568
573
  name: string;
569
574
  description?: string;
570
575
  initiallyHidden?: boolean;
571
576
  };
577
+ type StageConfig = string | StageConfigObject;
572
578
  declare function createFlowContext<C extends FlowConfig>(runId: string, data: any, spanId: string): FlowContext<C>;
573
579
 
574
580
  declare function ksuid(): string;
@@ -739,4 +745,4 @@ type dateDuration = `${number}Y${number}M${number}D` | `${number}Y${number}M` |
739
745
  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`;
740
746
  type DurationString = `P${dateDuration}T${timeDuration}` | `P${dateDuration}` | `PT${timeDuration}`;
741
747
 
742
- 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 FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type IDWhereCondition, InlineFile, ModelAPI, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders, type Response, 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 };
748
+ 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, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders, type Response, 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
@@ -2290,7 +2290,7 @@ async function handleRoute(request, config) {
2290
2290
  }
2291
2291
  __name(handleRoute, "handleRoute");
2292
2292
 
2293
- // src/handleFlow.js
2293
+ // src/handleFlow.ts
2294
2294
  import {
2295
2295
  createJSONRPCErrorResponse as createJSONRPCErrorResponse6,
2296
2296
  createJSONRPCSuccessResponse as createJSONRPCSuccessResponse5,
@@ -2692,7 +2692,8 @@ function withTimeout(promiseFn, timeout) {
2692
2692
  }
2693
2693
  __name(withTimeout, "withTimeout");
2694
2694
 
2695
- // src/handleFlow.js
2695
+ // src/handleFlow.ts
2696
+ import { sentenceCase } from "change-case";
2696
2697
  async function handleFlow(request, config) {
2697
2698
  const activeContext = opentelemetry6.propagation.extract(
2698
2699
  opentelemetry6.context.active(),
@@ -2733,7 +2734,20 @@ async function handleFlow(request, config) {
2733
2734
  span.spanContext().spanId
2734
2735
  );
2735
2736
  const flowFunction = flows[request.method].fn;
2736
- flowConfig = flows[request.method].config;
2737
+ const rawFlowConfig = flows[request.method].config;
2738
+ flowConfig = {
2739
+ ...rawFlowConfig,
2740
+ title: rawFlowConfig.title || sentenceCase(request.method || "flow"),
2741
+ stages: rawFlowConfig.stages?.map((stage) => {
2742
+ if (typeof stage === "string") {
2743
+ return {
2744
+ key: stage,
2745
+ name: stage
2746
+ };
2747
+ }
2748
+ return stage;
2749
+ })
2750
+ };
2737
2751
  const inputs = parseInputs(flowRun.input);
2738
2752
  try {
2739
2753
  await tryExecuteFlow(db, async () => {
@@ -2758,7 +2772,7 @@ async function handleFlow(request, config) {
2758
2772
  span.recordException(e);
2759
2773
  span.setStatus({
2760
2774
  code: opentelemetry6.SpanStatusCode.ERROR,
2761
- message: e.message
2775
+ message: e instanceof Error ? e.message : "unknown error"
2762
2776
  });
2763
2777
  if (e instanceof ExhuastedRetriesDisrupt) {
2764
2778
  return createJSONRPCSuccessResponse5(request.id, {
@@ -2771,7 +2785,7 @@ async function handleFlow(request, config) {
2771
2785
  return createJSONRPCSuccessResponse5(request.id, {
2772
2786
  runId,
2773
2787
  runCompleted: true,
2774
- error: e.message,
2788
+ error: e instanceof Error ? e.message : "unknown error",
2775
2789
  config: flowConfig
2776
2790
  });
2777
2791
  }