UNPKG

react-native-ibm-mobilefirst-jsonstore

Version:

React Native SDK for IBM JSONStore. Works with IBM Mobile First

92 lines (78 loc) 2.88 kB
/* Licensed Materials - Property of IBM * 5725-I43 (C) Copyright IBM Corp. 2018. All Rights Reserved. * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* author - Yash Soni | yashsoni21@in.ibm.com */ import { _checkParamType, ParamTypes, _mandatoryParam, _checkParamClassType } from './Utils' import JSONStoreSyncPolicy from './JSONStoreSyncPolicy' /** * Options that are used to modify the init operation in WLJSONStore. */ class JSONStoreInitOptions { /** * @type {string} */ username; /** * @type {string} */ password; /** * @type {boolean} */ enableAnalytics; /** * @type {string} */ secureRandom; /** * @type {number} */ pbkdf2Iterations; /** * @type {string} */ syncAdapterPath; /** * @type {JSONStoreSyncPolicy} */ syncPolicy; /** * Constructor to initialize JSONStoreInitOptions * @param {string} [username] - The user name * @param {string} [password] - The password to be used for the store. * @param {boolean} [enableAnalytics] - When true, analytics will be logged for JSONStore. * @param {string} [secureRandom] - The secure random string to be used by security artifacts. * @param {number} [pbkdf2Iterations] */ constructor(username = null, password = "", enableAnalytics = false, secureRandom = null, pbkdf2Iterations = 10000) { if (username) { _checkParamType(username, ParamTypes.STRING); } this.username = username this.password = password; this.enableAnalytics = enableAnalytics; this.secureRandom = secureRandom; this.pbkdf2Iterations = pbkdf2Iterations; this.syncAdapterPath = ""; this.syncPolicy = JSONStoreSyncPolicy.SYNC_NONE.type; } /** * Set Synchronization Options for the collection set * @param {JSONStoreSyncPolicy} syncPolicy - Must be either of ['SYNC_NONE', 'SYNC_DOWNSTREAM', 'SYNC_UPSTREAM'] * @param {string} syncAdapterPath - Name of the Sync Adapter */ setSyncOptions(syncPolicy = _mandatoryParam('syncPolicy'), syncAdapterPath = _mandatoryParam('syncAdapterPath')) { _checkParamClassType(syncPolicy, JSONStoreSyncPolicy); _checkParamType(syncAdapterPath, 'string'); if (syncPolicy.type != JSONStoreSyncPolicy.SYNC_NONE.type && syncPolicy.type != JSONStoreSyncPolicy.SYNC_DOWNSTREAM.type && syncPolicy.type != JSONStoreSyncPolicy.SYNC_UPSTREAM.type) { return new Error("SyncPolicy must be either of: ['SYNC_NONE', 'SYNC_DOWNSTREAM', 'SYNC_UPSTREAM']"); } this.syncPolicy = syncPolicy.type; this.syncAdapterPath = syncAdapterPath; } } export default JSONStoreInitOptions