@juhuu/sdk-ts 1.2.273 → 1.2.275

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
@@ -1297,6 +1297,11 @@ type FlowLog = {
1297
1297
  message: string;
1298
1298
  createdAt: Date;
1299
1299
  };
1300
+ type BlockExecutor = (inputs: FlowBlockInput, block: FlowBlock, context: Record<string, any>) => Promise<{
1301
+ output: Record<string, any>;
1302
+ logArray?: FlowLog[];
1303
+ flowBranch?: string | null;
1304
+ }>;
1300
1305
  type DataEdgeConnection = string | null;
1301
1306
  type ControlEdgeConnection = string | null;
1302
1307
  type QuickAction = {
@@ -1708,10 +1713,7 @@ declare class FlowsService extends Service {
1708
1713
  private resolveInputs;
1709
1714
  private isInputConnected;
1710
1715
  private blockExecutors;
1711
- executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.Execute.Options): Promise<{
1712
- output: Record<string, any>;
1713
- logArray: FlowLog[];
1714
- }>;
1716
+ executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.ExecuteLocally.Options): Promise<JUHUU.Flow.ExecuteLocally.Response>;
1715
1717
  }
1716
1718
 
1717
1719
  declare class FlowTracesService extends Service {
@@ -4851,7 +4853,9 @@ declare namespace JUHUU {
4851
4853
  flowId: string;
4852
4854
  input?: Record<string, any>;
4853
4855
  };
4854
- type Options = JUHUU.RequestOptions;
4856
+ type Options = JUHUU.RequestOptions & {
4857
+ blockExecutors?: Partial<Record<FlowBlock["type"], BlockExecutor>>;
4858
+ };
4855
4859
  type Response = {
4856
4860
  output: Record<string, any>;
4857
4861
  logArray: FlowLog[];
@@ -6511,4 +6515,4 @@ declare namespace JUHUU {
6511
6515
  }
6512
6516
  }
6513
6517
 
6514
- export { type AccessControlListElement, type Address, type ApiKeyScope, type ApiKeyStatus, type AutoRenewMode, type BaseBlock, type BusinessType, type Capability, type Category, type Circumstance, type Color, type ColorScheme, type Command, type Condition, ConditionType, type ConstBooleanBlock, type ConstNumberBlock, type ConstTextBlock, type ControlEdgeConnection, type CountryCode, CountryCodeArray, type CurrencyCode, CurrencyCodeArray, type CustomClaims, type DataEdgeConnection, type DeepNullable, type DevicePermission, type DeviceRetrieveBlock, type DeviceRetrieveBlockInputs, type DeviceStatus, type DeviceType, type DeviceUpdateBlock, type DeviceUpdateBlockInputs, type EndCustomBlock, type Environment, type EnvironmentSettings, type ExtractType, type FlowBlock, type FlowBlockInput, type FlowControlEdge, type FlowDataEdge, type FlowEdge, type FlowExecuteBlock, type FlowExecuteBlockInputs, type FlowExecutionEnvironment, type FlowLog, type FlowStatus, type Frontend, type GeneralSettings, type GeoPoint, type GraphNode, type HttpDeleteBlock, type HttpDeleteBlockInputs, type HttpGetBlock, type HttpGetBlockInputs, type HttpPatchBlock, type HttpPostBlock, type HttpPostBlockInputs, type HttpPutBlock, type HttpPutBlockInputs, type HttpsPatchBlockInputs, type IfBlock, type IncidentCreateBlock, type IncidentCreateBlockInputs, type IncidentRetrieveBlock, type IncidentRetrieveBlockInputs, JUHUU, type JsonLogic, Juhuu, type LanguageCode, LanguageCodeArray, Layout, type LayoutBlock, type License, type LicenseTariffIdMap, type LinkType, type LocalParameter, type LocaleString, type LocationRetrieveBlock, type LocationRetrieveBlockInputs, type LocationUpdateBlock, type LocationUpdateBlockInputs, type MapDestructureBlock, type MapDestructureBlockInputs, type MapFilter, type MathAddBlock, type MathAddBlockInputs, type MathDivideBlock, type MathDivideBlockInputs, type MathMultiplyBlock, type MathMultiplyBlockInputs, type MathSubtractBlock, type MathSubtractBlockInputs, type Modality, type MqttSendBlock, type MqttSendBlockInputs, Offer, type OfferTime, type PanelDisplay, type ParamDefinition, type ParamType, type ParameterRetrieveBlock, type ParameterRetrieveBlockInputs, type ParameterUpdateBlock, type ParameterUpdateBlockInputs, type Party, type PaymentMethod, type PaymentReason, type PaymentRefundReason, type PaymentRefundStatus, type PaymentServiceProvider, type PaymentStatus, type PayoutSettings, type PayoutStatus, type PermissionTypes, type Person, type Platform, type PlatformString, type PostingRow, type PropertyRetrieveBlock, type PropertyRetrieveBlockInputs, type PropertyUpdateBlock, type PropertyUpdateBlockInputs, type ProximityStrategy, type Purpose, type PushToken, type QuickAction, type QuickView, ReadonlyCategoryArray, ReadonlyModalityArray, ReadonlySectorArray, type RefundStatus, type Sector, type SessionCannotTerminateReason, type SessionRetrieveBlock, type SessionRetrieveBlockInputs, type SessionSettings, type SessionStatus, type SessionTerminateBlock, type SessionTerminateBlockInputs, type SessionTerminatedByType, type SessionType, Settings, type SimStatus, type StarRating, type StartCustomBlock, type StartLocationUpdateBlock, type StartParameterUpdateBlock, type StartQuickActionLocationBlock, type StartSessionUpdateBlock, type SwitchBlock, type SystemLogBlock, type SystemLogBlockInputs, type TarifType, type TaxCode, type TimeZone, type UiNavigateScreenBlock, type UiNavigateScreenBlockInputs, type Unit, type UserCreateBlock, type UserCreateBlockInputs, type UserGroup, type UserRetrieveBlock, type UserRetrieveBlockInputs, type UserType, type Utilization, type VeloBrushDeviceDocumentUserManualStep, type Viewport, type ViewportPolygon, type VisualPriority, type hexColor };
6518
+ export { type AccessControlListElement, type Address, type ApiKeyScope, type ApiKeyStatus, type AutoRenewMode, type BaseBlock, type BlockExecutor, type BusinessType, type Capability, type Category, type Circumstance, type Color, type ColorScheme, type Command, type Condition, ConditionType, type ConstBooleanBlock, type ConstNumberBlock, type ConstTextBlock, type ControlEdgeConnection, type CountryCode, CountryCodeArray, type CurrencyCode, CurrencyCodeArray, type CustomClaims, type DataEdgeConnection, type DeepNullable, type DevicePermission, type DeviceRetrieveBlock, type DeviceRetrieveBlockInputs, type DeviceStatus, type DeviceType, type DeviceUpdateBlock, type DeviceUpdateBlockInputs, type EndCustomBlock, type Environment, type EnvironmentSettings, type ExtractType, type FlowBlock, type FlowBlockInput, type FlowControlEdge, type FlowDataEdge, type FlowEdge, type FlowExecuteBlock, type FlowExecuteBlockInputs, type FlowExecutionEnvironment, type FlowLog, type FlowStatus, type Frontend, type GeneralSettings, type GeoPoint, type GraphNode, type HttpDeleteBlock, type HttpDeleteBlockInputs, type HttpGetBlock, type HttpGetBlockInputs, type HttpPatchBlock, type HttpPostBlock, type HttpPostBlockInputs, type HttpPutBlock, type HttpPutBlockInputs, type HttpsPatchBlockInputs, type IfBlock, type IncidentCreateBlock, type IncidentCreateBlockInputs, type IncidentRetrieveBlock, type IncidentRetrieveBlockInputs, JUHUU, type JsonLogic, Juhuu, type LanguageCode, LanguageCodeArray, Layout, type LayoutBlock, type License, type LicenseTariffIdMap, type LinkType, type LocalParameter, type LocaleString, type LocationRetrieveBlock, type LocationRetrieveBlockInputs, type LocationUpdateBlock, type LocationUpdateBlockInputs, type MapDestructureBlock, type MapDestructureBlockInputs, type MapFilter, type MathAddBlock, type MathAddBlockInputs, type MathDivideBlock, type MathDivideBlockInputs, type MathMultiplyBlock, type MathMultiplyBlockInputs, type MathSubtractBlock, type MathSubtractBlockInputs, type Modality, type MqttSendBlock, type MqttSendBlockInputs, Offer, type OfferTime, type PanelDisplay, type ParamDefinition, type ParamType, type ParameterRetrieveBlock, type ParameterRetrieveBlockInputs, type ParameterUpdateBlock, type ParameterUpdateBlockInputs, type Party, type PaymentMethod, type PaymentReason, type PaymentRefundReason, type PaymentRefundStatus, type PaymentServiceProvider, type PaymentStatus, type PayoutSettings, type PayoutStatus, type PermissionTypes, type Person, type Platform, type PlatformString, type PostingRow, type PropertyRetrieveBlock, type PropertyRetrieveBlockInputs, type PropertyUpdateBlock, type PropertyUpdateBlockInputs, type ProximityStrategy, type Purpose, type PushToken, type QuickAction, type QuickView, ReadonlyCategoryArray, ReadonlyModalityArray, ReadonlySectorArray, type RefundStatus, type Sector, type SessionCannotTerminateReason, type SessionRetrieveBlock, type SessionRetrieveBlockInputs, type SessionSettings, type SessionStatus, type SessionTerminateBlock, type SessionTerminateBlockInputs, type SessionTerminatedByType, type SessionType, Settings, type SimStatus, type StarRating, type StartCustomBlock, type StartLocationUpdateBlock, type StartParameterUpdateBlock, type StartQuickActionLocationBlock, type StartSessionUpdateBlock, type SwitchBlock, type SystemLogBlock, type SystemLogBlockInputs, type TarifType, type TaxCode, type TimeZone, type UiNavigateScreenBlock, type UiNavigateScreenBlockInputs, type Unit, type UserCreateBlock, type UserCreateBlockInputs, type UserGroup, type UserRetrieveBlock, type UserRetrieveBlockInputs, type UserType, type Utilization, type VeloBrushDeviceDocumentUserManualStep, type Viewport, type ViewportPolygon, type VisualPriority, type hexColor };
package/dist/index.d.ts CHANGED
@@ -1297,6 +1297,11 @@ type FlowLog = {
1297
1297
  message: string;
1298
1298
  createdAt: Date;
1299
1299
  };
1300
+ type BlockExecutor = (inputs: FlowBlockInput, block: FlowBlock, context: Record<string, any>) => Promise<{
1301
+ output: Record<string, any>;
1302
+ logArray?: FlowLog[];
1303
+ flowBranch?: string | null;
1304
+ }>;
1300
1305
  type DataEdgeConnection = string | null;
1301
1306
  type ControlEdgeConnection = string | null;
1302
1307
  type QuickAction = {
@@ -1708,10 +1713,7 @@ declare class FlowsService extends Service {
1708
1713
  private resolveInputs;
1709
1714
  private isInputConnected;
1710
1715
  private blockExecutors;
1711
- executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.Execute.Options): Promise<{
1712
- output: Record<string, any>;
1713
- logArray: FlowLog[];
1714
- }>;
1716
+ executeLocally(FlowExecuteLocallyParams: JUHUU.Flow.ExecuteLocally.Params, FlowExecuteLocallyOptions?: JUHUU.Flow.ExecuteLocally.Options): Promise<JUHUU.Flow.ExecuteLocally.Response>;
1715
1717
  }
1716
1718
 
1717
1719
  declare class FlowTracesService extends Service {
@@ -4851,7 +4853,9 @@ declare namespace JUHUU {
4851
4853
  flowId: string;
4852
4854
  input?: Record<string, any>;
4853
4855
  };
4854
- type Options = JUHUU.RequestOptions;
4856
+ type Options = JUHUU.RequestOptions & {
4857
+ blockExecutors?: Partial<Record<FlowBlock["type"], BlockExecutor>>;
4858
+ };
4855
4859
  type Response = {
4856
4860
  output: Record<string, any>;
4857
4861
  logArray: FlowLog[];
@@ -6511,4 +6515,4 @@ declare namespace JUHUU {
6511
6515
  }
6512
6516
  }
6513
6517
 
6514
- export { type AccessControlListElement, type Address, type ApiKeyScope, type ApiKeyStatus, type AutoRenewMode, type BaseBlock, type BusinessType, type Capability, type Category, type Circumstance, type Color, type ColorScheme, type Command, type Condition, ConditionType, type ConstBooleanBlock, type ConstNumberBlock, type ConstTextBlock, type ControlEdgeConnection, type CountryCode, CountryCodeArray, type CurrencyCode, CurrencyCodeArray, type CustomClaims, type DataEdgeConnection, type DeepNullable, type DevicePermission, type DeviceRetrieveBlock, type DeviceRetrieveBlockInputs, type DeviceStatus, type DeviceType, type DeviceUpdateBlock, type DeviceUpdateBlockInputs, type EndCustomBlock, type Environment, type EnvironmentSettings, type ExtractType, type FlowBlock, type FlowBlockInput, type FlowControlEdge, type FlowDataEdge, type FlowEdge, type FlowExecuteBlock, type FlowExecuteBlockInputs, type FlowExecutionEnvironment, type FlowLog, type FlowStatus, type Frontend, type GeneralSettings, type GeoPoint, type GraphNode, type HttpDeleteBlock, type HttpDeleteBlockInputs, type HttpGetBlock, type HttpGetBlockInputs, type HttpPatchBlock, type HttpPostBlock, type HttpPostBlockInputs, type HttpPutBlock, type HttpPutBlockInputs, type HttpsPatchBlockInputs, type IfBlock, type IncidentCreateBlock, type IncidentCreateBlockInputs, type IncidentRetrieveBlock, type IncidentRetrieveBlockInputs, JUHUU, type JsonLogic, Juhuu, type LanguageCode, LanguageCodeArray, Layout, type LayoutBlock, type License, type LicenseTariffIdMap, type LinkType, type LocalParameter, type LocaleString, type LocationRetrieveBlock, type LocationRetrieveBlockInputs, type LocationUpdateBlock, type LocationUpdateBlockInputs, type MapDestructureBlock, type MapDestructureBlockInputs, type MapFilter, type MathAddBlock, type MathAddBlockInputs, type MathDivideBlock, type MathDivideBlockInputs, type MathMultiplyBlock, type MathMultiplyBlockInputs, type MathSubtractBlock, type MathSubtractBlockInputs, type Modality, type MqttSendBlock, type MqttSendBlockInputs, Offer, type OfferTime, type PanelDisplay, type ParamDefinition, type ParamType, type ParameterRetrieveBlock, type ParameterRetrieveBlockInputs, type ParameterUpdateBlock, type ParameterUpdateBlockInputs, type Party, type PaymentMethod, type PaymentReason, type PaymentRefundReason, type PaymentRefundStatus, type PaymentServiceProvider, type PaymentStatus, type PayoutSettings, type PayoutStatus, type PermissionTypes, type Person, type Platform, type PlatformString, type PostingRow, type PropertyRetrieveBlock, type PropertyRetrieveBlockInputs, type PropertyUpdateBlock, type PropertyUpdateBlockInputs, type ProximityStrategy, type Purpose, type PushToken, type QuickAction, type QuickView, ReadonlyCategoryArray, ReadonlyModalityArray, ReadonlySectorArray, type RefundStatus, type Sector, type SessionCannotTerminateReason, type SessionRetrieveBlock, type SessionRetrieveBlockInputs, type SessionSettings, type SessionStatus, type SessionTerminateBlock, type SessionTerminateBlockInputs, type SessionTerminatedByType, type SessionType, Settings, type SimStatus, type StarRating, type StartCustomBlock, type StartLocationUpdateBlock, type StartParameterUpdateBlock, type StartQuickActionLocationBlock, type StartSessionUpdateBlock, type SwitchBlock, type SystemLogBlock, type SystemLogBlockInputs, type TarifType, type TaxCode, type TimeZone, type UiNavigateScreenBlock, type UiNavigateScreenBlockInputs, type Unit, type UserCreateBlock, type UserCreateBlockInputs, type UserGroup, type UserRetrieveBlock, type UserRetrieveBlockInputs, type UserType, type Utilization, type VeloBrushDeviceDocumentUserManualStep, type Viewport, type ViewportPolygon, type VisualPriority, type hexColor };
6518
+ export { type AccessControlListElement, type Address, type ApiKeyScope, type ApiKeyStatus, type AutoRenewMode, type BaseBlock, type BlockExecutor, type BusinessType, type Capability, type Category, type Circumstance, type Color, type ColorScheme, type Command, type Condition, ConditionType, type ConstBooleanBlock, type ConstNumberBlock, type ConstTextBlock, type ControlEdgeConnection, type CountryCode, CountryCodeArray, type CurrencyCode, CurrencyCodeArray, type CustomClaims, type DataEdgeConnection, type DeepNullable, type DevicePermission, type DeviceRetrieveBlock, type DeviceRetrieveBlockInputs, type DeviceStatus, type DeviceType, type DeviceUpdateBlock, type DeviceUpdateBlockInputs, type EndCustomBlock, type Environment, type EnvironmentSettings, type ExtractType, type FlowBlock, type FlowBlockInput, type FlowControlEdge, type FlowDataEdge, type FlowEdge, type FlowExecuteBlock, type FlowExecuteBlockInputs, type FlowExecutionEnvironment, type FlowLog, type FlowStatus, type Frontend, type GeneralSettings, type GeoPoint, type GraphNode, type HttpDeleteBlock, type HttpDeleteBlockInputs, type HttpGetBlock, type HttpGetBlockInputs, type HttpPatchBlock, type HttpPostBlock, type HttpPostBlockInputs, type HttpPutBlock, type HttpPutBlockInputs, type HttpsPatchBlockInputs, type IfBlock, type IncidentCreateBlock, type IncidentCreateBlockInputs, type IncidentRetrieveBlock, type IncidentRetrieveBlockInputs, JUHUU, type JsonLogic, Juhuu, type LanguageCode, LanguageCodeArray, Layout, type LayoutBlock, type License, type LicenseTariffIdMap, type LinkType, type LocalParameter, type LocaleString, type LocationRetrieveBlock, type LocationRetrieveBlockInputs, type LocationUpdateBlock, type LocationUpdateBlockInputs, type MapDestructureBlock, type MapDestructureBlockInputs, type MapFilter, type MathAddBlock, type MathAddBlockInputs, type MathDivideBlock, type MathDivideBlockInputs, type MathMultiplyBlock, type MathMultiplyBlockInputs, type MathSubtractBlock, type MathSubtractBlockInputs, type Modality, type MqttSendBlock, type MqttSendBlockInputs, Offer, type OfferTime, type PanelDisplay, type ParamDefinition, type ParamType, type ParameterRetrieveBlock, type ParameterRetrieveBlockInputs, type ParameterUpdateBlock, type ParameterUpdateBlockInputs, type Party, type PaymentMethod, type PaymentReason, type PaymentRefundReason, type PaymentRefundStatus, type PaymentServiceProvider, type PaymentStatus, type PayoutSettings, type PayoutStatus, type PermissionTypes, type Person, type Platform, type PlatformString, type PostingRow, type PropertyRetrieveBlock, type PropertyRetrieveBlockInputs, type PropertyUpdateBlock, type PropertyUpdateBlockInputs, type ProximityStrategy, type Purpose, type PushToken, type QuickAction, type QuickView, ReadonlyCategoryArray, ReadonlyModalityArray, ReadonlySectorArray, type RefundStatus, type Sector, type SessionCannotTerminateReason, type SessionRetrieveBlock, type SessionRetrieveBlockInputs, type SessionSettings, type SessionStatus, type SessionTerminateBlock, type SessionTerminateBlockInputs, type SessionTerminatedByType, type SessionType, Settings, type SimStatus, type StarRating, type StartCustomBlock, type StartLocationUpdateBlock, type StartParameterUpdateBlock, type StartQuickActionLocationBlock, type StartSessionUpdateBlock, type SwitchBlock, type SystemLogBlock, type SystemLogBlockInputs, type TarifType, type TaxCode, type TimeZone, type UiNavigateScreenBlock, type UiNavigateScreenBlockInputs, type Unit, type UserCreateBlock, type UserCreateBlockInputs, type UserGroup, type UserRetrieveBlock, type UserRetrieveBlockInputs, type UserType, type Utilization, type VeloBrushDeviceDocumentUserManualStep, type Viewport, type ViewportPolygon, type VisualPriority, type hexColor };
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,118 @@ 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 mergedBlockExecutors = {
3837
+ ...this.blockExecutors,
3838
+ ...FlowExecuteLocallyOptions?.blockExecutors || {}
3839
+ };
3840
+ const runBlock = async (block) => {
3841
+ logArray.push({
3842
+ createdAt: /* @__PURE__ */ new Date(),
3843
+ message: `Running block ${block.type} (${block.id})`,
3844
+ severity: "info"
3845
+ });
3846
+ const inputs = this.resolveInputs(block, outputStore, edgeArray);
3847
+ const executor = mergedBlockExecutors[block.type];
3848
+ if (executor === void 0 || executor === null) {
3849
+ throw new Error(
3850
+ `Block type '${block.type}' is not implemented in the local executor`
3851
+ );
3852
+ }
3853
+ const raw = await executor(
3854
+ inputs,
3855
+ block,
3856
+ FlowExecuteLocallyParams.input ?? {}
3857
+ );
3858
+ const { flowBranch, output } = raw;
3859
+ outputStore[block.id] = output;
3860
+ if (raw.logArray !== void 0) {
3861
+ logArray.push(...raw.logArray);
3862
+ }
3863
+ logArray.push({
3864
+ createdAt: /* @__PURE__ */ new Date(),
3865
+ message: `Block ${block.type} (${block.id}) executed successfully`,
3866
+ severity: "info"
3867
+ });
3868
+ return flowBranch ?? null;
3869
+ };
3870
+ const getNext = (fromId, branch) => {
3871
+ let ce = edgeArray.find(
3872
+ (e) => e.type === "control" && e.from.blockId === fromId && (e.from.output ?? null) === branch
3873
+ );
3874
+ if ((ce === null || ce === void 0) && branch === null) {
3875
+ ce = edgeArray.find(
3876
+ (e) => e.type === "control" && e.from.blockId === fromId
3877
+ );
3878
+ }
3879
+ if (ce === null || ce === void 0) {
3880
+ return null;
3881
+ }
3882
+ return blocksById.get(ce.to.blockId) ?? null;
3883
+ };
3884
+ if (flow.startNode.type.startsWith("start.") === false) {
3885
+ throw new Error(
3886
+ `Flow ${FlowExecuteLocallyParams.flowId} has an invalid start block that is not of type 'start.'`
3887
+ );
3888
+ }
3889
+ let current = flow.startNode;
3890
+ await runBlock(current);
3891
+ const next = getNext(current.id, null);
3892
+ if (next === null) {
3893
+ return {
3894
+ output: {},
3895
+ logArray
3896
+ };
3897
+ }
3898
+ current = next;
3899
+ while (current.type.startsWith("end.") === false) {
3900
+ const branch = await runBlock(current);
3901
+ const next2 = getNext(current.id, branch);
3902
+ if (next2 === null) {
3903
+ return {
3904
+ output: {},
3905
+ logArray
3906
+ };
3907
+ }
3908
+ current = next2;
3947
3909
  }
3910
+ await runBlock(current);
3911
+ const endBlock = current;
3912
+ const result = {};
3913
+ const definitions = endBlock.data.outputParamDefinitionArray ?? [];
3914
+ for (const def of definitions) {
3915
+ result[def.name] = outputStore[current.id]?.[def.name] ?? null;
3916
+ }
3917
+ return {
3918
+ output: result,
3919
+ logArray
3920
+ };
3921
+ } catch (error) {
3948
3922
  logArray.push({
3949
3923
  createdAt: /* @__PURE__ */ new Date(),
3950
- message: `Block ${block.type} (${block.id}) executed successfully`,
3951
- severity: "info"
3924
+ message: `Flow execution failed: ${error instanceof Error ? error.message : String(error)}`,
3925
+ severity: "error"
3952
3926
  });
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
3927
  return {
3979
3928
  output: {},
3980
3929
  logArray
3981
3930
  };
3982
3931
  }
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
3932
  }
4007
3933
  };
4008
3934
 
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,118 @@ 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 mergedBlockExecutors = {
3793
+ ...this.blockExecutors,
3794
+ ...FlowExecuteLocallyOptions?.blockExecutors || {}
3795
+ };
3796
+ const runBlock = async (block) => {
3797
+ logArray.push({
3798
+ createdAt: /* @__PURE__ */ new Date(),
3799
+ message: `Running block ${block.type} (${block.id})`,
3800
+ severity: "info"
3801
+ });
3802
+ const inputs = this.resolveInputs(block, outputStore, edgeArray);
3803
+ const executor = mergedBlockExecutors[block.type];
3804
+ if (executor === void 0 || executor === null) {
3805
+ throw new Error(
3806
+ `Block type '${block.type}' is not implemented in the local executor`
3807
+ );
3808
+ }
3809
+ const raw = await executor(
3810
+ inputs,
3811
+ block,
3812
+ FlowExecuteLocallyParams.input ?? {}
3813
+ );
3814
+ const { flowBranch, output } = raw;
3815
+ outputStore[block.id] = output;
3816
+ if (raw.logArray !== void 0) {
3817
+ logArray.push(...raw.logArray);
3818
+ }
3819
+ logArray.push({
3820
+ createdAt: /* @__PURE__ */ new Date(),
3821
+ message: `Block ${block.type} (${block.id}) executed successfully`,
3822
+ severity: "info"
3823
+ });
3824
+ return flowBranch ?? null;
3825
+ };
3826
+ const getNext = (fromId, branch) => {
3827
+ let ce = edgeArray.find(
3828
+ (e) => e.type === "control" && e.from.blockId === fromId && (e.from.output ?? null) === branch
3829
+ );
3830
+ if ((ce === null || ce === void 0) && branch === null) {
3831
+ ce = edgeArray.find(
3832
+ (e) => e.type === "control" && e.from.blockId === fromId
3833
+ );
3834
+ }
3835
+ if (ce === null || ce === void 0) {
3836
+ return null;
3837
+ }
3838
+ return blocksById.get(ce.to.blockId) ?? null;
3839
+ };
3840
+ if (flow.startNode.type.startsWith("start.") === false) {
3841
+ throw new Error(
3842
+ `Flow ${FlowExecuteLocallyParams.flowId} has an invalid start block that is not of type 'start.'`
3843
+ );
3844
+ }
3845
+ let current = flow.startNode;
3846
+ await runBlock(current);
3847
+ const next = getNext(current.id, null);
3848
+ if (next === null) {
3849
+ return {
3850
+ output: {},
3851
+ logArray
3852
+ };
3853
+ }
3854
+ current = next;
3855
+ while (current.type.startsWith("end.") === false) {
3856
+ const branch = await runBlock(current);
3857
+ const next2 = getNext(current.id, branch);
3858
+ if (next2 === null) {
3859
+ return {
3860
+ output: {},
3861
+ logArray
3862
+ };
3863
+ }
3864
+ current = next2;
3903
3865
  }
3866
+ await runBlock(current);
3867
+ const endBlock = current;
3868
+ const result = {};
3869
+ const definitions = endBlock.data.outputParamDefinitionArray ?? [];
3870
+ for (const def of definitions) {
3871
+ result[def.name] = outputStore[current.id]?.[def.name] ?? null;
3872
+ }
3873
+ return {
3874
+ output: result,
3875
+ logArray
3876
+ };
3877
+ } catch (error) {
3904
3878
  logArray.push({
3905
3879
  createdAt: /* @__PURE__ */ new Date(),
3906
- message: `Block ${block.type} (${block.id}) executed successfully`,
3907
- severity: "info"
3880
+ message: `Flow execution failed: ${error instanceof Error ? error.message : String(error)}`,
3881
+ severity: "error"
3908
3882
  });
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
3883
  return {
3935
3884
  output: {},
3936
3885
  logArray
3937
3886
  };
3938
3887
  }
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
3888
  }
3963
3889
  };
3964
3890
 
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.275",
4
4
  "description": "Typescript wrapper for JUHUU services",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",