-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystemData.js
More file actions
5 lines (4 loc) · 7.66 KB
/
Copy pathsystemData.js
File metadata and controls
5 lines (4 loc) · 7.66 KB
1
2
3
4
5
/* mobilecaddy-utils - v3.2.1 - Bundle Time: 2024-10-22 11:36:49 */
/* git info: "2024-10-22 11:34:11 +0100": 4b69821f8a37db692d32cb588a22dc57e260d69b (v3) */
/* Copyright 2024 MobileCaddy Ltd */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createSystemDataSoup=createSystemDataSoup,exports.getRecordTypeDots=getRecordTypeDots;var smartstore,mobileCaddy=_interopRequireWildcard(require("./constants")),logger=_interopRequireWildcard(require("./logger")),appDataUtils=_interopRequireWildcard(require("./appDataUtils"));function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};o.get||o.set?Object.defineProperty(t,r,o):t[r]=e[r]}return t.default=e,t}function useSdkReq(){return!(!window[mobileCaddy.CONTAINER_VSN_KEY]||!window[mobileCaddy.CONTAINER_VSN_KEY].startsWith("3"))}var USE_FORCETK=!!window.USE_FORCETK;function getQueryAndSoupDefinition(e,t,r){var o=[],a="Select ";e.forEach(function(e){o.push({path:e.Column_Name,type:e.Column_Type}),0!==e.Column_Name.indexOf("_")&&(a+=e.Column_Name+",")}),a=a.substring(0,a.length-1),t(a+=" From "+e[0].Name,o)}function populateSysDataSoupVariables(e,t,r,o){var a=function(e,t){if(t.status){var a=JSON.parse(e);(window.smartstore?window.smartstore:cordova.require("com.salesforce.plugin.smartstore")).upsertSoupEntries("syncLib_system_data",a,r,o)}else"exception"===t.type?(alert(t.message),logger.error("Exception return from getSystemDataRowValues = "+t.message)):logger.error("Unknown return from getSystemDataRowValues = "+t.message)};useSdkReq()?plugin.mcsdk.request({method:"POST",path:"/services/apexrest/mobilecaddy1/getSysDataSoupVariables001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,systemDataPlatformSupportVersion:t}},function(e){var t={status:e.status};a(JSON.parse(e.data),t)},o):!0===USE_FORCETK?force.request({method:"POST",path:"/services/apexrest/mobilecaddy1/getSysDataSoupVariables001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,systemDataPlatformSupportVersion:t}},function(e){var t={status:"200"};a(e,t)},o):Visualforce.remoting.Manager.invokeAction("mobilecaddy1."+mobileCaddy.START_PAGE_CONTROLLER+".getSysDataSoupVariables",e,t,a,{escape:!1})}function createSystemDataSoup(e,t,r,o){getSystemDataSoupDefinition(r,o,e,t)}function getSystemDataSoupDefinition(e,t,r,o){var a=function(a,s){if(s.status){var n=JSON.parse(a);n.forEach(function(e){}),(window.smartstore?window.smartstore:cordova.require("com.salesforce.plugin.smartstore")).registerSoup("syncLib_system_data",n,function(){populateSysDataSoupVariables(e,t,function(){populateDefsForSObjectMobileTables(e,t,r,o)},o)},o)}else"exception"===s.type?(alert(s.message),logger.error("Exception return from getSystemDataSoupDefinition = "+s.message)):logger.error("Unknown return from getSystemDataSoupDefinition = "+s.message)};useSdkReq()?plugin.mcsdk.request({method:"POST",path:"/services/apexrest/mobilecaddy1/getSystemDataSoupDefinition001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,systemDataPlatformSupportVersion:t}},function(e){var t={status:e.status};a(JSON.parse(e.data),t)},o):!0===USE_FORCETK?force.request({method:"POST",path:"/services/apexrest/mobilecaddy1/getSystemDataSoupDefinition001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,systemDataPlatformSupportVersion:t}},function(e){var t={status:"200"};a(e,t)},o):Visualforce.remoting.Manager.invokeAction("mobilecaddy1."+mobileCaddy.START_PAGE_CONTROLLER+".getSystemDataSoupDefinition",e,t,a,{escape:!1})}function populateDefsForSObjectMobileTables(e,t,r,o){var a=function(e,t){if(t.status){var a=JSON.parse(e);(window.smartstore?window.smartstore:cordova.require("com.salesforce.plugin.smartstore")).upsertSoupEntries("syncLib_system_data",a,function(e){r(e)},function(e){logger.error("Error returned from upsert, message = "+e),o(e)})}else"exception"===t.type?(alert(t.message),logger.error("Exception return from getDefsForSObjectMobileTables = "+t.message)):logger.error("Unknown return from getDefsForSObjectMobileTables = "+t.message)};useSdkReq()?plugin.mcsdk.request({method:"POST",path:"/services/apexrest/mobilecaddy1/getDefsForSObjectMobileTables001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,systemDataPlatformSupportVersion:t}},function(e){var t={status:e.status};a(JSON.parse(e.data),t)},o):!0===USE_FORCETK?force.request({method:"POST",path:"/services/apexrest/mobilecaddy1/getDefsForSObjectMobileTables001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,systemDataPlatformSupportVersion:t}},function(e){var t={status:"200"};a(e,t)},o):Visualforce.remoting.Manager.invokeAction("mobilecaddy1."+mobileCaddy.START_PAGE_CONTROLLER+".getDefsForSObjectMobileTables",e,t,a,{escape:!1,timeout:12e4})}function getRecordTypeDots(e,t,r){return new Promise(function(o,a){r||(r=1);var s,n=window.smartstore?window.smartstore:cordova.require("com.salesforce.plugin.smartstore"),i=function(e,t){if(t.status){n.registerSoup("dotsRecordTypes",[{path:"Table",type:"string"},{path:"Data",type:"string"}],function(t){var r=JSON.parse(e).map(function(e){return{Table:e.mobileTableName,Data:JSON.stringify(e.recTypeInfoList)}});n.upsertSoupEntries("dotsRecordTypes",r,function(t){var r={};JSON.parse(e).forEach(function(e){var t={};e.recTypeInfoList.forEach(function(e){e.recTypeDevName?(t[e.recTypeId]={recTypeName:e.recTypeName,recTypeDevName:e.recTypeDevName},t[e.recTypeName]=e.recTypeId,t[e.recTypeDevName]=e.recTypeId):(t[e.recTypeId]=e.recTypeName,t[e.recTypeName]=e.recTypeId)}),r[e.mobileTableName]=t}),localStorage.setItem("lsDotsRecordTypes",JSON.stringify(r)),o()},function(e){logger.error("Error returned from upsert, message = "+e),a(e)})},function(e){a(e)})}else"exception"===t.type?(logger.error("Exception return from p2mRefreshRecTypeDOTs = "+t.message),a(t.message)):(logger.error("Unknown return from p2mRefreshRecTypeDOTs = "+t.message),a(t.message))};r<3?appDataUtils.getCachedCurrentValueFromAppSoup("syncRefreshVersion").then(function(a){s=a,useSdkReq()?plugin.mcsdk.request({method:"POST",path:"/services/apexrest/mobilecaddy1/p2mRefreshRecTypeDOTs001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,syncRefreshDataVersion:s,connSessJson:"{}"}},function(e){var t={status:e.status};i(JSON.parse(e.data),t)},function(a){logger.error("p2mRefreshRecTypeDOTs001 response",a),setTimeout(function(a){getRecordTypeDots(e,t,r+1).then(function(){o()}).catch(function(e){logger.error("Retry loop error",e),o()})},5e3)}):!0===USE_FORCETK?force.request({method:"POST",path:"/services/apexrest/mobilecaddy1/p2mRefreshRecTypeDOTs001",contentType:"application/json",data:{audId:e,startPageControllerVersion:mobileCaddy.START_PAGE_CONTROLLER_VSN,syncRefreshDataVersion:s,connSessJson:"{}"}},function(e){var t={status:"200"};i(e,t)},function(e){i("[]",{status:"OK"})}):Visualforce.remoting.Manager.getAction("mobilecaddy1."+mobileCaddy.START_PAGE_CONTROLLER+".p2mRefreshRecTypeDOTs")?Visualforce.remoting.Manager.invokeAction("mobilecaddy1."+mobileCaddy.START_PAGE_CONTROLLER+".p2mRefreshRecTypeDOTs",e,s,"{}",i,{escape:!1,timeout:12e4}):i("[]",{status:"OK"})}):(logger.error("getRecordTypeDots: MAX RETRIES"),alert("Communication error!\nThe install has failed due to inconsistent internet connection.\nYou will need to uninstall and reinstall the application."))})}