From 430e365490b427f0746956578e2e5f10942496e7 Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 15:58:03 +0530 Subject: [PATCH 01/10] refactor: remove unused routing types --- .../priority-logics/PriorityLogicUtils.res | 7 --- .../HyperSwitch/Routing/HistoryEntity.res | 26 ++++++-- .../HyperSwitch/Routing/PriorityRouting.res | 1 - .../HyperSwitch/Routing/RoutingTypes.res | 60 +++++++------------ 4 files changed, 43 insertions(+), 51 deletions(-) delete mode 100644 src/components/priority-logics/PriorityLogicUtils.res diff --git a/src/components/priority-logics/PriorityLogicUtils.res b/src/components/priority-logics/PriorityLogicUtils.res deleted file mode 100644 index e516b8d6c..000000000 --- a/src/components/priority-logics/PriorityLogicUtils.res +++ /dev/null @@ -1,7 +0,0 @@ -type gateway = { - gateway_name: string, - distribution: int, - disableFallback: bool, -} - -type formState = CreateConfig | EditConfig | ViewConfig diff --git a/src/screens/HyperSwitch/Routing/HistoryEntity.res b/src/screens/HyperSwitch/Routing/HistoryEntity.res index e90fb16d2..47ecffdd9 100644 --- a/src/screens/HyperSwitch/Routing/HistoryEntity.res +++ b/src/screens/HyperSwitch/Routing/HistoryEntity.res @@ -2,7 +2,17 @@ open LogicUtils open RoutingUtils open RoutingTypes -let allColumns = [Name, Type, ProfileId, ProfileName, Description, Created, LastUpdated, Status] +let allColumns: array = [ + Name, + Type, + ProfileId, + ProfileName, + Description, + Created, + LastUpdated, + Status, +] + let itemToObjMapper = dict => { { id: getString(dict, "id", ""), @@ -14,9 +24,17 @@ let itemToObjMapper = dict => { created_at: getString(dict, "created_at", ""), } } -let defaultColumns = [Name, ProfileId, ProfileName, Type, Description, Status] -let getHeading = colType => { +let defaultColumns: array = [ + Name, + ProfileId, + ProfileName, + Type, + Description, + Status, +] + +let getHeading: historyColType => Table.header = colType => { switch colType { | Name => Table.makeHeaderInfo(~key="name", ~title="Name of Control", ~showSort=true, ()) | Type => Table.makeHeaderInfo(~key="kind", ~title="Type of Control", ~showSort=true, ()) @@ -32,7 +50,7 @@ let getHeading = colType => { } } let getTableCell = activeRoutingIds => { - let getCell = (historyData, colType): Table.cell => { + let getCell = (historyData, colType: historyColType): Table.cell => { switch colType { | Name => Text(historyData.name) | Type => diff --git a/src/screens/HyperSwitch/Routing/PriorityRouting.res b/src/screens/HyperSwitch/Routing/PriorityRouting.res index 20592a4a4..7533a3f18 100644 --- a/src/screens/HyperSwitch/Routing/PriorityRouting.res +++ b/src/screens/HyperSwitch/Routing/PriorityRouting.res @@ -1,7 +1,6 @@ open RoutingUtils open APIUtils open RoutingTypes -open PriorityLogicUtils open RoutingPreviewer module SimpleRoutingView = { @react.component diff --git a/src/screens/HyperSwitch/Routing/RoutingTypes.res b/src/screens/HyperSwitch/Routing/RoutingTypes.res index bd0b6c90d..8f2de9636 100644 --- a/src/screens/HyperSwitch/Routing/RoutingTypes.res +++ b/src/screens/HyperSwitch/Routing/RoutingTypes.res @@ -1,7 +1,18 @@ type routingType = SINGLE | PRIORITY | VOLUME_SPLIT | ADVANCED | COST | DEFAULTFALLBACK | NO_ROUTING -type modalValue = {conType: string, conText: React.element} -type routingValueType = {heading: string, subHeading: string} -type modalObj = (routingType, string) => modalValue +type formState = CreateConfig | EditConfig | ViewConfig +type status = ACTIVE | APPROVED | PENDING | REJECTED +type pageState = Preview | Create | Edit + +type historyColType = + | Name + | Type + | ProfileId + | ProfileName + | Description + | Created + | LastUpdated + | Status + type colType = | Name | Description @@ -10,8 +21,6 @@ type colType = | DateCreated | LastUpdated -type status = ACTIVE | APPROVED | PENDING | REJECTED -type configType = RuleBased | CodeBased type operator = | IS | IS_NOT @@ -22,28 +31,15 @@ type operator = | NOT_CONTAINS | NOT_EQUAL_TO | UnknownOperator(string) + type variantType = Number | Enum_variant | Metadata_value | String_value | UnknownVariant(string) type logicalOperator = AND | OR | UnknownLogicalOperator(string) type val = StringArray(array) | String(string) | Int(int) -type logic = { - id: string, - name: string, - description: string, - isActiveLogic: bool, - status: status, - configType: configType, - version: string, - priorityLogic: string, - priorityLogicRules: string, - dateCreated: string, - lastUpdated: string, -} -type response = { - useCode: bool, - gatewayPriority: string, - gatewayPriorityLogic: string, - logics: array, -} + +type modalValue = {conType: string, conText: React.element} +type routingValueType = {heading: string, subHeading: string} +type modalObj = (routingType, string) => modalValue + type wasmModule = { getAllKeys: unit => array, getKeyType: string => string, @@ -59,7 +55,7 @@ type volumeDistribution = { connector: string, split: int, } -type pageState = Preview | Create | Edit + type condition = { field: string, metadata?: Js.Json.t, @@ -78,20 +74,6 @@ type ruleInfoType = { default_gateways: array, } -type gateWAY = {gateways: array} -type volumeDistributionType = {volumeBasedDistribution: gateWAY} -type ruleDict = {json: volumeDistributionType} - -type historyColType = - | Name - | Type - | ProfileId - | ProfileName - | Description - | Created - | LastUpdated - | Status - type historyData = { id: string, name: string, From 354452de059d72be261306bdb9efc708aa06779c Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:04:53 +0530 Subject: [PATCH 02/10] refactor: cleanup routing typs --- src/screens/HyperSwitch/Routing/RoutingTypes.res | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingTypes.res b/src/screens/HyperSwitch/Routing/RoutingTypes.res index 8f2de9636..4852ee162 100644 --- a/src/screens/HyperSwitch/Routing/RoutingTypes.res +++ b/src/screens/HyperSwitch/Routing/RoutingTypes.res @@ -2,6 +2,9 @@ type routingType = SINGLE | PRIORITY | VOLUME_SPLIT | ADVANCED | COST | DEFAULTF type formState = CreateConfig | EditConfig | ViewConfig type status = ACTIVE | APPROVED | PENDING | REJECTED type pageState = Preview | Create | Edit +type variantType = Number | Enum_variant | Metadata_value | String_value | UnknownVariant(string) +type logicalOperator = AND | OR | UnknownLogicalOperator(string) +type val = StringArray(array) | String(string) | Int(int) type historyColType = | Name @@ -32,10 +35,6 @@ type operator = | NOT_EQUAL_TO | UnknownOperator(string) -type variantType = Number | Enum_variant | Metadata_value | String_value | UnknownVariant(string) -type logicalOperator = AND | OR | UnknownLogicalOperator(string) -type val = StringArray(array) | String(string) | Int(int) - type modalValue = {conType: string, conText: React.element} type routingValueType = {heading: string, subHeading: string} type modalObj = (routingType, string) => modalValue @@ -46,11 +45,13 @@ type wasmModule = { getAllConnectors: unit => array, getVariantValues: string => array, } + type gateway = { distribution: int, disableFallback: bool, gateway_name: string, } + type volumeDistribution = { connector: string, split: int, @@ -63,12 +64,15 @@ type condition = { value: val, logicalOperator: logicalOperator, } + type routingOutputType = {override_3ds: string} + type rule = { gateways: array, conditions: array, routingOutput?: routingOutputType, } + type ruleInfoType = { rules: array, default_gateways: array, @@ -85,6 +89,7 @@ type historyData = { } type value = {"type": Js.Json.t, "value": Js.Json.t} + type payloadCondition = { lhs: string, comparison: string, From e1144ac0fe0c7573891097fbb1a8fc2b5ac6ff48 Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:07:30 +0530 Subject: [PATCH 03/10] refactor: cleanup routing previewer --- .../AdvancedRouting/RoutingPreviewer.res | 125 +----------------- 1 file changed, 1 insertion(+), 124 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/AdvancedRouting/RoutingPreviewer.res b/src/screens/HyperSwitch/Routing/AdvancedRouting/RoutingPreviewer.res index 578ca6eb4..95f691b4a 100644 --- a/src/screens/HyperSwitch/Routing/AdvancedRouting/RoutingPreviewer.res +++ b/src/screens/HyperSwitch/Routing/AdvancedRouting/RoutingPreviewer.res @@ -1,5 +1,4 @@ open RoutingTypes -open RoutingUtils module SimplePreview = { @react.component @@ -26,6 +25,7 @@ module SimplePreview = { } } + module GatewayView = { @react.component let make = (~gateways, ~connectorList=?) => { @@ -56,126 +56,3 @@ module GatewayView = { } } -module RulePreviewer = { - @react.component - let make = (~ruleInfo: ruleInfoType, ~isFrom3ds=false) => { - open LogicUtils -
-
-
- {ruleInfo.rules - ->Array.mapWithIndex((rule, index) => { - let headingText = `Rule ${string_of_int(index + 1)}` - let marginStyle = index === ruleInfo.rules->Array.length - 1 ? "mt-2" : "my-2" - let threeDsType = - rule.routingOutput->Belt.Option.getWithDefault(defaultThreeDsObjectValue) -
-
- {headingText->React.string} -
-
-
- {rule.conditions - ->RoutingUtils.filterEmptyValues - ->Array.mapWithIndex((condition, index) => { - let logical = logicalOperatorTypeToStringMapper(condition.logicalOperator) - let operator = operatorTypeToStringMapper(condition.operator) - let field = condition.field->String.length > 0 ? condition.field : "" - - let value = switch condition.value { - | StringArray(arr) => arr->Array.joinWith(", ") - | String(str) => str - | Int(int) => int->Belt.Int.toString - } - let metadataKey = switch condition.metadata { - | Some(json) => json->getDictFromJsonObject->getOptionString("key") - | _ => None - } - -
- - - - - {switch metadataKey { - | Some(key) => - | None => React.null - }} - - -
- }) - ->React.array} -
- Array.length > 0}> - - - -
- {threeDsType.override_3ds->LogicUtils.capitalizeString->React.string} -
-
- - - -
-
- }) - ->React.array} -
- -
-
- ()} - /> -
- {React.string("Default Processors")} - {React.string(" *")} -
-
-
- {ruleInfo.default_gateways - ->Array.mapWithIndex((gateway, index) => { -
-
- {React.string(string_of_int(index + 1))} -
-
{gateway->React.string}
- Array.length - 1}> - ()} - /> - -
- }) - ->React.array} -
-
-
-
-
- } -} From 1fa96c117e4141a7f8408eecff3ea2605287ee63 Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:18:01 +0530 Subject: [PATCH 04/10] refactor: unused routing Types and utils --- .../HyperSwitch/Routing/RoutingTypes.res | 18 ------------------ .../HyperSwitch/Routing/RoutingUtils.res | 15 ++++++++------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingTypes.res b/src/screens/HyperSwitch/Routing/RoutingTypes.res index 4852ee162..f3ada070f 100644 --- a/src/screens/HyperSwitch/Routing/RoutingTypes.res +++ b/src/screens/HyperSwitch/Routing/RoutingTypes.res @@ -67,17 +67,6 @@ type condition = { type routingOutputType = {override_3ds: string} -type rule = { - gateways: array, - conditions: array, - routingOutput?: routingOutputType, -} - -type ruleInfoType = { - rules: array, - default_gateways: array, -} - type historyData = { id: string, name: string, @@ -89,10 +78,3 @@ type historyData = { } type value = {"type": Js.Json.t, "value": Js.Json.t} - -type payloadCondition = { - lhs: string, - comparison: string, - value: value, - metadata: Js.Json.t, -} diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 0a4f4067a..349d0714b 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -191,7 +191,7 @@ let getWasmGateway = wasm => { let advanceRoutingConditionMapper = (dict, wasm) => { let variantType = wasm->getWasmKeyType(dict->getString("field", "")) - let obj = { + let obj: AdvancedRoutingTypes.statement = { lhs: dict->getString("field", ""), comparison: switch dict->getString("operator", "")->operatorMapper { | IS => "equal" @@ -205,7 +205,7 @@ let advanceRoutingConditionMapper = (dict, wasm) => { | UnknownOperator(str) => str }, value: { - "type": switch variantType->variantTypeMapper { + \"type": switch variantType->variantTypeMapper { | Number => "number" | Enum_variant => switch dict->getString("operator", "")->operatorMapper { @@ -218,8 +218,8 @@ let advanceRoutingConditionMapper = (dict, wasm) => { | Metadata_value => "metadata_variant" | String_value => "str_value" | _ => "" - }->Js.Json.string, - "value": switch variantType->variantTypeMapper { + }, + value: switch variantType->variantTypeMapper { | Number => (dict->getString("value", "")->float_of_string *. 100.00)->Js.Json.number | Enum_variant => switch dict->getString("operator", "")->operatorMapper { @@ -240,15 +240,16 @@ let advanceRoutingConditionMapper = (dict, wasm) => { | _ => ""->Js.Json.string }, }, - metadata: Dict.make()->Js.Json.object_, } - let value = [("value", obj.value["value"]), ("type", obj.value["type"])]->Dict.fromArray + let value = + [("value", obj.value.value), ("type", obj.value.\"type"->Js.Json.string)]->Dict.fromArray + let dict = [ ("lhs", obj.lhs->Js.Json.string), ("comparison", obj.comparison->Js.Json.string), ("value", value->Js.Json.object_), - ("metadata", obj.metadata), + ("metadata", Dict.make()->Js.Json.object_), ]->Dict.fromArray dict->Js.Json.object_ From 850a1f0ee1601bc8272dc7480be6772c133efd21 Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:20:42 +0530 Subject: [PATCH 05/10] refactor: unused routing Types and utils --- .../HyperSwitch/Routing/RoutingTypes.res | 8 ------ .../HyperSwitch/Routing/RoutingUtils.res | 25 ------------------- 2 files changed, 33 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingTypes.res b/src/screens/HyperSwitch/Routing/RoutingTypes.res index f3ada070f..4b0a522fa 100644 --- a/src/screens/HyperSwitch/Routing/RoutingTypes.res +++ b/src/screens/HyperSwitch/Routing/RoutingTypes.res @@ -57,14 +57,6 @@ type volumeDistribution = { split: int, } -type condition = { - field: string, - metadata?: Js.Json.t, - operator: operator, - value: val, - logicalOperator: logicalOperator, -} - type routingOutputType = {override_3ds: string} type historyData = { diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 349d0714b..2eebd682c 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -454,21 +454,6 @@ let valueTypeMapper = dict => { value } -let conditionTypeMapper = (conditionArr: array) => { - let conditionArray = [] - conditionArr->Array.forEach(value => { - let val = value->getDictFromJsonObject - let tempval = { - field: val->getString("field", ""), - metadata: val->getDictfromDict("metadata")->Js.Json.object_, - operator: val->getString("operator", "")->operatorMapper, - value: val->valueTypeMapper, - logicalOperator: val->getString("logical.operator", "")->logicalOperatorMapper, - } - conditionArray->Array.push(tempval) - }) - conditionArray -} let threeDsTypeMapper = dict => { let getRoutingOutputval = dict->getString("override_3ds", "three_ds") let val = { @@ -594,16 +579,6 @@ let validateConditionsFor3ds = dict => { }) } -let filterEmptyValues = (arr: array) => { - arr->Array.filter(item => { - switch item.value { - | StringArray(arr) => arr->Array.length > 0 - | String(str) => str->String.length > 0 - | Int(int) => int > 0 - } - }) -} - let getRecordsObject = json => { switch Js.Json.classify(json) { | JSONObject(jsonDict) => jsonDict->getArrayFromDict("records", []) From 8c161231fb94b89282b9728be21e27fa477c310f Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:39:31 +0530 Subject: [PATCH 06/10] refactor: unused routing Types and utils --- .../HyperSwitch/Routing/RoutingUtils.res | 140 +----------------- .../UserOnboardingUIUtils.res | 57 ------- 2 files changed, 1 insertion(+), 196 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 2eebd682c..6660f835e 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -1,9 +1,7 @@ open RoutingTypes open LogicUtils external toWasm: Js.Dict.t => wasmModule = "%identity" -let getObjects = (_: Js.Json.t) => { - [] -} + let defaultThreeDsObjectValue: routingOutputType = { override_3ds: "three_ds", } @@ -19,20 +17,6 @@ let getCurrentUTCTime = () => { `${currYear}-${currMonth}-${currDay}` } -let operatorMapper = value => { - switch value { - | "CONTAINS" => CONTAINS - | "NOT_CONTAINS" => NOT_CONTAINS - | "IS" => IS - | "IS_NOT" => IS_NOT - | "GREATER THAN" => GREATER_THAN - | "LESS THAN" => LESS_THAN - | "EQUAL TO" => EQUAL_TO - | "NOT EQUAL_TO" => NOT_EQUAL_TO - | _ => UnknownOperator("") - } -} - let variantTypeMapper = variantType => { switch variantType { | "number" => Number @@ -189,72 +173,6 @@ let getWasmGateway = wasm => { } } -let advanceRoutingConditionMapper = (dict, wasm) => { - let variantType = wasm->getWasmKeyType(dict->getString("field", "")) - let obj: AdvancedRoutingTypes.statement = { - lhs: dict->getString("field", ""), - comparison: switch dict->getString("operator", "")->operatorMapper { - | IS => "equal" - | IS_NOT => "not_equal" - | CONTAINS => "equal" - | NOT_CONTAINS => "not_equal" - | EQUAL_TO => "equal" - | GREATER_THAN => "greater_than" - | LESS_THAN => "less_than" - | NOT_EQUAL_TO => "not_equal" - | UnknownOperator(str) => str - }, - value: { - \"type": switch variantType->variantTypeMapper { - | Number => "number" - | Enum_variant => - switch dict->getString("operator", "")->operatorMapper { - | IS => "enum_variant" - | CONTAINS => "enum_variant_array" - | IS_NOT => "enum_variant" - | NOT_CONTAINS => "enum_variant_array" - | _ => "" - } - | Metadata_value => "metadata_variant" - | String_value => "str_value" - | _ => "" - }, - value: switch variantType->variantTypeMapper { - | Number => (dict->getString("value", "")->float_of_string *. 100.00)->Js.Json.number - | Enum_variant => - switch dict->getString("operator", "")->operatorMapper { - | IS => dict->getString("value", "")->Js.Json.string - | CONTAINS => dict->getArrayFromDict("value", [])->Js.Json.array - | IS_NOT => dict->getString("value", "")->Js.Json.string - | NOT_CONTAINS => dict->getArrayFromDict("value", [])->Js.Json.array - - | _ => ""->Js.Json.string - } - | Metadata_value => { - let key = - dict->getDictfromDict("metadata")->getString("key", "")->String.trim->Js.Json.string - let value = dict->getString("value", "")->String.trim->Js.Json.string - Dict.fromArray([("key", key), ("value", value)])->Js.Json.object_ - } - | String_value => dict->getString("value", "")->Js.Json.string - | _ => ""->Js.Json.string - }, - }, - } - let value = - [("value", obj.value.value), ("type", obj.value.\"type"->Js.Json.string)]->Dict.fromArray - - let dict = - [ - ("lhs", obj.lhs->Js.Json.string), - ("comparison", obj.comparison->Js.Json.string), - ("value", value->Js.Json.object_), - ("metadata", Dict.make()->Js.Json.object_), - ]->Dict.fromArray - - dict->Js.Json.object_ -} - let getVolumeSplit = ( dict_arr, objMapper, @@ -277,62 +195,6 @@ let checkIfValuePresesent = valueRes => { conditionMatched } -let generateStatement = (arr, wasm) => { - let conditionDict = Dict.make() - let statementDict = Dict.make() - arr->Array.forEachWithIndex((item, index) => { - let valueRes = - item->getDictFromJsonObject->Dict.get("value")->Belt.Option.getWithDefault([]->Js.Json.array) - - if valueRes->checkIfValuePresesent { - let value = item->getDictFromJsonObject->advanceRoutingConditionMapper(wasm) - let logical = item->getDictFromJsonObject->getString("logical.operator", "") - - switch logical->logicalOperatorMapper { - | OR => { - let copyDict = Js.Dict.map((. val) => val, conditionDict) - Dict.set(statementDict, Belt.Int.toString(index), copyDict) - conditionDict->Dict.set("condition", []->Js.Json.array) - let val = - conditionDict->Dict.get("condition")->Belt.Option.getWithDefault([]->Js.Json.array) - let arr = switch Js.Json.classify(val) { - | JSONArray(arr) => { - arr->Array.push(value) - arr - } - | _ => [] - } - conditionDict->Dict.set("condition", arr->Js.Json.array) - } - - | _ => - let val = - conditionDict->Dict.get("condition")->Belt.Option.getWithDefault([]->Js.Json.array) - let arr = switch Js.Json.classify(val) { - | JSONArray(arr) => { - arr->Array.push(value) - arr - } - - | _ => [] - } - conditionDict->Dict.set("condition", arr->Js.Json.array) - } - } - }) - - let copyDict = Js.Dict.map((. val) => val, conditionDict) - Dict.set(statementDict, Belt.Int.toString(arr->Array.length), copyDict) - statementDict - ->Dict.keysToArray - ->Array.map(val => { - switch statementDict->Dict.get(val) { - | Some(dt) => dt->Js.Json.object_ - | _ => Dict.make()->Js.Json.object_ - } - }) -} - let getDefaultSelection = dict => { [ ("data", dict->getArrayFromDict("default_gateways", [])->Js.Json.array), diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res index 0bfebfccb..6e846a84c 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res @@ -862,63 +862,6 @@ let getTabsForIntegration = ( , }, - // { - // title: "3. Manage", - // renderContent: () => { - // let skipAndContinue = async () => { - // try { - // let url = APIUtils.getURL(~entityName=INTEGRATION_DETAILS, ~methodType=Post, ()) - // let metaDataDict = - // Dict.fromArray([("is_skip", true->Js.Json.boolean)])->Js.Json.object_ - // let body = HSwitchUtils.constructOnboardingBody( - // ~dashboardPageState, - // ~integrationDetails, - // ~is_done=false, - // ~metadata=metaDataDict, - // (), - // ) - // let _ = await updateDetails(url, body, Post) - // setIntegrationDetails(_ => body->ProviderHelper.getIntegrationDetails) - // } catch { - // | _ => () - // } - // } - // let skipOnboarding = async path => { - // let _ = await skipAndContinue() - // Window._open(path) - // } - //
- // - //
skipOnboarding(`/connectors`)->ignore} className="cursor-pointer"> - //
- // - //
- //
- //
- // - //
skipOnboarding(`/routing`)->ignore} className="cursor-pointer"> - //
- // - //
- //
- //
- // - //
skipOnboarding(`/payments`)->ignore} className="cursor-pointer"> - //
- // - //
- //
- //
- // // - //
- // }, - // }, ] | _ => [] } From 819b31fb75ca90db5c3e4bdfc689df687e036f1b Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:40:57 +0530 Subject: [PATCH 07/10] refactor: unused routing Types and utils --- .../HyperSwitch/Routing/RoutingUtils.res | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 6660f835e..3333017b8 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -17,24 +17,6 @@ let getCurrentUTCTime = () => { `${currYear}-${currMonth}-${currDay}` } -let variantTypeMapper = variantType => { - switch variantType { - | "number" => Number - | "enum_variant" => Enum_variant - | "metadata_value" => Metadata_value - | "str_value" => String_value - | _ => UnknownVariant("") - } -} - -let logicalOperatorMapper = logical => { - switch logical { - | "AND" => AND - | "OR" => OR - | _ => UnknownLogicalOperator("") - } -} - let routingTypeMapper = routingType => { switch routingType { | "single" => SINGLE @@ -59,27 +41,6 @@ let routingTypeName = routingType => { } } -let logicalOperatorTypeToStringMapper = logicalOperator => { - switch logicalOperator { - | AND => "AND" - | OR => "OR" - | UnknownLogicalOperator(str) => str - } -} -let operatorTypeToStringMapper = operator => { - switch operator { - | IS => "IS" - | CONTAINS => "CONTAINS" - | IS_NOT => "IS_NOT" - | NOT_CONTAINS => "NOT_CONTAINS" - | GREATER_THAN => "GREATER THAN" - | LESS_THAN => "LESS THAN" - | EQUAL_TO => "EQUAL TO" - | NOT_EQUAL_TO => "NOT EQUAL_TO" - | UnknownOperator(str) => str - } -} - let itemGateWayObjMapper = ( dict, _connectorList: option>, From 719ed252adff3091a8a8cbac3afe2e82532e08ef Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:48:19 +0530 Subject: [PATCH 08/10] refactor: unused routing Types and utils --- .../HyperSwitch/Routing/RoutingUtils.res | 155 ------------------ .../Routing/VolumeSplitRouting.res | 2 +- .../RoutingRevamp/AdvancedRouting.res | 4 +- .../RoutingRevamp/AdvancedRoutingUIUtils.res | 19 +++ 4 files changed, 23 insertions(+), 157 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 3333017b8..e8a8d03af 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -41,54 +41,6 @@ let routingTypeName = routingType => { } } -let itemGateWayObjMapper = ( - dict, - _connectorList: option>, -) => { - let connectorId = dict->getDictfromDict("connector")->getString("merchant_connector_id", "") - [ - ("distribution", dict->getFloat("split", 0.00)->Js.Json.number), - ("disableFallback", dict->getBool("disableFallback", false)->Js.Json.boolean), - ("gateway_name", connectorId->Js.Json.string), - ]->Dict.fromArray -} - -let itemBodyGateWayObjMapper = ( - dict, - connectorList: option>, -) => { - let merchantConnectorId = - dict->getDictfromDict("connector")->getString("merchant_connector_id", "") - let name = - connectorList - ->Belt.Option.getWithDefault([Dict.make()->ConnectorTableUtils.getProcessorPayloadType]) - ->ConnectorTableUtils.getConnectorNameViaId(merchantConnectorId) - let newDict = - [ - ("connector", name.connector_name->Js.Json.string), - ("merchant_connector_id", merchantConnectorId->Js.Json.string), - ] - ->Dict.fromArray - ->Js.Json.object_ - [("split", dict->getFloat("split", 0.00)->Js.Json.number), ("connector", newDict)]->Dict.fromArray -} - -let connectorPayload = (routingType, arr) => { - switch routingType->routingTypeMapper { - | VOLUME_SPLIT => { - let connectorData = arr->Array.reduce([], (acc, routingObj) => { - let routingDict = routingObj->getDictFromJsonObject - acc->Array.push(getString(routingDict, "connector", "")) - acc - }) - connectorData - } - - | PRIORITY => arr->Js.Json.array->getStrArryFromJson - | _ => [] - } -} - let getRoutingPayload = (data, routingType, name, description, profileId) => { let connectorsOrder = [("data", data->Js.Json.array), ("type", routingType->Js.Json.string)]->Dict.fromArray @@ -101,89 +53,6 @@ let getRoutingPayload = (data, routingType, name, description, profileId) => { ]->Dict.fromArray } -let getWasmKeyType = (wasm, value) => { - try { - switch wasm { - | Some(res) => res.getKeyType(value) - | None => "" - } - } catch { - | _ => "" - } -} - -let getWasmVariantValues = (wasm, value) => { - try { - switch wasm { - | Some(res) => res.getVariantValues(value) - | None => [] - } - } catch { - | _ => [] - } -} - -let getWasmGateway = wasm => { - try { - switch wasm { - | Some(res) => res.getAllConnectors() - | None => [] - } - } catch { - | _ => [] - } -} - -let getVolumeSplit = ( - dict_arr, - objMapper, - connectorList: option>, -) => { - dict_arr->Array.reduce([], (acc, routingObj) => { - let value = [routingObj->getDictFromJsonObject->objMapper(connectorList)->Js.Json.object_] - acc->Array.concat(value)->Array.map(value => value) - }) -} - -let checkIfValuePresesent = valueRes => { - // to check if the value is present only then add to the statement - let conditionMatched = switch Js.Json.classify(valueRes) { - | JSONArray(arr) => arr->Array.length > 0 - | JSONString(str) => str->String.length > 0 - | JSONNumber(num) => num > Belt.Int.toFloat(0) - | _ => false - } - conditionMatched -} - -let getDefaultSelection = dict => { - [ - ("data", dict->getArrayFromDict("default_gateways", [])->Js.Json.array), - ("type", "priority"->Js.Json.string), - ]->Dict.fromArray -} -let generateRuleObject = (index, connectorSelection, statement) => { - let ruleObj = Dict.fromArray([ - ("name", `rule_${string_of_int(index + 1)}`->Js.Json.string), - ("statements", statement->Js.Json.array), - ("connectorSelection", connectorSelection->Js.Json.object_), - ]) - ruleObj -} -let constuctAlgorithm = (dict, rules, metadata) => { - let body = - [ - ("defaultSelection", getDefaultSelection(dict)->Js.Json.object_), - ("rules", rules->Js.Json.array), - ("metadata", metadata->Js.Json.object_), - ]->Dict.fromArray - - let algorithm = - [("type", "advanced"->Js.Json.string), ("data", body->Js.Json.object_)]->Dict.fromArray - - algorithm -} - let getModalObj = (routingType, text) => { switch routingType { | ADVANCED => { @@ -299,12 +168,6 @@ let constructNameDescription = routingType => { ]) } -let manipulateInitialValueJson = initialValueJson => { - let manipulatedJson = ADVANCED->constructNameDescription - manipulatedJson->Dict.set("code", initialValueJson->getString("code", "")->Js.Json.string) - manipulatedJson->Dict.set("json", initialValueJson->getObj("json", Dict.make())->Js.Json.object_) - manipulatedJson -} let currentTabNameRecoilAtom = Recoil.atom(. "currentTabName", "ActiveTab") module SaveAndActivateButton = { @@ -344,24 +207,6 @@ module SaveAndActivateButton = { /> } } -module ConfigureRuleButton = { - @react.component - let make = (~setShowModal, ~isConfigButtonEnabled) => { - let formState: ReactFinalForm.formState = ReactFinalForm.useFormState( - ReactFinalForm.useFormSubscription(["values"])->Js.Nullable.return, - ) - -