@juhuu/sdk-ts 1.2.273 → 1.2.274

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.mts CHANGED
@@ -1708,10 +1708,7 @@ declare class FlowsService extends Service {
1708
1708
  private resolveInputs;
1709
1709
  private isInputConnected;
1710
1710
  private blockExecutors;
1711
- executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.Execute.Options): Promise<{
1712
- output: Record<string, any>;
1713
- logArray: FlowLog[];
1714
- }>;
1711
+ executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.ExecuteLocally.Options): Promise<JUHUU.Flow.ExecuteLocally.Response>;
1715
1712
  }
1716
1713
 
1717
1714
  declare class FlowTracesService extends Service {
package/dist/index.d.ts CHANGED
@@ -1708,10 +1708,7 @@ declare class FlowsService extends Service {
1708
1708
  private resolveInputs;
1709
1709
  private isInputConnected;
1710
1710
  private blockExecutors;
1711
- executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.Execute.Options): Promise<{
1712
- output: Record<string, any>;
1713
- logArray: FlowLog[];
1714
- }>;
1711
+ executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.ExecuteLocally.Options): Promise<JUHUU.Flow.ExecuteLocally.Response>;
1715
1712
  }
1716
1713
 
1717
1714
  declare class FlowTracesService extends Service {
package/dist/index.js CHANGED
@@ -3787,119 +3787,27 @@ var FlowsService = class extends Service {
3787
3787
  flowId: finalFlowId,
3788
3788
  input: execInput
3789
3789
  });
3790
- if (!response.ok) {
3791
- throw new Error(`Failed to execute flow: ${response.data?.message || "Unknown error"}`);
3790
+ if (response.ok === false) {
3791
+ throw new Error(
3792
+ `Failed to execute flow: ${response.data?.message || "Unknown error"}`
3793
+ );
3792
3794
  }
3793
3795
  return { output: response.data.output };
3794
3796
  },
3795
3797
  "end.custom": async (inputs) => {
3796
3798
  return { output: { ...inputs } };
3797
3799
  },
3798
- // Placeholder implementations for other block types (they will throw errors if used)
3799
- "start.quickAction.location": async () => {
3800
- throw new Error("Block type not implemented in executeLocally");
3801
- },
3802
- "start.session.update": async () => {
3803
- throw new Error("Block type not implemented in executeLocally");
3804
- },
3805
- "start.location.update": async () => {
3806
- throw new Error("Block type not implemented in executeLocally");
3807
- },
3808
- "start.parameter.update": async () => {
3809
- throw new Error("Block type not implemented in executeLocally");
3810
- },
3811
- "const.number": async () => {
3812
- throw new Error("Block type not implemented in executeLocally");
3813
- },
3814
- "const.text": async () => {
3815
- throw new Error("Block type not implemented in executeLocally");
3816
- },
3817
- "const.boolean": async () => {
3818
- throw new Error("Block type not implemented in executeLocally");
3819
- },
3820
- "math.add": async () => {
3821
- throw new Error("Block type not implemented in executeLocally");
3822
- },
3823
- "math.subtract": async () => {
3824
- throw new Error("Block type not implemented in executeLocally");
3825
- },
3826
- "math.multiply": async () => {
3827
- throw new Error("Block type not implemented in executeLocally");
3828
- },
3829
- "math.divide": async () => {
3830
- throw new Error("Block type not implemented in executeLocally");
3831
- },
3832
- "map.destructure": async () => {
3833
- throw new Error("Block type not implemented in executeLocally");
3834
- },
3835
- "parameter.retrieve": async () => {
3836
- throw new Error("Block type not implemented in executeLocally");
3837
- },
3838
- "property.retrieve": async () => {
3839
- throw new Error("Block type not implemented in executeLocally");
3840
- },
3841
- "location.retrieve": async () => {
3842
- throw new Error("Block type not implemented in executeLocally");
3843
- },
3844
- "session.retrieve": async () => {
3845
- throw new Error("Block type not implemented in executeLocally");
3846
- },
3847
- "device.retrieve": async () => {
3848
- throw new Error("Block type not implemented in executeLocally");
3849
- },
3850
- "user.retrieve": async () => {
3851
- throw new Error("Block type not implemented in executeLocally");
3852
- },
3853
- "user.create": async () => {
3854
- throw new Error("Block type not implemented in executeLocally");
3855
- },
3856
- "incident.retrieve": async () => {
3857
- throw new Error("Block type not implemented in executeLocally");
3858
- },
3859
- "parameter.update": async () => {
3860
- throw new Error("Block type not implemented in executeLocally");
3800
+ "const.number": async (_inputs, block) => {
3801
+ const { data } = block;
3802
+ return { output: { value: data?.value } };
3861
3803
  },
3862
- "device.update": async () => {
3863
- throw new Error("Block type not implemented in executeLocally");
3804
+ "const.text": async (_inputs, block) => {
3805
+ const { data } = block;
3806
+ return { output: { value: data?.value } };
3864
3807
  },
3865
- "location.update": async () => {
3866
- throw new Error("Block type not implemented in executeLocally");
3867
- },
3868
- "property.update": async () => {
3869
- throw new Error("Block type not implemented in executeLocally");
3870
- },
3871
- "session.terminate": async () => {
3872
- throw new Error("Block type not implemented in executeLocally");
3873
- },
3874
- "system.log": async () => {
3875
- throw new Error("Block type not implemented in executeLocally");
3876
- },
3877
- "ui.navigate.screen": async () => {
3878
- throw new Error("Block type not implemented in executeLocally");
3879
- },
3880
- "incident.create": async () => {
3881
- throw new Error("Block type not implemented in executeLocally");
3882
- },
3883
- "control.switch": async () => {
3884
- throw new Error("Block type not implemented in executeLocally");
3885
- },
3886
- "http.patch": async () => {
3887
- throw new Error("Block type not implemented in executeLocally");
3888
- },
3889
- "http.get": async () => {
3890
- throw new Error("Block type not implemented in executeLocally");
3891
- },
3892
- "http.post": async () => {
3893
- throw new Error("Block type not implemented in executeLocally");
3894
- },
3895
- "http.delete": async () => {
3896
- throw new Error("Block type not implemented in executeLocally");
3897
- },
3898
- "http.put": async () => {
3899
- throw new Error("Block type not implemented in executeLocally");
3900
- },
3901
- "mqtt.send": async () => {
3902
- throw new Error("Block type not implemented in executeLocally");
3808
+ "const.boolean": async (_inputs, block) => {
3809
+ const { data } = block;
3810
+ return { output: { value: data?.value } };
3903
3811
  }
3904
3812
  };
3905
3813
  async executeLocally(FlowExecuteLocallyParams, FlowExecuteLocallyOptions) {
@@ -3909,100 +3817,114 @@ var FlowsService = class extends Service {
3909
3817
  message: `Starting local execution of flow '${FlowExecuteLocallyParams.flowId}'`,
3910
3818
  severity: "info"
3911
3819
  });
3912
- const flowResponse = await this.retrieve({
3913
- flowId: FlowExecuteLocallyParams.flowId
3914
- });
3915
- if (!flowResponse.ok) {
3916
- throw new Error(
3917
- `Failed to retrieve flow: ${flowResponse.data?.message || "Unknown error"}`
3918
- );
3919
- }
3920
- const flow = flowResponse.data.flow;
3921
- const blocksById = new Map(
3922
- flow.nodeArray.map((b) => [b.id, b])
3923
- );
3924
- blocksById.set(flow.startNode.id, flow.startNode);
3925
- const edgeArray = flow.edgeArray;
3926
- const outputStore = {};
3927
- const runBlock = async (block) => {
3928
- logArray.push({
3929
- createdAt: /* @__PURE__ */ new Date(),
3930
- message: `Running block ${block.type} (${block.id})`,
3931
- severity: "info"
3820
+ try {
3821
+ const flowResponse = await this.retrieve({
3822
+ flowId: FlowExecuteLocallyParams.flowId
3932
3823
  });
3933
- const inputs = this.resolveInputs(block, outputStore, edgeArray);
3934
- const executor = this.blockExecutors[block.type];
3935
- if (executor === void 0 || executor === null) {
3936
- throw new Error(`No executor for ${block.type}`);
3824
+ if (!flowResponse.ok) {
3825
+ throw new Error(
3826
+ `Failed to retrieve flow: ${flowResponse.data?.message || "Unknown error"}`
3827
+ );
3937
3828
  }
3938
- const raw = await executor(
3939
- inputs,
3940
- block,
3941
- FlowExecuteLocallyParams.input ?? {}
3829
+ const flow = flowResponse.data.flow;
3830
+ const blocksById = new Map(
3831
+ flow.nodeArray.map((b) => [b.id, b])
3942
3832
  );
3943
- const { flowBranch, output } = raw;
3944
- outputStore[block.id] = output;
3945
- if (raw.logArray !== void 0) {
3946
- logArray.push(...raw.logArray);
3833
+ blocksById.set(flow.startNode.id, flow.startNode);
3834
+ const edgeArray = flow.edgeArray;
3835
+ const outputStore = {};
3836
+ const runBlock = async (block) => {
3837
+ logArray.push({
3838
+ createdAt: /* @__PURE__ */ new Date(),
3839
+ message: `Running block ${block.type} (${block.id})`,
3840
+ severity: "info"
3841
+ });
3842
+ const inputs = this.resolveInputs(block, outputStore, edgeArray);
3843
+ const executor = this.blockExecutors[block.type];
3844
+ if (executor === void 0 || executor === null) {
3845
+ throw new Error(
3846
+ `Block type '${block.type}' is not implemented in the local executor`
3847
+ );
3848
+ }
3849
+ const raw = await executor(
3850
+ inputs,
3851
+ block,
3852
+ FlowExecuteLocallyParams.input ?? {}
3853
+ );
3854
+ const { flowBranch, output } = raw;
3855
+ outputStore[block.id] = output;
3856
+ if (raw.logArray !== void 0) {
3857
+ logArray.push(...raw.logArray);
3858
+ }
3859
+ logArray.push({
3860
+ createdAt: /* @__PURE__ */ new Date(),
3861
+ message: `Block ${block.type} (${block.id}) executed successfully`,
3862
+ severity: "info"
3863
+ });
3864
+ return flowBranch ?? null;
3865
+ };
3866
+ const getNext = (fromId, branch) => {
3867
+ let ce = edgeArray.find(
3868
+ (e) => e.type === "control" && e.from.blockId === fromId && (e.from.output ?? null) === branch
3869
+ );
3870
+ if ((ce === null || ce === void 0) && branch === null) {
3871
+ ce = edgeArray.find(
3872
+ (e) => e.type === "control" && e.from.blockId === fromId
3873
+ );
3874
+ }
3875
+ if (ce === null || ce === void 0) {
3876
+ return null;
3877
+ }
3878
+ return blocksById.get(ce.to.blockId) ?? null;
3879
+ };
3880
+ if (flow.startNode.type.startsWith("start.") === false) {
3881
+ throw new Error(
3882
+ `Flow ${FlowExecuteLocallyParams.flowId} has an invalid start block that is not of type 'start.'`
3883
+ );
3884
+ }
3885
+ let current = flow.startNode;
3886
+ await runBlock(current);
3887
+ const next = getNext(current.id, null);
3888
+ if (next === null) {
3889
+ return {
3890
+ output: {},
3891
+ logArray
3892
+ };
3893
+ }
3894
+ current = next;
3895
+ while (current.type.startsWith("end.") === false) {
3896
+ const branch = await runBlock(current);
3897
+ const next2 = getNext(current.id, branch);
3898
+ if (next2 === null) {
3899
+ return {
3900
+ output: {},
3901
+ logArray
3902
+ };
3903
+ }
3904
+ current = next2;
3947
3905
  }
3906
+ await runBlock(current);
3907
+ const endBlock = current;
3908
+ const result = {};
3909
+ const definitions = endBlock.data.outputParamDefinitionArray ?? [];
3910
+ for (const def of definitions) {
3911
+ result[def.name] = outputStore[current.id]?.[def.name] ?? null;
3912
+ }
3913
+ return {
3914
+ output: result,
3915
+ logArray
3916
+ };
3917
+ } catch (error) {
3948
3918
  logArray.push({
3949
3919
  createdAt: /* @__PURE__ */ new Date(),
3950
- message: `Block ${block.type} (${block.id}) executed successfully`,
3951
- severity: "info"
3920
+ message: `Flow execution failed: ${error instanceof Error ? error.message : String(error)}`,
3921
+ severity: "error"
3952
3922
  });
3953
- return flowBranch ?? null;
3954
- };
3955
- const getNext = (fromId, branch) => {
3956
- let ce = edgeArray.find(
3957
- (e) => e.type === "control" && e.from.blockId === fromId && (e.from.output ?? null) === branch
3958
- );
3959
- if ((ce === null || ce === void 0) && branch === null) {
3960
- ce = edgeArray.find(
3961
- (e) => e.type === "control" && e.from.blockId === fromId
3962
- );
3963
- }
3964
- if (ce === null || ce === void 0) {
3965
- return null;
3966
- }
3967
- return blocksById.get(ce.to.blockId) ?? null;
3968
- };
3969
- if (flow.startNode.type.startsWith("start.") === false) {
3970
- throw new Error(
3971
- `Flow ${FlowExecuteLocallyParams.flowId} has an invalid start block that is not of type 'start.'`
3972
- );
3973
- }
3974
- let current = flow.startNode;
3975
- await runBlock(current);
3976
- const next = getNext(current.id, null);
3977
- if (next === null) {
3978
3923
  return {
3979
3924
  output: {},
3980
3925
  logArray
3981
3926
  };
3982
3927
  }
3983
- current = next;
3984
- while (current.type.startsWith("end.") === false) {
3985
- const branch = await runBlock(current);
3986
- const next2 = getNext(current.id, branch);
3987
- if (next2 === null) {
3988
- return {
3989
- output: {},
3990
- logArray
3991
- };
3992
- }
3993
- current = next2;
3994
- }
3995
- await runBlock(current);
3996
- const endBlock = current;
3997
- const result = {};
3998
- const definitions = endBlock.data.outputParamDefinitionArray ?? [];
3999
- for (const def of definitions) {
4000
- result[def.name] = outputStore[current.id]?.[def.name] ?? null;
4001
- }
4002
- return {
4003
- output: result,
4004
- logArray
4005
- };
4006
3928
  }
4007
3929
  };
4008
3930
 
package/dist/index.mjs CHANGED
@@ -3743,119 +3743,27 @@ var FlowsService = class extends Service {
3743
3743
  flowId: finalFlowId,
3744
3744
  input: execInput
3745
3745
  });
3746
- if (!response.ok) {
3747
- throw new Error(`Failed to execute flow: ${response.data?.message || "Unknown error"}`);
3746
+ if (response.ok === false) {
3747
+ throw new Error(
3748
+ `Failed to execute flow: ${response.data?.message || "Unknown error"}`
3749
+ );
3748
3750
  }
3749
3751
  return { output: response.data.output };
3750
3752
  },
3751
3753
  "end.custom": async (inputs) => {
3752
3754
  return { output: { ...inputs } };
3753
3755
  },
3754
- // Placeholder implementations for other block types (they will throw errors if used)
3755
- "start.quickAction.location": async () => {
3756
- throw new Error("Block type not implemented in executeLocally");
3757
- },
3758
- "start.session.update": async () => {
3759
- throw new Error("Block type not implemented in executeLocally");
3760
- },
3761
- "start.location.update": async () => {
3762
- throw new Error("Block type not implemented in executeLocally");
3763
- },
3764
- "start.parameter.update": async () => {
3765
- throw new Error("Block type not implemented in executeLocally");
3766
- },
3767
- "const.number": async () => {
3768
- throw new Error("Block type not implemented in executeLocally");
3769
- },
3770
- "const.text": async () => {
3771
- throw new Error("Block type not implemented in executeLocally");
3772
- },
3773
- "const.boolean": async () => {
3774
- throw new Error("Block type not implemented in executeLocally");
3775
- },
3776
- "math.add": async () => {
3777
- throw new Error("Block type not implemented in executeLocally");
3778
- },
3779
- "math.subtract": async () => {
3780
- throw new Error("Block type not implemented in executeLocally");
3781
- },
3782
- "math.multiply": async () => {
3783
- throw new Error("Block type not implemented in executeLocally");
3784
- },
3785
- "math.divide": async () => {
3786
- throw new Error("Block type not implemented in executeLocally");
3787
- },
3788
- "map.destructure": async () => {
3789
- throw new Error("Block type not implemented in executeLocally");
3790
- },
3791
- "parameter.retrieve": async () => {
3792
- throw new Error("Block type not implemented in executeLocally");
3793
- },
3794
- "property.retrieve": async () => {
3795
- throw new Error("Block type not implemented in executeLocally");
3796
- },
3797
- "location.retrieve": async () => {
3798
- throw new Error("Block type not implemented in executeLocally");
3799
- },
3800
- "session.retrieve": async () => {
3801
- throw new Error("Block type not implemented in executeLocally");
3802
- },
3803
- "device.retrieve": async () => {
3804
- throw new Error("Block type not implemented in executeLocally");
3805
- },
3806
- "user.retrieve": async () => {
3807
- throw new Error("Block type not implemented in executeLocally");
3808
- },
3809
- "user.create": async () => {
3810
- throw new Error("Block type not implemented in executeLocally");
3811
- },
3812
- "incident.retrieve": async () => {
3813
- throw new Error("Block type not implemented in executeLocally");
3814
- },
3815
- "parameter.update": async () => {
3816
- throw new Error("Block type not implemented in executeLocally");
3756
+ "const.number": async (_inputs, block) => {
3757
+ const { data } = block;
3758
+ return { output: { value: data?.value } };
3817
3759
  },
3818
- "device.update": async () => {
3819
- throw new Error("Block type not implemented in executeLocally");
3760
+ "const.text": async (_inputs, block) => {
3761
+ const { data } = block;
3762
+ return { output: { value: data?.value } };
3820
3763
  },
3821
- "location.update": async () => {
3822
- throw new Error("Block type not implemented in executeLocally");
3823
- },
3824
- "property.update": async () => {
3825
- throw new Error("Block type not implemented in executeLocally");
3826
- },
3827
- "session.terminate": async () => {
3828
- throw new Error("Block type not implemented in executeLocally");
3829
- },
3830
- "system.log": async () => {
3831
- throw new Error("Block type not implemented in executeLocally");
3832
- },
3833
- "ui.navigate.screen": async () => {
3834
- throw new Error("Block type not implemented in executeLocally");
3835
- },
3836
- "incident.create": async () => {
3837
- throw new Error("Block type not implemented in executeLocally");
3838
- },
3839
- "control.switch": async () => {
3840
- throw new Error("Block type not implemented in executeLocally");
3841
- },
3842
- "http.patch": async () => {
3843
- throw new Error("Block type not implemented in executeLocally");
3844
- },
3845
- "http.get": async () => {
3846
- throw new Error("Block type not implemented in executeLocally");
3847
- },
3848
- "http.post": async () => {
3849
- throw new Error("Block type not implemented in executeLocally");
3850
- },
3851
- "http.delete": async () => {
3852
- throw new Error("Block type not implemented in executeLocally");
3853
- },
3854
- "http.put": async () => {
3855
- throw new Error("Block type not implemented in executeLocally");
3856
- },
3857
- "mqtt.send": async () => {
3858
- throw new Error("Block type not implemented in executeLocally");
3764
+ "const.boolean": async (_inputs, block) => {
3765
+ const { data } = block;
3766
+ return { output: { value: data?.value } };
3859
3767
  }
3860
3768
  };
3861
3769
  async executeLocally(FlowExecuteLocallyParams, FlowExecuteLocallyOptions) {
@@ -3865,100 +3773,114 @@ var FlowsService = class extends Service {
3865
3773
  message: `Starting local execution of flow '${FlowExecuteLocallyParams.flowId}'`,
3866
3774
  severity: "info"
3867
3775
  });
3868
- const flowResponse = await this.retrieve({
3869
- flowId: FlowExecuteLocallyParams.flowId
3870
- });
3871
- if (!flowResponse.ok) {
3872
- throw new Error(
3873
- `Failed to retrieve flow: ${flowResponse.data?.message || "Unknown error"}`
3874
- );
3875
- }
3876
- const flow = flowResponse.data.flow;
3877
- const blocksById = new Map(
3878
- flow.nodeArray.map((b) => [b.id, b])
3879
- );
3880
- blocksById.set(flow.startNode.id, flow.startNode);
3881
- const edgeArray = flow.edgeArray;
3882
- const outputStore = {};
3883
- const runBlock = async (block) => {
3884
- logArray.push({
3885
- createdAt: /* @__PURE__ */ new Date(),
3886
- message: `Running block ${block.type} (${block.id})`,
3887
- severity: "info"
3776
+ try {
3777
+ const flowResponse = await this.retrieve({
3778
+ flowId: FlowExecuteLocallyParams.flowId
3888
3779
  });
3889
- const inputs = this.resolveInputs(block, outputStore, edgeArray);
3890
- const executor = this.blockExecutors[block.type];
3891
- if (executor === void 0 || executor === null) {
3892
- throw new Error(`No executor for ${block.type}`);
3780
+ if (!flowResponse.ok) {
3781
+ throw new Error(
3782
+ `Failed to retrieve flow: ${flowResponse.data?.message || "Unknown error"}`
3783
+ );
3893
3784
  }
3894
- const raw = await executor(
3895
- inputs,
3896
- block,
3897
- FlowExecuteLocallyParams.input ?? {}
3785
+ const flow = flowResponse.data.flow;
3786
+ const blocksById = new Map(
3787
+ flow.nodeArray.map((b) => [b.id, b])
3898
3788
  );
3899
- const { flowBranch, output } = raw;
3900
- outputStore[block.id] = output;
3901
- if (raw.logArray !== void 0) {
3902
- logArray.push(...raw.logArray);
3789
+ blocksById.set(flow.startNode.id, flow.startNode);
3790
+ const edgeArray = flow.edgeArray;
3791
+ const outputStore = {};
3792
+ const runBlock = async (block) => {
3793
+ logArray.push({
3794
+ createdAt: /* @__PURE__ */ new Date(),
3795
+ message: `Running block ${block.type} (${block.id})`,
3796
+ severity: "info"
3797
+ });
3798
+ const inputs = this.resolveInputs(block, outputStore, edgeArray);
3799
+ const executor = this.blockExecutors[block.type];
3800
+ if (executor === void 0 || executor === null) {
3801
+ throw new Error(
3802
+ `Block type '${block.type}' is not implemented in the local executor`
3803
+ );
3804
+ }
3805
+ const raw = await executor(
3806
+ inputs,
3807
+ block,
3808
+ FlowExecuteLocallyParams.input ?? {}
3809
+ );
3810
+ const { flowBranch, output } = raw;
3811
+ outputStore[block.id] = output;
3812
+ if (raw.logArray !== void 0) {
3813
+ logArray.push(...raw.logArray);
3814
+ }
3815
+ logArray.push({
3816
+ createdAt: /* @__PURE__ */ new Date(),
3817
+ message: `Block ${block.type} (${block.id}) executed successfully`,
3818
+ severity: "info"
3819
+ });
3820
+ return flowBranch ?? null;
3821
+ };
3822
+ const getNext = (fromId, branch) => {
3823
+ let ce = edgeArray.find(
3824
+ (e) => e.type === "control" && e.from.blockId === fromId && (e.from.output ?? null) === branch
3825
+ );
3826
+ if ((ce === null || ce === void 0) && branch === null) {
3827
+ ce = edgeArray.find(
3828
+ (e) => e.type === "control" && e.from.blockId === fromId
3829
+ );
3830
+ }
3831
+ if (ce === null || ce === void 0) {
3832
+ return null;
3833
+ }
3834
+ return blocksById.get(ce.to.blockId) ?? null;
3835
+ };
3836
+ if (flow.startNode.type.startsWith("start.") === false) {
3837
+ throw new Error(
3838
+ `Flow ${FlowExecuteLocallyParams.flowId} has an invalid start block that is not of type 'start.'`
3839
+ );
3840
+ }
3841
+ let current = flow.startNode;
3842
+ await runBlock(current);
3843
+ const next = getNext(current.id, null);
3844
+ if (next === null) {
3845
+ return {
3846
+ output: {},
3847
+ logArray
3848
+ };
3849
+ }
3850
+ current = next;
3851
+ while (current.type.startsWith("end.") === false) {
3852
+ const branch = await runBlock(current);
3853
+ const next2 = getNext(current.id, branch);
3854
+ if (next2 === null) {
3855
+ return {
3856
+ output: {},
3857
+ logArray
3858
+ };
3859
+ }
3860
+ current = next2;
3903
3861
  }
3862
+ await runBlock(current);
3863
+ const endBlock = current;
3864
+ const result = {};
3865
+ const definitions = endBlock.data.outputParamDefinitionArray ?? [];
3866
+ for (const def of definitions) {
3867
+ result[def.name] = outputStore[current.id]?.[def.name] ?? null;
3868
+ }
3869
+ return {
3870
+ output: result,
3871
+ logArray
3872
+ };
3873
+ } catch (error) {
3904
3874
  logArray.push({
3905
3875
  createdAt: /* @__PURE__ */ new Date(),
3906
- message: `Block ${block.type} (${block.id}) executed successfully`,
3907
- severity: "info"
3876
+ message: `Flow execution failed: ${error instanceof Error ? error.message : String(error)}`,
3877
+ severity: "error"
3908
3878
  });
3909
- return flowBranch ?? null;
3910
- };
3911
- const getNext = (fromId, branch) => {
3912
- let ce = edgeArray.find(
3913
- (e) => e.type === "control" && e.from.blockId === fromId && (e.from.output ?? null) === branch
3914
- );
3915
- if ((ce === null || ce === void 0) && branch === null) {
3916
- ce = edgeArray.find(
3917
- (e) => e.type === "control" && e.from.blockId === fromId
3918
- );
3919
- }
3920
- if (ce === null || ce === void 0) {
3921
- return null;
3922
- }
3923
- return blocksById.get(ce.to.blockId) ?? null;
3924
- };
3925
- if (flow.startNode.type.startsWith("start.") === false) {
3926
- throw new Error(
3927
- `Flow ${FlowExecuteLocallyParams.flowId} has an invalid start block that is not of type 'start.'`
3928
- );
3929
- }
3930
- let current = flow.startNode;
3931
- await runBlock(current);
3932
- const next = getNext(current.id, null);
3933
- if (next === null) {
3934
3879
  return {
3935
3880
  output: {},
3936
3881
  logArray
3937
3882
  };
3938
3883
  }
3939
- current = next;
3940
- while (current.type.startsWith("end.") === false) {
3941
- const branch = await runBlock(current);
3942
- const next2 = getNext(current.id, branch);
3943
- if (next2 === null) {
3944
- return {
3945
- output: {},
3946
- logArray
3947
- };
3948
- }
3949
- current = next2;
3950
- }
3951
- await runBlock(current);
3952
- const endBlock = current;
3953
- const result = {};
3954
- const definitions = endBlock.data.outputParamDefinitionArray ?? [];
3955
- for (const def of definitions) {
3956
- result[def.name] = outputStore[current.id]?.[def.name] ?? null;
3957
- }
3958
- return {
3959
- output: result,
3960
- logArray
3961
- };
3962
3884
  }
3963
3885
  };
3964
3886
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juhuu/sdk-ts",
3
- "version": "1.2.273",
3
+ "version": "1.2.274",
4
4
  "description": "Typescript wrapper for JUHUU services",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",