@teamkeel/functions-runtime 0.416.0 → 0.416.1

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 CHANGED
@@ -41,6 +41,9 @@ __export(index_exports, {
41
41
  PERMISSION_STATE: () => PERMISSION_STATE,
42
42
  Permissions: () => Permissions,
43
43
  RequestHeaders: () => RequestHeaders,
44
+ RetryBackoffExponential: () => RetryBackoffExponential,
45
+ RetryBackoffLinear: () => RetryBackoffLinear,
46
+ RetryConstant: () => RetryConstant,
44
47
  STEP_STATUS: () => STEP_STATUS,
45
48
  STEP_TYPE: () => STEP_TYPE,
46
49
  checkBuiltInPermissions: () => checkBuiltInPermissions,
@@ -2637,12 +2640,13 @@ var UIRenderDisrupt = class extends FlowDisrupt {
2637
2640
  }
2638
2641
  };
2639
2642
  var StepCreatedDisrupt = class extends FlowDisrupt {
2643
+ constructor(executeAfter) {
2644
+ super();
2645
+ this.executeAfter = executeAfter;
2646
+ }
2640
2647
  static {
2641
2648
  __name(this, "StepCreatedDisrupt");
2642
2649
  }
2643
- constructor() {
2644
- super();
2645
- }
2646
2650
  };
2647
2651
  var ExhuastedRetriesDisrupt = class extends FlowDisrupt {
2648
2652
  static {
@@ -2923,6 +2927,20 @@ var STEP_TYPE = /* @__PURE__ */ ((STEP_TYPE2) => {
2923
2927
  STEP_TYPE2["COMPLETE"] = "COMPLETE";
2924
2928
  return STEP_TYPE2;
2925
2929
  })(STEP_TYPE || {});
2930
+ var RetryBackoffLinear = /* @__PURE__ */ __name((intervalS) => {
2931
+ return (retry) => retry * intervalS * 1e3;
2932
+ }, "RetryBackoffLinear");
2933
+ var RetryConstant = /* @__PURE__ */ __name((intervalS) => {
2934
+ return (retry) => retry > 0 ? intervalS * 1e3 : 0;
2935
+ }, "RetryConstant");
2936
+ var RetryBackoffExponential = /* @__PURE__ */ __name((intervalS) => {
2937
+ return (retry) => {
2938
+ if (retry < 1) {
2939
+ return 0;
2940
+ }
2941
+ return Math.pow(intervalS, retry) * 1e3;
2942
+ };
2943
+ }, "RetryBackoffExponential");
2926
2944
  var defaultOpts = {
2927
2945
  retries: 4,
2928
2946
  timeout: 6e4
@@ -3013,7 +3031,11 @@ function createFlowContext(runId, data, action, spanId, ctx) {
3013
3031
  status: "NEW" /* NEW */,
3014
3032
  type: "FUNCTION" /* FUNCTION */
3015
3033
  }).returningAll().executeTakeFirst();
3016
- throw new StepCreatedDisrupt();
3034
+ throw new StepCreatedDisrupt(
3035
+ options.retryPolicy ? new Date(
3036
+ Date.now() + options.retryPolicy(failedSteps.length + 1)
3037
+ ) : void 0
3038
+ );
3017
3039
  }
3018
3040
  await db.updateTable("keel.flow_step").set({
3019
3041
  status: "COMPLETED" /* COMPLETED */,
@@ -3233,7 +3255,8 @@ async function handleFlow(request, config) {
3233
3255
  return (0, import_json_rpc_26.createJSONRPCSuccessResponse)(request.id, {
3234
3256
  runId,
3235
3257
  runCompleted: false,
3236
- config: flowConfig
3258
+ config: flowConfig,
3259
+ executeAfter: e.executeAfter
3237
3260
  });
3238
3261
  }
3239
3262
  if (e instanceof UIRenderDisrupt) {
@@ -3338,6 +3361,9 @@ __name(ksuid, "ksuid");
3338
3361
  PERMISSION_STATE,
3339
3362
  Permissions,
3340
3363
  RequestHeaders,
3364
+ RetryBackoffExponential,
3365
+ RetryBackoffLinear,
3366
+ RetryConstant,
3341
3367
  STEP_STATUS,
3342
3368
  STEP_TYPE,
3343
3369
  checkBuiltInPermissions,