@a11ywatch/core
Version:
a11ywatch central API
49 lines • 1.89 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractPageData = exports.extractLighthouse = void 0;
const website_source_builder_1 = require("@a11ywatch/website-source-builder");
const utils_1 = require("../../../core/utils");
const extractLighthouse = ({ domain, pageUrl, userId, insight }) => {
const parsedInsight = insight
? (0, utils_1.jsonParse)(insight)
: null;
return {
userId,
domain,
pageUrl: (0, website_source_builder_1.removeTrailingSlash)(pageUrl),
json: parsedInsight ? JSON.stringify(parsedInsight) : "",
};
};
exports.extractLighthouse = extractLighthouse;
const extractPageData = (dataSource) => {
const { issues, webPage, userId } = dataSource !== null && dataSource !== void 0 ? dataSource : {
issues: {
documentTitle: "",
domain: "",
pageUrl: "",
issues: [],
},
webPage: null,
};
const _a = webPage !== null && webPage !== void 0 ? webPage : {}, { insight } = _a, w = __rest(_a, ["insight"]);
const _b = w !== null && w !== void 0 ? w : {}, { issuesInfo } = _b, website = __rest(_b, ["issuesInfo"]);
return {
userId,
issues,
webPage: website,
issuesInfo,
};
};
exports.extractPageData = extractPageData;
//# sourceMappingURL=extract-page-data.js.map