Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
case ACTION_RULE_TYPE_BOOLEAN: {
tmpResult = ruleData;
break;
}
case ACTION_RULE_TYPE_REGEX: {
const regexParts = ruleData.split('/');
let regexPattern = '';
let regexParam = '';
if (regexParts.length === 1) {
[regexPattern] = regexParts;
} else if (regexParts.length === 3) {
regexParts.shift();
[regexPattern, regexParam = ''] = regexParts;
} else {
logger.error(`Error: Invalid regex string in action rule in element ${element.id}`);
break;
}
const regex = new RegExp(regexPattern, regexParam);
tmpResult = regex.test(nextState.formData[rule.context]);
break;
}
default: break;
}
// Concat rules based on the rule concat method of the action
result = concatRules(result, tmpResult);
});
init({ locales, lang }) {
if (didInit) {
logger.warn('Looks like i18n locales are already inited. Changing locales now may lead to inconsistent translations.');
}
didInit = true;
this.text = getTranslator(locales, lang);
this.price = getPriceFormatter(lang);
this.date = getDateFormatter(lang);
this.time = getTimeFormatter(lang);
this.number = getNumberFormatter(lang);
// If component decides to act accordingly this information should be exposed.
this.ready = true;
},
text: notReadyCb,
// Suppress errors globally
pipelineManager.addSuppressedErrors([
errorCodes.EACCESS,
errorCodes.ENOTFOUND,
errorCodes.EVALIDATION,
]);
// Map the error events into the Observable streams.
errorEmitter.addListener(SOURCE_APP, error => dispatch(appError(error)));
errorEmitter.addListener(SOURCE_PIPELINE, error => dispatch(pipelineError(error)));
/** @returns {*} */
const viewVisibility = () => events.emit(UI_VISIBILITY_CHANGE);
event.addCallback('routeDidChange', viewVisibility);
event.addCallback(APP_EVENT_VIEW_DID_DISAPPEAR, () => {
dispatch(pwaDidDisappear());
viewVisibility();
});
event.addCallback(APP_EVENT_VIEW_DID_APPEAR, () => {
dispatch(pwaDidAppear());
clearUpInAppBrowser(isAndroid(getState()));
});
});
pipelineManager.addSuppressedErrors([
errorCodes.EACCESS,
errorCodes.ENOTFOUND,
errorCodes.EVALIDATION,
]);
// Map the error events into the Observable streams.
errorEmitter.addListener(SOURCE_APP, error => dispatch(appError(error)));
errorEmitter.addListener(SOURCE_PIPELINE, error => dispatch(pipelineError(error)));
/** @returns {*} */
const viewVisibility = () => events.emit(UI_VISIBILITY_CHANGE);
event.addCallback('routeDidChange', viewVisibility);
event.addCallback(APP_EVENT_VIEW_DID_DISAPPEAR, () => {
dispatch(pwaDidDisappear());
viewVisibility();
});
event.addCallback(APP_EVENT_VIEW_DID_APPEAR, () => {
dispatch(pwaDidAppear());
clearUpInAppBrowser(isAndroid(getState()));
});
});
const values = childrenArray.reduce((obj, child) => (child.props && child.props.forKey ? {
...obj,
[child.props.forKey]: separator,
} : obj), { ...params });
// Split the tokenized string at the separators.
const stringParts = i18n.text(string, values).split(separator);
// Create a new array containing the separated chunks of the text and merge the substitutions.
formatted = stringParts.reduce((result, text, index) => [
...result,
text,
childrenArray[index],
], []);
} catch (e) {
logger.error('i18n error for string %s', string, e);
}
return (
<span role="{role}">{formatted}</span>
);
};
onWillReplace(({ prev, next }) => dispatch(routeWillReplace(prev, next)));
onDidReplace(({ prev, next }) => dispatch(routeDidReplace(prev, next)));
onWillReset(({ prev, next }) => dispatch(routeWillReset(prev, next)));
onDidReset(({ prev, next }) => dispatch(routeDidReset(prev, next)));
onUpdate(updated => dispatch(routeDidUpdate(updated)));
// Suppress errors globally
pipelineManager.addSuppressedErrors([
errorCodes.EACCESS,
errorCodes.ENOTFOUND,
errorCodes.EVALIDATION,
]);
// Map the error events into the Observable streams.
errorEmitter.addListener(SOURCE_APP, error => dispatch(appError(error)));
errorEmitter.addListener(SOURCE_PIPELINE, error => dispatch(pipelineError(error)));
/** @returns {*} */
const viewVisibility = () => events.emit(UI_VISIBILITY_CHANGE);
event.addCallback('routeDidChange', viewVisibility);
event.addCallback(APP_EVENT_VIEW_DID_DISAPPEAR, () => {
dispatch(pwaDidDisappear());
viewVisibility();
});
event.addCallback(APP_EVENT_VIEW_DID_APPEAR, () => {
dispatch(pwaDidAppear());
clearUpInAppBrowser(isAndroid(getState()));
});
});
onDidPop(({ prev, next }) => dispatch(routeDidPop(prev, next)));
onWillReplace(({ prev, next }) => dispatch(routeWillReplace(prev, next)));
onDidReplace(({ prev, next }) => dispatch(routeDidReplace(prev, next)));
onWillReset(({ prev, next }) => dispatch(routeWillReset(prev, next)));
onDidReset(({ prev, next }) => dispatch(routeDidReset(prev, next)));
onUpdate(updated => dispatch(routeDidUpdate(updated)));
// Suppress errors globally
pipelineManager.addSuppressedErrors([
errorCodes.EACCESS,
errorCodes.ENOTFOUND,
errorCodes.EVALIDATION,
]);
// Map the error events into the Observable streams.
errorEmitter.addListener(SOURCE_APP, error => dispatch(appError(error)));
errorEmitter.addListener(SOURCE_PIPELINE, error => dispatch(pipelineError(error)));
/** @returns {*} */
const viewVisibility = () => events.emit(UI_VISIBILITY_CHANGE);
event.addCallback('routeDidChange', viewVisibility);
event.addCallback(APP_EVENT_VIEW_DID_DISAPPEAR, () => {
dispatch(pwaDidDisappear());
viewVisibility();
});
event.addCallback(APP_EVENT_VIEW_DID_APPEAR, () => {
dispatch(pwaDidAppear());
clearUpInAppBrowser(isAndroid(getState()));
});
}
return null;
}
// Fire the onBeforeDispatch callback to inform a caller that fetchProducts will return data.
onBeforeDispatch();
dispatch(requestProducts({
hash,
cached,
cachedTime,
requestParams,
}));
return new PipelineRequest(pipeline)
.setInput(requestParams)
.dispatch()
.then((response) => {
let totalResultCount = response.totalProductCount;
/**
* When the next check was written, getHighlightProducts and getLiveshoppingProducts
* didn't deliver a totalProductCount within their responses - they simply returned all
* available products.
* So we set the products count of the response as totalProductCount to decrease the
* amount of logic, which is necessary to deal with product related pipelines.
*/
if (
typeof totalResultCount === 'undefined' &&
(
pipeline === pipelines.SHOPGATE_CATALOG_GET_HIGHLIGHT_PRODUCTS ||
return new Promise((resolve, reject) => {
if (shouldFetchData(getEntryByType(URL_TYPE_REGISTER, state), 'url')) {
dispatch(requestUrl(URL_TYPE_REGISTER));
new PipelineRequest('shopgate.user.getRegistrationUrl')
.setTrusted()
.dispatch()
.then(({ url, expires }) => {
dispatch(receiveUrl(URL_TYPE_REGISTER, url, expires));
resolve(url);
})
.catch((error) => {
logger.error(error);
dispatch(errorUrl(URL_TYPE_REGISTER));
reject();
});
} else {
// The registrationUrl is still valid
resolve(getRegisterUrl(state));
}
});
registerEvents([
'showPreviousTab',
'closeInAppBrowser',
// TODO The iOS apps don't emit the event to the webviews without registration till Lib 15.2.
// This needs to be removed, when IOS-1886 is done and the the iOS apps are updated.
'httpResponse',
]);
// Add event callbacks
event.addCallback('pageContext', pageContext);
event.addCallback('showPreviousTab', showPreviousTab);
/**
* This event is triggered form the desktop shop in the inAppBrowser.
* We have to close the inAppBrowser and redirect the user to the given url.
*/
event.addCallback('closeInAppBrowser', (data = {}) => {
if (data.redirectTo) {
new ParsedLink(data.redirectTo).open();
}
closeInAppBrowser(isAndroid(getState()));
});
/**
* The following events are sometimes sent by the app, but don't need to be handled right now.
* To avoid console warnings from the event system, empty handlers are registered here.
*/
event.addCallback('viewDidAppear', () => {});
event.addCallback('viewDidDisappear', () => {});
event.addCallback('pageInsetsChanged', () => {});
});
}