Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (error.response) {
const { status, statusText, headers: responseHeaders } = error.response;
const message = `[${status}] ${statusText}`;
log(`warn`, `error on ${id} webhook event: ${message}`);
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// special handling for 5xx
if (status >= 500) {
return retryResult(id, message);
}
// special handling for rate limiting
if (status === 429) {
return pipe(
getRetryAfterIntervalFromHeaders(responseHeaders),
map(retry => retryResultSeconds(id, message, retry)),
getOrElse(() => retryResult(id, message))
);
}
return errorResultInvalid(id, message);
}
const message = i18n.translate('xpack.actions.builtin.webhook.unreachableRemoteWebhook', {
defaultMessage: 'Unreachable Remote Webhook, are you sure the address is correct?',
});
log(`warn`, `error on ${id} webhook action: ${message}`);
return errorResultUnreachable(id, message);
}
}
computePath(fileNode?: DbFileTreeNode): Promise {
return pipe(
fromNullable(fileNode),
map(node => node.mpath.split('.').slice(0, -1)),
map(async parentsIds => {
if (parentsIds.length > 0) {
const parents = await this.fileTreeRepo.getNamesByIds(parentsIds);
return extractPath(parentsIds, parents);
}
return [];
}),
getOrElse(() => Promise.resolve([] as IFilePathItem[])),
);
}
}
export function incrementMonthOption(month: Option): Option {
return pipe(month, map(incrementMonth), alt(constant(some(0))));
}
getActiveWindowTabs,
T.map(flow(O.map(sufficientTabsExact), O.chain(NEA.fromArray))),
);
case ContextMenuEntry.SendActiveTab: return pipe(
getActiveTab,
T.map(flow(
O.chain(tab => OT.fromNullable(tab.title, tab.url)),
O.map(([title, url]) => [{ title, url }]),
O.chain(NEA.fromArray),
)),
);
case ContextMenuEntry.SendLink: return pipe(
u,
O.map(url => [{ url, title: url }]),
O.chain(NEA.fromArray),
TO.fromOption,
);
default: return TO.none;
}
};
private renderMonth() {
const {
value: { month },
} = this.props;
const monthClassName = this.getSectionClassName(ActiveSection.Month);
const monthValue = map(inc)(month);
return (
<span>
{format(monthValue, ActiveSection.Month)}
</span>
);
}
export const colors = {
[URLMatch.Exact]: '#4286f4',
[URLMatch.Domain]: '#a0c4ff',
};
const hrefToUrlReducer = (acc: Array, href: string): Array => pipe(
fromString(href),
E.fold(
constant(acc),
snoc_(acc),
),
);
const getBookmarksUrlsFromLocalStorage: TaskEither>> = pipe(
getBookmarksFromLocalStorage,
TE.map(O.map(flow(
A.map(bm => bm.url),
A.reduce([], hrefToUrlReducer),
))),
);
let urlState: Array = [];
const syncBookmarks: Task = async () => {
const bookmarkUrls = await getBookmarksUrlsFromLocalStorage();
if (EO.isRightSome(bookmarkUrls)) {
urlState = bookmarkUrls.right.value;
}
};
const reduceMatch = ([x, y]: [URLMatch, number]) => (z: URLMatch): [URLMatch, number] =>
const contextClickTabs = (u: Option) => (c: ContextMenuEntry): TaskOption> => {
switch (c) {
case ContextMenuEntry.SendAllTabs: return pipe(
getAllTabs,
T.map(flow(O.map(sufficientTabsExact), O.chain(NEA.fromArray))),
);
case ContextMenuEntry.SendActiveWindowTabs: return pipe(
getActiveWindowTabs,
T.map(flow(O.map(sufficientTabsExact), O.chain(NEA.fromArray))),
);
case ContextMenuEntry.SendActiveTab: return pipe(
getActiveTab,
T.map(flow(
O.chain(tab => OT.fromNullable(tab.title, tab.url)),
O.map(([title, url]) => [{ title, url }]),
O.chain(NEA.fromArray),
)),
);
case ContextMenuEntry.SendLink: return pipe(
u,
O.map(url => [{ url, title: url }]),
O.chain(NEA.fromArray),
TO.fromOption,
const ContentApp: FC = () => {
const activePage = useSelector(state => state.user.page);
const stagedGroupTitle = O.map(formatStagedBookmarksGroupTitle)(useSelector(getStagedGroupToEdit));
const dispatch = useDispatch();
const page = pageMap({ activePage, stagedGroupTitle });
return (
<>
{'nav' in page && (
} else {
this.onValueChange(day, some(digit - 1), year);
if (digit > 1) {
this.selectNextSection();
this.secondInput = false;
} else {
this.secondInput = true;
}
}
break;
}
case ActiveSection.Year: {
if (this.secondInput) {
const newYear = pipe(
year,
map(value => {
if (value < 1000) {
return Number(`${value}${digit}`);
} else {
return Number(`${value}${digit}`.substr(1));
}
}),
);
this.onValueChange(day, month, newYear);
} else {
this.onValueChange(day, month, some(digit));
this.secondInput = true;
}
break;
}
}
}
const run = (from: Ref, url: string, kind: Kind, item: PathItemObject): Either => {
if (isSome(item.$ref)) {
const $ref = item.$ref.value;
return pipe(
e.resolveRef($ref, PathItemObjectCodec),
either.mapLeft(() => new Error(`Unable to resolve PathItem $ref: "${$ref}"`)),
either.chain(resolved => run(from, url, kind, resolved)),
);
} else {
const get = pipe(
item.get,
map(operation => serializeOperationObject(from, url, 'GET', kind, operation, item)),
);
const put = pipe(
item.put,
map(operation => serializeOperationObject(from, url, 'PUT', kind, operation, item)),
);
const post = pipe(
item.post,
map(operation => serializeOperationObject(from, url, 'POST', kind, operation, item)),
);
const remove = pipe(
item.delete,
map(operation => serializeOperationObject(from, url, 'DELETE', kind, operation, item)),
);
const options = pipe(
item.options,
map(operation => serializeOperationObject(from, url, 'OPTIONS', kind, operation, item)),
);
const head = pipe(
item.head,
map(operation => serializeOperationObject(from, url, 'HEAD', kind, operation, item)),