diff --git a/.githooks/commit-msg b/.githooks/commit-msg index e4b5d138e..26b4e3eb0 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -9,8 +9,8 @@ commit_msg=$(cat "$commit_msg_file") echo echo "*****~~~~~ Formatting - Check for unformatted files ~~~~~~*****" -# Check for unformatted JavaScript, TypeScript, and JSON files using Prettier -unformatted_js_files=$(git ls-files | grep '\.js\|\.jsx\|\.ts\|\.tsx\|\.json' | xargs npx prettier --list-different) +# Check for unformatted JavaScript and JSON files using Prettier +unformatted_js_files=$(git ls-files | grep '\.js\|\.json' | xargs npx prettier --list-different) # If there are unformatted JavaScript, TypeScript, or JSON files, print an error message and exit with a non-zero status code if [ -n "$unformatted_js_files" ]; then @@ -26,14 +26,6 @@ echo echo "*****~~~~~ All files are formatted. ~~~~~~*****" echo -# JS Code Check -echo "*****~~~~~ Checking ReScript Code ~~~~~~*****" -if (! npm run re:build) -then - echo "*****~~~~~ ReScript Code Compilation Failed! ~~~~~*****" - exit 1 -fi - echo echo "*****~~~~~ Commit message validation! ~~~~~*****" echo diff --git a/.prettierignore b/.prettierignore index 83b694704..4924cc8c7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ -CHANGELOG.md \ No newline at end of file +CHANGELOG.md +*euclid* diff --git a/public/hyperswitch/module.js b/public/hyperswitch/module.js index d5143e314..632af9f49 100644 --- a/public/hyperswitch/module.js +++ b/public/hyperswitch/module.js @@ -62,3 +62,43 @@ function getParsedJson(str) { throw e; } } + +function getThreeDsKeys() { + if (wasm) { + return wasm.getThreeDsKeys(); + } else { + return []; + } +} + +function getAllKeys() { + if (wasm) { + return wasm.getAllKeys(); + } else { + return []; + } +} + +function getKeyType(str) { + if (wasm) { + return wasm.getKeyType(str); + } else { + return ""; + } +} + +function getAllConnectors() { + if (wasm) { + return wasm.getAllConnectors(); + } else { + return []; + } +} + +function getVariantValues(str) { + if (wasm) { + return wasm.getVariantValues(str); + } else { + return []; + } +} diff --git a/public/hyperswitch/wasm/euclid.d.ts b/public/hyperswitch/wasm/euclid.d.ts index fa5ff3caa..94af4dabd 100644 --- a/public/hyperswitch/wasm/euclid.d.ts +++ b/public/hyperswitch/wasm/euclid.d.ts @@ -1,142 +1,128 @@ /* tslint:disable */ /* eslint-disable */ /** - * This function can be used by the frontend to educate wasm about the forex rates data. - * The input argument is a struct fields base_currency and conversion where later is all the conversions associated with the base_currency - * to all different currencies present. - * @param {any} forex - * @returns {any} - */ +* This function can be used by the frontend to educate wasm about the forex rates data. +* The input argument is a struct fields base_currency and conversion where later is all the conversions associated with the base_currency +* to all different currencies present. +* @param {any} forex +* @returns {any} +*/ export function setForexData(forex: any): any; /** - * This function can be used to perform currency_conversion on the input amount, from_currency, - * to_currency which are all expected to be one of currencies we already have in our Currency - * enum. - * @param {bigint} amount - * @param {any} from_currency - * @param {any} to_currency - * @returns {any} - */ -export function convertCurrency( - amount: bigint, - from_currency: any, - to_currency: any, -): any; -/** - * This function can be used by the frontend to provide the WASM with information about - * all the merchant's connector accounts. The input argument is a vector of all the merchant's - * connector accounts from the API. - * @param {any} mcas - * @returns {any} - */ +* This function can be used to perform currency_conversion on the input amount, from_currency, +* to_currency which are all expected to be one of currencies we already have in our Currency +* enum. +* @param {bigint} amount +* @param {any} from_currency +* @param {any} to_currency +* @returns {any} +*/ +export function convertCurrency(amount: bigint, from_currency: any, to_currency: any): any; +/** +* This function can be used by the frontend to provide the WASM with information about +* all the merchant's connector accounts. The input argument is a vector of all the merchant's +* connector accounts from the API. +* @param {any} mcas +* @returns {any} +*/ export function seedKnowledgeGraph(mcas: any): any; /** - * This function allows the frontend to get all the merchant's configured - * connectors that are valid for a rule based on the conditions specified in - * the rule - * @param {any} rule - * @returns {any} - */ +* This function allows the frontend to get all the merchant's configured +* connectors that are valid for a rule based on the conditions specified in +* the rule +* @param {any} rule +* @returns {any} +*/ export function getValidConnectorsForRule(rule: any): any; /** - * @param {any} js_program - * @returns {any} - */ +* @param {any} js_program +* @returns {any} +*/ export function analyzeProgram(js_program: any): any; /** - * @param {any} program - * @param {any} input - * @returns {any} - */ +* @param {any} program +* @param {any} input +* @returns {any} +*/ export function runProgram(program: any, input: any): any; /** - * @returns {any} - */ +* @returns {any} +*/ export function getAllConnectors(): any; /** - * @returns {any} - */ +* @returns {any} +*/ export function getAllKeys(): any; /** - * @param {string} key - * @returns {string} - */ +* @param {string} key +* @returns {string} +*/ export function getKeyType(key: string): string; /** - * @returns {any} - */ +* @returns {any} +*/ export function getThreeDsKeys(): any; /** - * @returns {any} - */ +* @returns {any} +*/ export function getSurchargeKeys(): any; /** - * @param {string} val - * @returns {string} - */ +* @param {string} val +* @returns {string} +*/ export function parseToString(val: string): string; /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getVariantValues(key: string): any; /** - * @param {bigint} n1 - * @param {bigint} n2 - * @returns {bigint} - */ +* @param {bigint} n1 +* @param {bigint} n2 +* @returns {bigint} +*/ export function addTwo(n1: bigint, n2: bigint): bigint; /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getConnectorConfig(key: string): any; /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getPayoutConnectorConfig(key: string): any; /** - * @param {any} input - * @param {any} response - * @returns {any} - */ +* @param {any} input +* @param {any} response +* @returns {any} +*/ export function getRequestPayload(input: any, response: any): any; /** - * @param {any} input - * @returns {any} - */ +* @param {any} input +* @returns {any} +*/ export function getResponsePayload(input: any): any; /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getDescriptionCategory(key: string): any; /** - * - * Function exposed as `wasm` function in js `parse`. Allowing use to extend the functionality and - * usage for web - * @param {string} val - * @returns {string} - */ +* +* Function exposed as `wasm` function in js `parse`. Allowing use to extend the functionality and +* usage for web +* @param {string} val +* @returns {string} +*/ export function parse(val: string): string; -export type InitInput = - | RequestInfo - | URL - | Response - | BufferSource - | WebAssembly.Module; +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly setForexData: (a: number, b: number) => void; - readonly convertCurrency: ( - a: number, - b: number, - c: number, - d: number, - ) => void; + readonly convertCurrency: (a: number, b: number, c: number, d: number) => void; readonly seedKnowledgeGraph: (a: number, b: number) => void; readonly getValidConnectorsForRule: (a: number, b: number) => void; readonly analyzeProgram: (a: number, b: number) => void; @@ -156,12 +142,7 @@ export interface InitOutput { readonly parse: (a: number, b: number, c: number) => void; readonly parseToString: (a: number, b: number, c: number) => void; readonly __wbindgen_export_0: (a: number, b: number) => number; - readonly __wbindgen_export_1: ( - a: number, - b: number, - c: number, - d: number, - ) => number; + readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export_2: (a: number, b: number, c: number) => void; readonly __wbindgen_export_3: (a: number) => void; @@ -169,23 +150,21 @@ export interface InitOutput { export type SyncInitInput = BufferSource | WebAssembly.Module; /** - * Instantiates the given `module`, which can either be bytes or - * a precompiled `WebAssembly.Module`. - * - * @param {SyncInitInput} module - * - * @returns {InitOutput} - */ +* Instantiates the given `module`, which can either be bytes or +* a precompiled `WebAssembly.Module`. +* +* @param {SyncInitInput} module +* +* @returns {InitOutput} +*/ export function initSync(module: SyncInitInput): InitOutput; /** - * If `module_or_path` is {RequestInfo} or {URL}, makes a request and - * for everything else, calls `WebAssembly.instantiate` directly. - * - * @param {InitInput | Promise} module_or_path - * - * @returns {Promise} - */ -export default function __wbg_init( - module_or_path?: InitInput | Promise, -): Promise; +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and +* for everything else, calls `WebAssembly.instantiate` directly. +* +* @param {InitInput | Promise} module_or_path +* +* @returns {Promise} +*/ +export default function __wbg_init (module_or_path?: InitInput | Promise): Promise; diff --git a/public/hyperswitch/wasm/euclid.js b/public/hyperswitch/wasm/euclid.js index be86d0cf0..dadd31f11 100644 --- a/public/hyperswitch/wasm/euclid.js +++ b/public/hyperswitch/wasm/euclid.js @@ -1,30 +1,21 @@ let wasm; -const cachedTextDecoder = - typeof TextDecoder !== "undefined" - ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) - : { - decode: () => { - throw Error("TextDecoder not available"); - }, - }; - -if (typeof TextDecoder !== "undefined") { - cachedTextDecoder.decode(); -} +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; let cachedUint8Memory0 = null; function getUint8Memory0() { - if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8Memory0; + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; } function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); } const heap = new Array(128).fill(undefined); @@ -34,1017 +25,938 @@ heap.push(undefined, null, true, false); let heap_next = heap.length; function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; - heap[idx] = obj; - return idx; + heap[idx] = obj; + return idx; } -function getObject(idx) { - return heap[idx]; -} +function getObject(idx) { return heap[idx]; } function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; } function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; + const ret = getObject(idx); + dropObject(idx); + return ret; } let WASM_VECTOR_LEN = 0; -const cachedTextEncoder = - typeof TextEncoder !== "undefined" - ? new TextEncoder("utf-8") - : { - encode: () => { - throw Error("TextEncoder not available"); - }, - }; - -const encodeString = - typeof cachedTextEncoder.encodeInto === "function" +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); - } + return cachedTextEncoder.encodeInto(arg, view); +} : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length, - }; - }; + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); function passStringToWasm0(arg, malloc, realloc) { - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8Memory0() - .subarray(ptr, ptr + buf.length) - .set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } - const mem = getUint8Memory0(); + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; - let offset = 0; + const mem = getUint8Memory0(); - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7f) break; - mem[ptr + offset] = code; - } + let offset = 0; - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; } - ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0; - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - offset += ret.written; - } + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } - WASM_VECTOR_LEN = offset; - return ptr; + WASM_VECTOR_LEN = offset; + return ptr; } function isLikeNone(x) { - return x === undefined || x === null; + return x === undefined || x === null; } let cachedInt32Memory0 = null; function getInt32Memory0() { - if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { - cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachedInt32Memory0; + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; } let cachedBigInt64Memory0 = null; function getBigInt64Memory0() { - if ( - cachedBigInt64Memory0 === null || - cachedBigInt64Memory0.byteLength === 0 - ) { - cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); - } - return cachedBigInt64Memory0; + if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { + cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); + } + return cachedBigInt64Memory0; } let cachedFloat64Memory0 = null; function getFloat64Memory0() { - if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { - cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachedFloat64Memory0; + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; } function debugString(val) { - // primitive types - const type = typeof val; - if (type == "number" || type == "boolean" || val == null) { - return `${val}`; - } - if (type == "string") { - return `"${val}"`; - } - if (type == "symbol") { - const description = val.description; - if (description == null) { - return "Symbol"; - } else { - return `Symbol(${description})`; + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; } - } - if (type == "function") { - const name = val.name; - if (typeof name == "string" && name.length > 0) { - return `Function(${name})`; - } else { - return "Function"; + if (type == 'string') { + return `"${val}"`; } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = "["; - if (length > 0) { - debug += debugString(val[0]); + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } } - for (let i = 1; i < length; i++) { - debug += ", " + debugString(val[i]); + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } } - debug += "]"; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == "Object") { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return "Object(" + JSON.stringify(val) + ")"; - } catch (_) { - return "Object"; + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; } /** - * This function can be used by the frontend to educate wasm about the forex rates data. - * The input argument is a struct fields base_currency and conversion where later is all the conversions associated with the base_currency - * to all different currencies present. - * @param {any} forex - * @returns {any} - */ +* This function can be used by the frontend to educate wasm about the forex rates data. +* The input argument is a struct fields base_currency and conversion where later is all the conversions associated with the base_currency +* to all different currencies present. +* @param {any} forex +* @returns {any} +*/ export function setForexData(forex) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.setForexData(retptr, addHeapObject(forex)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.setForexData(retptr, addHeapObject(forex)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * This function can be used to perform currency_conversion on the input amount, from_currency, - * to_currency which are all expected to be one of currencies we already have in our Currency - * enum. - * @param {bigint} amount - * @param {any} from_currency - * @param {any} to_currency - * @returns {any} - */ +* This function can be used to perform currency_conversion on the input amount, from_currency, +* to_currency which are all expected to be one of currencies we already have in our Currency +* enum. +* @param {bigint} amount +* @param {any} from_currency +* @param {any} to_currency +* @returns {any} +*/ export function convertCurrency(amount, from_currency, to_currency) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.convertCurrency( - retptr, - amount, - addHeapObject(from_currency), - addHeapObject(to_currency), - ); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.convertCurrency(retptr, amount, addHeapObject(from_currency), addHeapObject(to_currency)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * This function can be used by the frontend to provide the WASM with information about - * all the merchant's connector accounts. The input argument is a vector of all the merchant's - * connector accounts from the API. - * @param {any} mcas - * @returns {any} - */ +* This function can be used by the frontend to provide the WASM with information about +* all the merchant's connector accounts. The input argument is a vector of all the merchant's +* connector accounts from the API. +* @param {any} mcas +* @returns {any} +*/ export function seedKnowledgeGraph(mcas) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.seedKnowledgeGraph(retptr, addHeapObject(mcas)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.seedKnowledgeGraph(retptr, addHeapObject(mcas)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * This function allows the frontend to get all the merchant's configured - * connectors that are valid for a rule based on the conditions specified in - * the rule - * @param {any} rule - * @returns {any} - */ +* This function allows the frontend to get all the merchant's configured +* connectors that are valid for a rule based on the conditions specified in +* the rule +* @param {any} rule +* @returns {any} +*/ export function getValidConnectorsForRule(rule) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getValidConnectorsForRule(retptr, addHeapObject(rule)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getValidConnectorsForRule(retptr, addHeapObject(rule)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {any} js_program - * @returns {any} - */ +* @param {any} js_program +* @returns {any} +*/ export function analyzeProgram(js_program) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.analyzeProgram(retptr, addHeapObject(js_program)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.analyzeProgram(retptr, addHeapObject(js_program)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {any} program - * @param {any} input - * @returns {any} - */ +* @param {any} program +* @param {any} input +* @returns {any} +*/ export function runProgram(program, input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.runProgram(retptr, addHeapObject(program), addHeapObject(input)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.runProgram(retptr, addHeapObject(program), addHeapObject(input)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @returns {any} - */ +* @returns {any} +*/ export function getAllConnectors() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getAllConnectors(retptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getAllConnectors(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @returns {any} - */ +* @returns {any} +*/ export function getAllKeys() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getAllKeys(retptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getAllKeys(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {string} key - * @returns {string} - */ +* @param {string} key +* @returns {string} +*/ export function getKeyType(key) { - let deferred3_0; - let deferred3_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - key, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.getKeyType(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - var r3 = getInt32Memory0()[retptr / 4 + 3]; - var ptr2 = r0; - var len2 = r1; - if (r3) { - ptr2 = 0; - len2 = 0; - throw takeObject(r2); + let deferred3_0; + let deferred3_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.getKeyType(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + var ptr2 = r0; + var len2 = r1; + if (r3) { + ptr2 = 0; len2 = 0; + throw takeObject(r2); + } + deferred3_0 = ptr2; + deferred3_1 = len2; + return getStringFromWasm0(ptr2, len2); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1); } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1); - } } /** - * @returns {any} - */ +* @returns {any} +*/ export function getThreeDsKeys() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getThreeDsKeys(retptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getThreeDsKeys(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @returns {any} - */ +* @returns {any} +*/ export function getSurchargeKeys() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getSurchargeKeys(retptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getSurchargeKeys(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {string} val - * @returns {string} - */ +* @param {string} val +* @returns {string} +*/ export function parseToString(val) { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - val, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.parse(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - deferred2_0 = r0; - deferred2_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1); - } + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(val, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.parse(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred2_0 = r0; + deferred2_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1); + } } /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getVariantValues(key) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - key, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.getVariantValues(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.getVariantValues(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {bigint} n1 - * @param {bigint} n2 - * @returns {bigint} - */ +* @param {bigint} n1 +* @param {bigint} n2 +* @returns {bigint} +*/ export function addTwo(n1, n2) { - const ret = wasm.addTwo(n1, n2); - return ret; + const ret = wasm.addTwo(n1, n2); + return ret; } /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getConnectorConfig(key) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - key, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.getConnectorConfig(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.getConnectorConfig(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getPayoutConnectorConfig(key) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - key, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.getPayoutConnectorConfig(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.getPayoutConnectorConfig(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {any} input - * @param {any} response - * @returns {any} - */ +* @param {any} input +* @param {any} response +* @returns {any} +*/ export function getRequestPayload(input, response) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getRequestPayload( - retptr, - addHeapObject(input), - addHeapObject(response), - ); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getRequestPayload(retptr, addHeapObject(input), addHeapObject(response)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {any} input - * @returns {any} - */ +* @param {any} input +* @returns {any} +*/ export function getResponsePayload(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.getResponsePayload(retptr, addHeapObject(input)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.getResponsePayload(retptr, addHeapObject(input)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } /** - * @param {string} key - * @returns {any} - */ +* @param {string} key +* @returns {any} +*/ export function getDescriptionCategory(key) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - key, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.getDescriptionCategory(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.getDescriptionCategory(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } } function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_export_3(addHeapObject(e)); - } + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_export_3(addHeapObject(e)); + } } /** - * - * Function exposed as `wasm` function in js `parse`. Allowing use to extend the functionality and - * usage for web - * @param {string} val - * @returns {string} - */ +* +* Function exposed as `wasm` function in js `parse`. Allowing use to extend the functionality and +* usage for web +* @param {string} val +* @returns {string} +*/ export function parse(val) { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0( - val, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len0 = WASM_VECTOR_LEN; - wasm.parse(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - deferred2_0 = r0; - deferred2_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1); - } + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(val, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len0 = WASM_VECTOR_LEN; + wasm.parse(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred2_0 = r0; + deferred2_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1); + } } async function __wbg_load(module, imports) { - if (typeof Response === "function" && module instanceof Response) { - if (typeof WebAssembly.instantiateStreaming === "function") { - try { - return await WebAssembly.instantiateStreaming(module, imports); - } catch (e) { - if (module.headers.get("Content-Type") != "application/wasm") { - console.warn( - "`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", - e, - ); - } else { - throw e; + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } } - } - } - const bytes = await module.arrayBuffer(); - return await WebAssembly.instantiate(bytes, imports); - } else { - const instance = await WebAssembly.instantiate(module, imports); + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); - if (instance instanceof WebAssembly.Instance) { - return { instance, module }; } else { - return instance; + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } } - } } function __wbg_get_imports() { - const imports = {}; - imports.wbg = {}; - imports.wbg.__wbindgen_string_new = function (arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_object_drop_ref = function (arg0) { - takeObject(arg0); - }; - imports.wbg.__wbg_set_bedc3d02d0f05eb0 = function (arg0, arg1, arg2) { - const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_is_string = function (arg0) { - const ret = typeof getObject(arg0) === "string"; - return ret; - }; - imports.wbg.__wbindgen_error_new = function (arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); - }; - imports.wbg.__wbg_set_841ac57cff3d672b = function (arg0, arg1, arg2) { - getObject(arg0)[takeObject(arg1)] = takeObject(arg2); - }; - imports.wbg.__wbg_new_b51585de1b234aff = function () { - const ret = new Object(); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_is_object = function (arg0) { - const val = getObject(arg0); - const ret = typeof val === "object" && val !== null; - return ret; - }; - imports.wbg.__wbg_entries_e51f29c7bba0c054 = function (arg0) { - const ret = Object.entries(getObject(arg0)); - return addHeapObject(ret); - }; - imports.wbg.__wbg_length_fff51ee6522a1a18 = function (arg0) { - const ret = getObject(arg0).length; - return ret; - }; - imports.wbg.__wbg_get_44be0491f933a435 = function (arg0, arg1) { - const ret = getObject(arg0)[arg1 >>> 0]; - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_string_get = function (arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof obj === "string" ? obj : undefined; - var ptr1 = isLikeNone(ret) - ? 0 - : passStringToWasm0( - ret, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - var len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; - }; - imports.wbg.__wbg_new_56693dbed0c32988 = function () { - const ret = new Map(); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_number_new = function (arg0) { - const ret = arg0; - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_bigint_from_i64 = function (arg0) { - const ret = arg0; - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_jsval_loose_eq = function (arg0, arg1) { - const ret = getObject(arg0) == getObject(arg1); - return ret; - }; - imports.wbg.__wbindgen_boolean_get = function (arg0) { - const v = getObject(arg0); - const ret = typeof v === "boolean" ? (v ? 1 : 0) : 2; - return ret; - }; - imports.wbg.__wbindgen_is_bigint = function (arg0) { - const ret = typeof getObject(arg0) === "bigint"; - return ret; - }; - imports.wbg.__wbindgen_bigint_get_as_i64 = function (arg0, arg1) { - const v = getObject(arg1); - const ret = typeof v === "bigint" ? v : undefined; - getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); - }; - imports.wbg.__wbindgen_jsval_eq = function (arg0, arg1) { - const ret = getObject(arg0) === getObject(arg1); - return ret; - }; - imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) { - const ret = BigInt.asUintN(64, arg0); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_number_get = function (arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof obj === "number" ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); - }; - imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function (arg0) { - const ret = Number.isSafeInteger(getObject(arg0)); - return ret; - }; - imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function (arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; - }; - imports.wbg.__wbg_iterator_97f0c81209c6c35a = function () { - const ret = Symbol.iterator; - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_in = function (arg0, arg1) { - const ret = getObject(arg0) in getObject(arg1); - return ret; - }; - imports.wbg.__wbg_new_898a68150f225f2e = function () { - const ret = new Array(); - return addHeapObject(ret); - }; - imports.wbg.__wbg_set_502d29070ea18557 = function (arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); - }; - imports.wbg.__wbg_String_88810dfeb4021902 = function (arg0, arg1) { - const ret = String(getObject(arg1)); - const ptr1 = passStringToWasm0( - ret, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; - }; - imports.wbg.__wbg_getwithrefkey_5e6d9547403deab8 = function (arg0, arg1) { - const ret = getObject(arg0)[getObject(arg1)]; - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_is_undefined = function (arg0) { - const ret = getObject(arg0) === undefined; - return ret; - }; - imports.wbg.__wbg_next_ddb3312ca1c4e32a = function () { - return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbg_done_5c1f01fb660d73b5 = function (arg0) { - const ret = getObject(arg0).done; - return ret; - }; - imports.wbg.__wbg_value_1695675138684bd5 = function (arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); - }; - imports.wbg.__wbg_fromCodePoint_5aced4409dbb8969 = function () { - return handleError(function (arg0) { - const ret = String.fromCodePoint(arg0 >>> 0); - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbindgen_bigint_from_i128 = function (arg0, arg1) { - const ret = (arg0 << BigInt(64)) | BigInt.asUintN(64, arg1); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_bigint_from_u128 = function (arg0, arg1) { - const ret = - (BigInt.asUintN(64, arg0) << BigInt(64)) | BigInt.asUintN(64, arg1); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_memory = function () { - const ret = wasm.memory; - return addHeapObject(ret); - }; - imports.wbg.__wbg_buffer_085ec1f694018c4f = function (arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); - }; - imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function ( - arg0, - arg1, - arg2, - ) { - const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); - return addHeapObject(ret); - }; - imports.wbg.__wbg_new_8125e318e6245eed = function (arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); - }; - imports.wbg.__wbg_from_d7c216d4616bb368 = function (arg0) { - const ret = Array.from(getObject(arg0)); - return addHeapObject(ret); - }; - imports.wbg.__wbg_get_97b561fb56f034b5 = function () { - return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbindgen_is_function = function (arg0) { - const ret = typeof getObject(arg0) === "function"; - return ret; - }; - imports.wbg.__wbg_call_cb65541d95d71282 = function () { - return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbg_next_526fc47e980da008 = function (arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); - }; - imports.wbg.__wbg_length_72e2208bbc0efc61 = function (arg0) { - const ret = getObject(arg0).length; - return ret; - }; - imports.wbg.__wbg_set_5cf90238115182c3 = function (arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); - }; - imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function (arg0) { - let result; - try { - result = getObject(arg0) instanceof Uint8Array; - } catch { - result = false; - } - const ret = result; - return ret; - }; - imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function (arg0) { - let result; - try { - result = getObject(arg0) instanceof ArrayBuffer; - } catch { - result = false; - } - const ret = result; - return ret; - }; - imports.wbg.__wbindgen_object_clone_ref = function (arg0) { - const ret = getObject(arg0); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_debug_string = function (arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr1 = passStringToWasm0( - ret, - wasm.__wbindgen_export_0, - wasm.__wbindgen_export_1, - ); - const len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; - }; - imports.wbg.__wbindgen_throw = function (arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); - }; - - return imports; + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbg_set_bedc3d02d0f05eb0 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_string = function(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; + }; + imports.wbg.__wbindgen_error_new = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_841ac57cff3d672b = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_new_b51585de1b234aff = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbg_entries_e51f29c7bba0c054 = function(arg0) { + const ret = Object.entries(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_length_fff51ee6522a1a18 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_get_44be0491f933a435 = function(arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_new_56693dbed0c32988 = function() { + const ret = new Map(); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) { + const ret = arg0; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { + const ret = getObject(arg0) == getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_is_bigint = function(arg0) { + const ret = typeof(getObject(arg0)) === 'bigint'; + return ret; + }; + imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) { + const v = getObject(arg1); + const ret = typeof(v) === 'bigint' ? v : undefined; + getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) { + const ret = BigInt.asUintN(64, arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function(arg0) { + const ret = Number.isSafeInteger(getObject(arg0)); + return ret; + }; + imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function(arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; + }; + imports.wbg.__wbg_iterator_97f0c81209c6c35a = function() { + const ret = Symbol.iterator; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_in = function(arg0, arg1) { + const ret = getObject(arg0) in getObject(arg1); + return ret; + }; + imports.wbg.__wbg_new_898a68150f225f2e = function() { + const ret = new Array(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_502d29070ea18557 = function(arg0, arg1, arg2) { + getObject(arg0)[arg1 >>> 0] = takeObject(arg2); + }; + imports.wbg.__wbg_String_88810dfeb4021902 = function(arg0, arg1) { + const ret = String(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbg_getwithrefkey_5e6d9547403deab8 = function(arg0, arg1) { + const ret = getObject(arg0)[getObject(arg1)]; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_next_ddb3312ca1c4e32a = function() { return handleError(function (arg0) { + const ret = getObject(arg0).next(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_5c1f01fb660d73b5 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_1695675138684bd5 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_fromCodePoint_5aced4409dbb8969 = function() { return handleError(function (arg0) { + const ret = String.fromCodePoint(arg0 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_bigint_from_i128 = function(arg0, arg1) { + const ret = arg0 << BigInt(64) | BigInt.asUintN(64, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_bigint_from_u128 = function(arg0, arg1) { + const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_from_d7c216d4616bb368 = function(arg0) { + const ret = Array.from(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_next_526fc47e980da008 = function(arg0) { + const ret = getObject(arg0).next; + return addHeapObject(ret); + }; + imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Uint8Array; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof ArrayBuffer; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + + return imports; } -function __wbg_init_memory(imports, maybe_memory) {} +function __wbg_init_memory(imports, maybe_memory) { + +} function __wbg_finalize_init(instance, module) { - wasm = instance.exports; - __wbg_init.__wbindgen_wasm_module = module; - cachedBigInt64Memory0 = null; - cachedFloat64Memory0 = null; - cachedInt32Memory0 = null; - cachedUint8Memory0 = null; - - return wasm; + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + cachedBigInt64Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint8Memory0 = null; + + + return wasm; } function initSync(module) { - if (wasm !== undefined) return wasm; + if (wasm !== undefined) return wasm; - const imports = __wbg_get_imports(); + const imports = __wbg_get_imports(); - __wbg_init_memory(imports); + __wbg_init_memory(imports); - if (!(module instanceof WebAssembly.Module)) { - module = new WebAssembly.Module(module); - } + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } - const instance = new WebAssembly.Instance(module, imports); + const instance = new WebAssembly.Instance(module, imports); - return __wbg_finalize_init(instance, module); + return __wbg_finalize_init(instance, module); } async function __wbg_init(input) { - if (wasm !== undefined) return wasm; + if (wasm !== undefined) return wasm; - if (typeof input === "undefined") { - input = new URL("euclid_bg.wasm", import.meta.url); - } - const imports = __wbg_get_imports(); + if (typeof input === 'undefined') { + input = new URL('euclid_bg.wasm', import.meta.url); + } + const imports = __wbg_get_imports(); - if ( - typeof input === "string" || - (typeof Request === "function" && input instanceof Request) || - (typeof URL === "function" && input instanceof URL) - ) { - input = fetch(input); - } + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } - __wbg_init_memory(imports); + __wbg_init_memory(imports); - const { instance, module } = await __wbg_load(await input, imports); + const { instance, module } = await __wbg_load(await input, imports); - return __wbg_finalize_init(instance, module); + return __wbg_finalize_init(instance, module); } -export { initSync }; +export { initSync } export default __wbg_init; diff --git a/public/hyperswitch/wasm/euclid_bg.wasm b/public/hyperswitch/wasm/euclid_bg.wasm index 82ab15f17..7a282bb01 100644 Binary files a/public/hyperswitch/wasm/euclid_bg.wasm and b/public/hyperswitch/wasm/euclid_bg.wasm differ diff --git a/public/hyperswitch/wasm/euclid_bg.wasm.d.ts b/public/hyperswitch/wasm/euclid_bg.wasm.d.ts index e783b24d1..0c8b9d86f 100644 --- a/public/hyperswitch/wasm/euclid_bg.wasm.d.ts +++ b/public/hyperswitch/wasm/euclid_bg.wasm.d.ts @@ -2,12 +2,7 @@ /* eslint-disable */ export const memory: WebAssembly.Memory; export function setForexData(a: number, b: number): void; -export function convertCurrency( - a: number, - b: number, - c: number, - d: number, -): void; +export function convertCurrency(a: number, b: number, c: number, d: number): void; export function seedKnowledgeGraph(a: number, b: number): void; export function getValidConnectorsForRule(a: number, b: number): void; export function analyzeProgram(a: number, b: number): void; @@ -27,12 +22,7 @@ export function getDescriptionCategory(a: number, b: number, c: number): void; export function parse(a: number, b: number, c: number): void; export function parseToString(a: number, b: number, c: number): void; export function __wbindgen_export_0(a: number, b: number): number; -export function __wbindgen_export_1( - a: number, - b: number, - c: number, - d: number, -): number; +export function __wbindgen_export_1(a: number, b: number, c: number, d: number): number; export function __wbindgen_add_to_stack_pointer(a: number): number; export function __wbindgen_export_2(a: number, b: number, c: number): void; export function __wbindgen_export_3(a: number): void; diff --git a/src/libraries/Window.res b/src/libraries/Window.res index 8a326afbb..211d31224 100644 --- a/src/libraries/Window.res +++ b/src/libraries/Window.res @@ -38,6 +38,21 @@ external getConnectorConfig: string => Js.Json.t = "getConnectorConfig" @val @scope("window") external getPayoutConnectorConfig: string => Js.Json.t = "getPayoutConnectorConfig" +@val @scope("window") +external getThreeDsKeys: unit => array = "getThreeDsKeys" + +@val @scope("window") +external getAllKeys: unit => array = "getAllKeys" + +@val @scope("window") +external getKeyType: string => string = "getKeyType" + +@val @scope("window") +external getAllConnectors: unit => array = "getAllConnectors" + +@val @scope("window") +external getVariantValues: string => array = "getVariantValues" + @val @scope("window") open ConnectorTypes external getRequestPayload: (wasmRequest, wasmExtraPayload) => Js.Json.t = "getRequestPayload" diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 079bfea39..6c111366c 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -688,23 +688,41 @@ let validateNameAndDescription = (~dict, ~errors) => { }) } +let checkIfValuePresent = dict => { + let valueFromObject = dict->getDictfromDict("value") + + valueFromObject + ->getArrayFromDict("value", []) + ->Js.Array2.filter(ele => { + ele != ""->Js.Json.string + }) + ->Js.Array2.length > 0 || + valueFromObject->getString("value", "")->Js.String2.length > 0 || + valueFromObject->getFloat("value", -1.0) !== -1.0 || + (valueFromObject->getDictfromDict("value")->getString("key", "")->Js.String2.length > 0 && + valueFromObject->getDictfromDict("value")->getString("value", "")->Js.String2.length > 0) +} +let validateConditionJsonFor3ds = json => { + switch json->Js.Json.decodeObject { + | Some(dict) => + ["comparison", "lhs"]->Js.Array2.every(key => dict->Js.Dict.get(key)->Belt.Option.isSome) && + dict->checkIfValuePresent + | None => false + } +} + let validateConditions = dict => { dict ->LogicUtils.getArrayFromDict("conditions", []) ->Js.Array2.every(MakeRuleFieldComponent.validateConditionJson) } -let validateConditionsEvenIfOneExists = dict => { - let conditionsArray = dict->LogicUtils.getArrayFromDict("conditions", []) - let vector = Js.Vector.make(conditionsArray->Js.Array2.length, false) +let validateConditionsFor3ds = dict => { + let conditionsArray = dict->LogicUtils.getArrayFromDict("statements", []) - conditionsArray->Array.forEachWithIndex((value, index) => { - let res = value->MakeRuleFieldComponent.validateConditionJson - vector->Js.Vector.set(index, res) + conditionsArray->Array.every(value => { + value->validateConditionJsonFor3ds }) - - let _result = Js.Vector.filterInPlace((. val) => val == true, vector) - vector } let filterEmptyValues = (arr: array) => { diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res index cccabcc27..b147f8b23 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res @@ -45,21 +45,6 @@ module Add3DSCondition = { @react.component let make = (~isFirst, ~id) => { let classStyle = "flex justify-center relative py-2 h-fit min-w-min hover:bg-jp-2-light-gray-100 focus:outline-none rounded-md items-center border-2 border-border_gray border-opacity-50 text-jp-2-light-gray-1200 px-4 transition duration-[250ms] ease-out-[cubic-bezier(0.33, 1, 0.68, 1)] overflow-hidden" - let (dropdownval, setDropdownval) = React.useState(_ => "three_ds") - let field = ReactFinalForm.useField(`${id}.routingOutput.override_3ds`).input - - let input: ReactFinalForm.fieldRenderPropsInput = { - name: `${id}.routingOutput.override_3ds`, - onBlur: _ev => (), - onChange: ev => { - let value = ev->AdvancedRoutingUIUtils.formEventToStr - field.onChange(value->toForm) - setDropdownval(_ => value) - }, - onFocus: _ev => (), - value: dropdownval->Js.Json.string, - checked: true, - } let options: array = [ {value: "three_ds", label: "3DS"}, @@ -74,13 +59,19 @@ module Add3DSCondition = {
{"Auth type"->React.string}
{"= is Equal to"->React.string}
-
@@ -100,7 +91,7 @@ module Wrapper = { ~notFirstRule=true, ~isDragging=false, ~wasm, - ~isfrom3ds=false, + ~isFrom3ds=false, ) => { let showToast = ToastState.useShowToast() let isMobileView = MatchMedia.useMobileChecker() @@ -230,12 +221,12 @@ module Wrapper = { ${border} border-blue-700`}> - + - + - + @@ -572,65 +563,7 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => { let rulesDict = dataDict->getArrayFromDict("rules", []) - let modifiedRules = rulesDict->Js.Array2.map(ruleJson => { - let ruleDict = ruleJson->getDictFromJsonObject - let statements = ruleDict->getArrayFromDict("statements", []) - - let modifiedStatements = statements->Array.reduce( - [ - { - condition: [], - }, - ], - (acc, statement) => { - let statementDict = statement->getDictFromJsonObject - let logicalOperator = statementDict->getString("logical", "")->Js.String2.toLowerCase - - let lastItem = - acc - ->Belt.Array.get(acc->Js.Array2.length - 1) - ->Belt.Option.getWithDefault({condition: []}) - - let condition = { - lhs: statementDict->getString("lhs", ""), - comparison: switch statementDict->getString("comparison", "")->operatorMapper { - | IS - | EQUAL_TO - | CONTAINS => "equal" - | IS_NOT - | NOT_CONTAINS - | NOT_EQUAL_TO => "not_equal" - | GREATER_THAN => "greater_than" - | LESS_THAN => "less_than" - | UnknownOperator(str) => str - }, - value: statementDict->getDictfromDict("value")->getStatementValue, - metadata: statementDict->getJsonObjectFromDict("metadata"), - } - - let newAcc = if logicalOperator === "or" { - acc->Js.Array2.concat([ - { - condition: [condition], - }, - ]) - } else { - lastItem.condition->Array.push(condition) - let filteredArr = - acc->Array.filterWithIndex((_, i) => i !== acc->Js.Array2.length - 1) - filteredArr->Array.push(lastItem) - filteredArr - } - - newAcc - }, - ) - { - "name": ruleDict->getString("name", ""), - "connectorSelection": ruleDict->getJsonObjectFromDict("connectorSelection"), - "statements": modifiedStatements->Js.Array2.map(toJson)->Js.Json.array, - } - }) + let modifiedRules = rulesDict->generateRule let defaultSelection = dataDict diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res index 48c1b2341..28e1d3092 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res @@ -318,9 +318,8 @@ module FieldInp = { module RuleFieldBase = { @react.component - let make = (~isFirst, ~id, ~isExpanded, ~onClick, ~wasm) => { + let make = (~isFirst, ~id, ~isExpanded, ~onClick, ~wasm, ~isFrom3ds) => { let (hover, setHover) = React.useState(_ => false) - let (paymentMethod, setpaymentMethod) = React.useState(_ => []) let (keyType, setKeyType) = React.useState(_ => "") let (variantValues, setVariantValues) = React.useState(_ => []) let field = ReactFinalForm.useField(`${id}.lhs`).input @@ -339,20 +338,19 @@ module RuleFieldBase = { setKeyTypeAndVariants(wasm, value) } - React.useEffect0(() => { - let methodKeys = switch wasm { - | Some(res) => res.getAllKeys() - | None => [] - } + let methodKeys = React.useMemo0(() => { let value = field.value->LogicUtils.getStringFromJson("") if value->Js.String2.length > 0 { setKeyTypeAndVariants(wasm, value) } - setpaymentMethod(_ => methodKeys) - None + if isFrom3ds { + Window.getThreeDsKeys() + } else { + Window.getAllKeys() + } }) - Js.Array2.length > 0}> + Js.Array2.length > 0}> {if isExpanded {
- +
@@ -394,7 +392,7 @@ module RuleFieldBase = { module MakeRuleField = { @react.component - let make = (~id, ~isExpanded, ~wasm) => { + let make = (~id, ~isExpanded, ~wasm, ~isFrom3ds) => { let ruleJsonPath = `${id}.statements` let conditionsInput = ReactFinalForm.useField(ruleJsonPath).input let fields = conditionsInput.value->Js.Json.decodeArray->Belt.Option.getWithDefault([]) @@ -419,6 +417,7 @@ module MakeRuleField = { id={`${ruleJsonPath}[${i->Belt.Int.toString}]`} isExpanded wasm + isFrom3ds /> )->React.array} {if isExpanded { diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res index 92451c08c..0c342c5a1 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res @@ -1,11 +1,10 @@ -open LogicUtils -open AdvancedRoutingTypes +external toJson: 'a => Js.Json.t = "%identity" let getCurrentDetailedUTCTime = () => { Js.Date.fromFloat(Js.Date.now())->Js.Date.toUTCString } -let defaultThreeDsObjectValue = { +let defaultThreeDsObjectValue: AdvancedRoutingTypes.connectorSelection = { override_3ds: "three_ds", } @@ -45,6 +44,7 @@ let getRoutingTypeName = (routingType: AdvancedRoutingTypes.routing) => { } let getRoutingNameString = (~routingType) => { + open LogicUtils let routingText = routingType->getRoutingTypeName `${routingText->capitalizeString} Based Routing-${getCurrentShortUTCTime()}` } @@ -97,32 +97,38 @@ let variantTypeMapper: string => AdvancedRoutingTypes.variantType = variantType } } -let getStatementValue = valueDict => { +let getStatementValue: Js.Dict.t => AdvancedRoutingTypes.value = valueDict => { + open LogicUtils { \"type": valueDict->getString("type", ""), value: valueDict->getJsonObjectFromDict("value"), } } -let statementTypeMapper = dict => { - lhs: dict->getString("lhs", ""), - comparison: dict->getString("comparison", ""), - value: getStatementValue(dict->getDictfromDict("value")), - logical: dict->getString("logical", ""), +let statementTypeMapper: Js.Dict.t => AdvancedRoutingTypes.statement = dict => { + open LogicUtils + { + lhs: dict->getString("lhs", ""), + comparison: dict->getString("comparison", ""), + value: getStatementValue(dict->getDictfromDict("value")), + logical: dict->getString("logical", ""), + } } let conditionTypeMapper = (statementArr: array) => { + open LogicUtils let statements = statementArr->Array.reduce([], (acc, statementJson) => { let conditionArray = statementJson->getDictFromJsonObject->getArrayFromDict("condition", []) let arr = conditionArray->Js.Array2.mapi((conditionJson, index) => { let statementDict = conditionJson->getDictFromJsonObject - { + let returnValue: AdvancedRoutingTypes.statement = { lhs: statementDict->getString("lhs", ""), comparison: statementDict->getString("comparison", ""), logical: index === 0 ? "OR" : "AND", value: getStatementValue(statementDict->getDictfromDict("value")), } + returnValue }) acc->Js.Array2.concat(arr) }) @@ -131,6 +137,7 @@ let conditionTypeMapper = (statementArr: array) => { } let routingTypeMapper = (str: string) => { + open AdvancedRoutingTypes switch str->Js.String2.toLowerCase { | "priority" => PRIORITY | "volume_split" => VOLUME_SPLIT @@ -138,7 +145,10 @@ let routingTypeMapper = (str: string) => { } } -let volumeSplitConnectorSelectionDataMapper = dict => { +let volumeSplitConnectorSelectionDataMapper: Js.Dict.t< + Js.Json.t, +> => AdvancedRoutingTypes.volumeSplitConnectorSelectionData = dict => { + open LogicUtils { split: dict->getInt("split", 0), connector: { @@ -150,14 +160,18 @@ let volumeSplitConnectorSelectionDataMapper = dict => { } } -let priorityConnectorSelectionDataMapper = dict => { +let priorityConnectorSelectionDataMapper: Js.Dict.t< + Js.Json.t, +> => AdvancedRoutingTypes.connector = dict => { + open LogicUtils { connector: dict->getString("connector", ""), merchant_connector_id: dict->getString("merchant_connector_id", ""), } } -let connectorSelectionDataMapperFromJson: Js.Json.t => connectorSelectionData = json => { +let connectorSelectionDataMapperFromJson: Js.Json.t => AdvancedRoutingTypes.connectorSelectionData = json => { + open LogicUtils let split = json->getDictFromJsonObject->getOptionInt("split") let dict = json->getDictFromJsonObject switch split { @@ -169,15 +183,25 @@ let connectorSelectionDataMapperFromJson: Js.Json.t => connectorSelectionData = let getDefaultSelection: Js.Dict.t< Js.Json.t, > => AdvancedRoutingTypes.connectorSelection = defaultSelection => { - { - \"type": defaultSelection->getString("type", ""), - data: defaultSelection - ->getArrayFromDict("data", []) - ->Js.Array2.map(ele => ele->connectorSelectionDataMapperFromJson), + open LogicUtils + let override3dsValue = defaultSelection->getString("override_3ds", "") + + if override3dsValue->Js.String2.length > 0 { + { + override_3ds: override3dsValue, + } + } else { + { + \"type": defaultSelection->getString("type", ""), + data: defaultSelection + ->getArrayFromDict("data", []) + ->Js.Array2.map(ele => ele->connectorSelectionDataMapperFromJson), + } } } let getConnectorStringFromConnectorSelectionData = connectorSelectionData => { + open AdvancedRoutingTypes switch connectorSelectionData { | VolumeObject(obj) => { merchant_connector_id: obj.connector.merchant_connector_id, @@ -191,13 +215,15 @@ let getConnectorStringFromConnectorSelectionData = connectorSelectionData => { } let getSplitFromConnectorSelectionData = connectorSelectionData => { + open AdvancedRoutingTypes switch connectorSelectionData { | VolumeObject(obj) => obj.split | _ => 0 } } -let ruleInfoTypeMapper = json => { +let ruleInfoTypeMapper: Js.Dict.t => AdvancedRoutingTypes.algorithmData = json => { + open LogicUtils let rulesArray = json->getArrayFromDict("rules", []) let defaultSelection = json->getDictfromDict("defaultSelection") @@ -251,6 +277,7 @@ let getGatewaysArrayFromValueData = data => { } let getModalObj = (routingType, text) => { + open AdvancedRoutingTypes switch routingType { | ADVANCED => { conType: "Activate current configured configuration?", @@ -301,14 +328,16 @@ let isStatementMandatoryFieldsPresent = (statement: AdvancedRoutingTypes.stateme statementValue) } -let algorithmTypeMapper = values => { +let algorithmTypeMapper: Js.Dict.t => AdvancedRoutingTypes.algorithm = values => { + open LogicUtils { data: values->getDictfromDict("data")->ruleInfoTypeMapper, \"type": values->getString("type", ""), } } -let getRoutingTypesFromJson = (values: Js.Json.t) => { +let getRoutingTypesFromJson: Js.Json.t => AdvancedRoutingTypes.advancedRouting = values => { + open LogicUtils let valuesDict = values->getDictFromJsonObject { @@ -321,3 +350,68 @@ let getRoutingTypesFromJson = (values: Js.Json.t) => { let validateStatements = statementsArray => { statementsArray->Js.Array2.every(isStatementMandatoryFieldsPresent) } + +let generateStatements = statements => { + open LogicUtils + + let initialValueForStatement: AdvancedRoutingTypes.statementSendType = { + condition: [], + } + + statements->Array.reduce([initialValueForStatement], (acc, statement) => { + let statementDict = statement->getDictFromJsonObject + let logicalOperator = statementDict->getString("logical", "")->Js.String2.toLowerCase + + let lastItem = + acc->Belt.Array.get(acc->Js.Array2.length - 1)->Belt.Option.getWithDefault({condition: []}) + + let condition: AdvancedRoutingTypes.statement = { + lhs: statementDict->getString("lhs", ""), + comparison: switch statementDict->getString("comparison", "")->operatorMapper { + | IS + | EQUAL_TO + | CONTAINS => "equal" + | IS_NOT + | NOT_CONTAINS + | NOT_EQUAL_TO => "not_equal" + | GREATER_THAN => "greater_than" + | LESS_THAN => "less_than" + | UnknownOperator(str) => str + }, + value: statementDict->getDictfromDict("value")->getStatementValue, + metadata: statementDict->getJsonObjectFromDict("metadata"), + } + + let newAcc = if logicalOperator === "or" { + acc->Js.Array2.concat([ + { + condition: [condition], + }, + ]) + } else { + lastItem.condition->Array.push(condition) + let filteredArr = acc->Array.filterWithIndex((_, i) => i !== acc->Js.Array2.length - 1) + filteredArr->Array.push(lastItem) + filteredArr + } + + newAcc + }) +} + +let generateRule = rulesDict => { + let modifiedRules = rulesDict->Js.Array2.map(ruleJson => { + open LogicUtils + let ruleDict = ruleJson->getDictFromJsonObject + let statements = ruleDict->getArrayFromDict("statements", []) + + let modifiedStatements = statements->generateStatements + + { + "name": ruleDict->getString("name", ""), + "connectorSelection": ruleDict->getJsonObjectFromDict("connectorSelection"), + "statements": modifiedStatements->Js.Array2.map(toJson)->Js.Json.array, + } + }) + modifiedRules +} diff --git a/src/screens/HyperSwitch/RoutingRevamp/Previewers/RulePreviewer.res b/src/screens/HyperSwitch/RoutingRevamp/Previewers/RulePreviewer.res index a85510891..7686ad9b7 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/Previewers/RulePreviewer.res +++ b/src/screens/HyperSwitch/RoutingRevamp/Previewers/RulePreviewer.res @@ -28,7 +28,7 @@ module GatewayView = { } @react.component -let make = (~ruleInfo: algorithmData, ~isfrom3ds=false) => { +let make = (~ruleInfo: algorithmData, ~isFrom3ds=false) => { open LogicUtils
{ let value = switch statement.value.value->Js.Json.classify { | JSONArray(arr) => arr->Js.Array2.joinWith(", ") | JSONString(str) => str + | JSONNumber(num) => num->Belt.Float.toString | _ => "" } @@ -97,13 +98,13 @@ let make = (~ruleInfo: algorithmData, ~isfrom3ds=false) => { Js.Array2.length > 0}> - +
{threeDsType->LogicUtils.capitalizeString->React.string}
- + Belt.Option.getWithDefault([])} /> diff --git a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res index c7e55f912..50da84b8b 100644 --- a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res +++ b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res @@ -9,7 +9,12 @@ module ActiveRulePreview = { let ruleInfo = initialRule->Belt.Option.getWithDefault(Js.Dict.empty()) let name = ruleInfo->getString("name", "") let description = ruleInfo->getString("description", "") - let ruleInfo = ruleInfo->getJsonObjectFromDict("rules")->RoutingUtils.ruleInfoTypeMapper + + let ruleInfo = + ruleInfo + ->getJsonObjectFromDict("algorithm") + ->getDictFromJsonObject + ->AdvancedRoutingUtils.ruleInfoTypeMapper Belt.Option.isSome}>
@@ -25,7 +30,7 @@ module ActiveRulePreview = { {description->React.string}

- +
} @@ -34,7 +39,7 @@ module ActiveRulePreview = { module Configure3DSRule = { @react.component let make = (~wasm) => { - let ruleInput = ReactFinalForm.useField("json.rules").input + let ruleInput = ReactFinalForm.useField("algorithm.rules").input let (rules, setRules) = React.useState(_ => ruleInput.value->LogicUtils.getArrayFromJson([])) React.useEffect1(() => { ruleInput.onChange(rules->arrToFormEvent) @@ -58,7 +63,7 @@ module Configure3DSRule = { let notFirstRule = ruleInput.value->LogicUtils.getArrayFromJson([])->Js.Array2.length > 1 let rule = ruleInput.value->Js.Json.decodeArray->Belt.Option.getWithDefault([]) let keyExtractor = (index, _rule, isDragging) => { - let id = {`json.rules[${string_of_int(index)}]`} + let id = {`algorithm.rules[${string_of_int(index)}]`} let i = 1 } if notFirstRule { @@ -98,9 +103,7 @@ let make = () => { let fetchDetails = useGetMethod(~showErrorToast=false, ()) let updateDetails = useUpdateMethod(~showErrorToast=false, ()) let (wasm, setWasm) = React.useState(_ => None) - let (initialValues, _setInitialValues) = React.useState(_ => - buildInitial3DSValue->Js.Json.object_ - ) + let (initialValues, _setInitialValues) = React.useState(_ => buildInitial3DSValue->toJson) let (initialRule, setInitialRule) = React.useState(() => None) let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let (pageView, setPageView) = React.useState(_ => NEW) @@ -123,18 +126,14 @@ let make = () => { try { let threeDsUrl = getURL(~entityName=THREE_DS, ~methodType=Get, ()) let threeDsRuleDetail = await fetchDetails(threeDsUrl) - let schemaValue = - threeDsRuleDetail - ->getDictFromJsonObject - ->getObj("program", Js.Dict.empty()) - ->getObj("metadata", Js.Dict.empty()) - ->getObj("schema", Js.Dict.empty()) + let responseDict = threeDsRuleDetail->getDictFromJsonObject + let programValue = responseDict->getObj("program", Js.Dict.empty()) let intitialValue = [ - ("name", schemaValue->LogicUtils.getString("name", "")->Js.Json.string), - ("description", schemaValue->LogicUtils.getString("description", "")->Js.Json.string), - ("rules", schemaValue->LogicUtils.getObj("json", Js.Dict.empty())->Js.Json.object_), + ("name", responseDict->LogicUtils.getString("name", "")->Js.Json.string), + ("description", responseDict->LogicUtils.getString("description", "")->Js.Json.string), + ("algorithm", programValue->Js.Json.object_), ]->Js.Dict.fromArray setInitialRule(_ => Some(intitialValue)) @@ -183,24 +182,10 @@ let make = () => { let onSubmit = async (values, _) => { try { setScreenState(_ => Loading) - let dict = values->LogicUtils.getDictFromJsonObject - - let json = dict->LogicUtils.getJsonObjectFromDict("json")->LogicUtils.getDictFromJsonObject - - let description = dict->LogicUtils.getString("description", "") - let name = dict->LogicUtils.getString("name", "") - - let metadata = - [ - ("name", name->Js.Json.string), - ("description", description->Js.Json.string), - ("schema", dict->Js.Json.object_), - ]->Js.Dict.fromArray - - let threeDsPayload = buildThreeDsPayloadBody(json, wasm, metadata, name) + let threeDsPayload = values->buildThreeDsPayloadBody let getActivateUrl = getURL(~entityName=THREE_DS, ~methodType=Put, ()) - let _response = await updateDetails(getActivateUrl, threeDsPayload->Js.Json.object_, Put) + let _response = await updateDetails(getActivateUrl, threeDsPayload->toJson, Put) fetchDetails()->ignore setShowWarning(_ => true) RescriptReactRouter.replace(`/3ds`) @@ -221,7 +206,7 @@ let make = () => { RoutingUtils.validateNameAndDescription(~dict, ~errors) - switch dict->Js.Dict.get("json")->Belt.Option.flatMap(Js.Json.decodeObject) { + switch dict->Js.Dict.get("algorithm")->Belt.Option.flatMap(Js.Json.decodeObject) { | Some(jsonDict) => { let index = 1 let rules = jsonDict->LogicUtils.getArrayFromDict("rules", []) @@ -230,9 +215,9 @@ let make = () => { } else { rules->Array.forEachWithIndex((rule, i) => { let ruleDict = rule->LogicUtils.getDictFromJsonObject - if RoutingUtils.validateConditionsEvenIfOneExists(ruleDict)->Js.Array2.length == 0 { + if !RoutingUtils.validateConditionsFor3ds(ruleDict) { errors->Js.Dict.set( - `Rule ${(i + index)->string_of_int} - Condition`, + `Rule ${(i + 1)->string_of_int} - Condition`, `Invalid`->Js.Json.string, ) } diff --git a/src/screens/HyperSwitch/ThreeDSFlow/ThreeDSUtils.res b/src/screens/HyperSwitch/ThreeDSFlow/ThreeDSUtils.res index 42d2fda37..dd71cc234 100644 --- a/src/screens/HyperSwitch/ThreeDSFlow/ThreeDSUtils.res +++ b/src/screens/HyperSwitch/ThreeDSFlow/ThreeDSUtils.res @@ -1,55 +1,51 @@ -external toJson: 'a => array = "%identity" -type conditonType = { - \"logical.operator"?: string, - field: string, - real_field: string, - operator: string, - value: string, -} +external toJson: 'a => Js.Json.t = "%identity" type pageState = NEW | LANDING -open RoutingUtils -let conditions: array = [ +let statementObject: array = [ { - field: "amount", - real_field: "amount", - operator: "EQUAL TO", - value: "", + lhs: "amount", + value: { + \"type": "number", + value: ""->Js.Json.string, + }, + comparison: "EQUAL TO", }, { - \"logical.operator": "AND", - field: "currency", - real_field: "currency", - operator: "IS", - value: "", + logical: "AND", + value: { + \"type": "number", + value: ""->Js.Json.string, + }, + lhs: "currency", + comparison: "IS", }, ] -let constructNameDescription = - [ - ("name", `3DS Rule-${getCurrentUTCTime()}`->Js.Json.string), - ("description", `This is a Three-Ds Rule created at ${currentTimeInUTC}`->Js.Json.string), - ]->Js.Dict.fromArray - -let buildInitial3DSValue = { - let routingValueOutput = [("override_3ds", "three_ds"->Js.Json.string)]->Js.Dict.fromArray - let defaultValue = - [ - ("gateways", []->Js.Json.array), - ("conditions", conditions->toJson->Js.Json.array), - ("routingOutput", routingValueOutput->Js.Json.object_), - ]->Js.Dict.fromArray - - let initialJson = [("rules", [defaultValue->Js.Json.object_]->Js.Json.array)]->Js.Dict.fromArray - - let initialValueJson = constructNameDescription +type threeDsRoutingType = { + name: string, + description: string, + algorithm: AdvancedRoutingTypes.algorithmData, +} - initialValueJson->Js.Dict.set("json", initialJson->Js.Json.object_) - initialValueJson->Js.Dict.set("code", ""->Js.Json.string) +let rules: AdvancedRoutingTypes.rule = { + name: "rule_1", + connectorSelection: { + override_3ds: "three_ds", + }, + statements: statementObject, +} - // initialValueJson->Js.Dict.set("routingOutput", routingValueOutput->Js.Json.object_) - initialValueJson +let buildInitial3DSValue: threeDsRoutingType = { + name: `3DS Rule-${RoutingUtils.getCurrentUTCTime()}`, + description: `This is a Three-Ds Rule created at ${RoutingUtils.currentTimeInUTC}`, + algorithm: { + rules: [rules], + defaultSelection: { + override_3ds: "", + }, + metadata: Js.Json.null, + }, } let pageStateMapper = pageType => { @@ -59,58 +55,37 @@ let pageStateMapper = pageType => { } } -let generateRule = (index, statement, ~threeDsValue, ()) => { - let ruleObj = Js.Dict.fromArray([ - ("name", `rule_${string_of_int(index + 1)}`->Js.Json.string), - ("statements", statement->Js.Json.array), - ]) - ruleObj->Js.Dict.set("routingOutput", threeDsValue->Js.Json.object_) - ruleObj -} -let constuctAlgorithmValue = (rules, metadata) => { +let constuctAlgorithmValue = rules => { let defaultSelection = [("override_3ds", Js.Json.null)]->Js.Dict.fromArray let algorithm = [ ("defaultSelection", defaultSelection->Js.Json.object_), ("rules", rules->Js.Json.array), - ("metadata", metadata->Js.Json.object_), ]->Js.Dict.fromArray algorithm } -let buildThreeDsPayloadBody = (dict, wasm, metadata, name) => { +let buildThreeDsPayloadBody = values => { open LogicUtils - let threeDsPayload = [("name", name->Js.Json.string)]->Js.Dict.fromArray - - let rules = [] - - let _payload = - dict - ->getArrayFromDict("rules", []) - ->Array.reduceWithIndex([], (acc, priorityLogicObj, index) => { - switch priorityLogicObj->Js.Json.decodeObject { - | Some(priorityLogicObj) => { - let statement = generateStatement( - priorityLogicObj->getArrayFromDict("conditions", []), - wasm, - ) - let threeDsValue = priorityLogicObj->getObj("routingOutput", Js.Dict.empty()) - - let ruleObj = generateRule(index, statement, ~threeDsValue, ()) - rules->Array.push(ruleObj->Js.Json.object_) - } - - | None => () - } - acc - }) - - let algorithm = constuctAlgorithmValue(rules, metadata) - - threeDsPayload->Js.Dict.set("algorithm", algorithm->Js.Json.object_) + let valuesDict = values->getDictFromJsonObject + let dataDict = valuesDict->getDictfromDict("algorithm") + let rulesDict = dataDict->getArrayFromDict("rules", []) + + let modifiedRules = rulesDict->AdvancedRoutingUtils.generateRule + + let threeDsPayload = { + "name": valuesDict->getString("name", ""), + "algorithm": { + "defaultSelection": { + "override_3ds": null, + }, + "rules": modifiedRules, + "metadata": Js.Dict.empty()->Js.Json.object_, + }, + } threeDsPayload }