Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry-internal/global-search

Package Overview
Dependencies
Maintainers
10
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry-internal/global-search - npm Package Compare versions

Comparing version 0.0.46 to 0.1.1

2

dist/html-to-algolia-record/html-to-algolia-record.d.ts

@@ -12,3 +12,3 @@ import { SearchHit } from '../sentry-global-search/lib/types';

*/
declare const parseRecordsFromHTML: (html: string, meta: Meta) => SearchHit[];
declare const parseRecordsFromHTML: (html: string, meta: Meta, baseSelector?: string | undefined) => Promise<SearchHit[]>;
export default parseRecordsFromHTML;

@@ -1,6 +0,5 @@

import { Node } from './types';
/**
* Recursively traverse an AST, flattening each node into its child text.
*/
declare const getChildText: (children: Node[]) => string;
declare const getChildText: (element: any) => string;
export default getChildText;

@@ -1,6 +0,5 @@

import { Node } from './types';
/**
* Convert an HTML string into an AST
*/
declare const htmlToAST: (html: string) => Node[];
declare const htmlToAST: (html: string) => Promise<any>;
export default htmlToAST;

@@ -85,3 +85,3 @@ module.exports =

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 16);
/******/ return __webpack_require__(__webpack_require__.s = 18);
/******/ })

@@ -99,3 +99,3 @@ /************************************************************************/

module.exports = require("@babel/runtime/helpers/toConsumableArray");
module.exports = require("@babel/runtime/regenerator");

@@ -106,3 +106,3 @@ /***/ }),

module.exports = require("@babel/runtime/regenerator");
module.exports = require("@babel/runtime/helpers/toConsumableArray");

@@ -113,6 +113,18 @@ /***/ }),

module.exports = require("@babel/runtime/helpers/asyncToGenerator");
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = require("css-select");
/***/ }),
/* 4 */
/* 5 */
/***/ (function(module, exports) {
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -145,3 +157,3 @@

/***/ }),
/* 5 */
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -212,3 +224,3 @@

/***/ }),
/* 6 */
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -228,3 +240,3 @@

/***/ }),
/* 7 */
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -235,11 +247,11 @@

// EXTERNAL MODULE: external "@babel/runtime/regenerator"
var regenerator_ = __webpack_require__(2);
var regenerator_ = __webpack_require__(1);
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator_);
// EXTERNAL MODULE: external "@babel/runtime/helpers/toConsumableArray"
var toConsumableArray_ = __webpack_require__(1);
var toConsumableArray_ = __webpack_require__(2);
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray_);
// EXTERNAL MODULE: external "@babel/runtime/helpers/asyncToGenerator"
var asyncToGenerator_ = __webpack_require__(9);
var asyncToGenerator_ = __webpack_require__(3);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator_);

@@ -252,15 +264,15 @@

// EXTERNAL MODULE: external "@babel/runtime/helpers/classCallCheck"
var classCallCheck_ = __webpack_require__(10);
var classCallCheck_ = __webpack_require__(11);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck_);
// EXTERNAL MODULE: external "@babel/runtime/helpers/createClass"
var createClass_ = __webpack_require__(11);
var createClass_ = __webpack_require__(12);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass_);
// EXTERNAL MODULE: external "algoliasearch/lite"
var lite_ = __webpack_require__(12);
var lite_ = __webpack_require__(13);
var lite_default = /*#__PURE__*/__webpack_require__.n(lite_);
// EXTERNAL MODULE: external "title-case"
var external_title_case_ = __webpack_require__(13);
var external_title_case_ = __webpack_require__(14);

@@ -571,3 +583,3 @@ // CONCATENATED MODULE: ./src/sentry-global-search/lib/pretty-path.ts

/***/ }),
/* 8 */
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -577,2 +589,6 @@

// EXTERNAL MODULE: external "@babel/runtime/regenerator"
var regenerator_ = __webpack_require__(1);
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator_);
// EXTERNAL MODULE: external "@babel/runtime/helpers/defineProperty"

@@ -582,4 +598,8 @@ var defineProperty_ = __webpack_require__(0);

// EXTERNAL MODULE: external "@babel/runtime/helpers/asyncToGenerator"
var asyncToGenerator_ = __webpack_require__(3);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator_);
// EXTERNAL MODULE: ./node_modules/crypto-browserify/index.js
var crypto_browserify = __webpack_require__(14);
var crypto_browserify = __webpack_require__(15);
var crypto_browserify_default = /*#__PURE__*/__webpack_require__.n(crypto_browserify);

@@ -606,6 +626,6 @@

*/
var getChildText = function getChildText(children) {
return children.map(function (child) {
return child.type === 'element' ? getChildText(child.children) : child.text;
}).filter(Boolean).join('');
var getChildText = function getChildText(element) {
return element.children.map(function (child) {
return child.type === 'tag' ? getChildText(child) : child.data.trim();
}).filter(Boolean).join(' ');
};

@@ -615,4 +635,7 @@

// EXTERNAL MODULE: external "htmlparser2"
var external_htmlparser2_ = __webpack_require__(15);
var external_htmlparser2_ = __webpack_require__(16);
// EXTERNAL MODULE: external "domhandler"
var external_domhandler_ = __webpack_require__(17);
// CONCATENATED MODULE: ./src/html-to-algolia-record/lib/html-to-ast.ts

@@ -624,55 +647,29 @@

*/
var html_to_ast_htmlToAST = function htmlToAST(html) {
// The accumulator
var ast = []; // An array tracking nested elements.
var ancestry = [];
var parser = new external_htmlparser2_["Parser"]({
// Open tags get added to the child list of the last item in the ancestry
// then are pushed into the ancestry themselves.
onopentag: function onopentag(name, attribs) {
var element = {
type: 'element',
name: name,
attribs: attribs,
children: []
};
var latest = ancestry[ancestry.length - 1];
if (latest) {
latest.children.push(element); // Elements will inherit 'data-noindex' from their parent
if (latest.type === 'element' && latest.attribs['data-noindex'] !== undefined) {
element.attribs['data-noindex'] = latest.attribs['data-noindex'];
}
return new Promise(function (resolve, reject) {
var callback = function callback(error, dom) {
if (error) {
reject(error);
} else {
resolve(dom);
}
};
ancestry.push(element);
},
// Text nodes are added to their parent element
ontext: function ontext(text) {
if (text.trim()) {
var latest = ancestry[ancestry.length - 1];
latest.children.push({
type: 'text',
text: text,
children: []
});
}
},
// When elements are closed, we remove them from the ancestry and put them
// in the accumulator
onclosetag: function onclosetag(_name) {
ast.push(ancestry.pop());
}
var handler = new external_domhandler_["DomHandler"](callback);
var parser = new external_htmlparser2_["Parser"](handler);
parser.write(html);
parser.end();
});
parser.write(html);
parser.end();
return ast;
};
/* harmony default export */ var html_to_ast = (html_to_ast_htmlToAST);
// EXTERNAL MODULE: external "css-select"
var external_css_select_ = __webpack_require__(4);
// CONCATENATED MODULE: ./src/html-to-algolia-record/html-to-algolia-record.ts
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -685,33 +682,16 @@

var INCLUDE = ['h1', 'h2', 'h3', 'p', 'li', '[data-index]'];
var EXCLUDE = ['[data-noindex]'];
var testSelector = function testSelector(selector, node) {
selector = selector.trim();
var attributeSelector = /\[(.+)\]/.exec(selector);
var isDecendent = function isDecendent(testNode, highNode) {
var test = testNode.parent;
if (attributeSelector) {
var attribute = attributeSelector[1];
var value = node.attribs[attribute];
if (value !== undefined) return true;
while (test) {
if (highNode === test) return true;
test = test.parent;
}
return node.name === selector ? true : false;
return false;
};
var canBeIndexed = function canBeIndexed(node) {
var match = false; // See if any of the include selectors match. If so, this is a match
match = !!INCLUDE.find(function (x) {
return testSelector(x, node);
}); // Unless the node matches any of the exclude selectors
if (!!EXCLUDE.find(function (x) {
return testSelector(x, node);
})) {
match = false;
}
return match;
};
/**

@@ -728,63 +708,85 @@ * Create algolia record objects from HTML. Intended for use with the rendered

var html_to_algolia_record_parseRecordsFromHTML = function parseRecordsFromHTML(html, meta) {
var title = meta.title;
var records = []; // This object is merged into each record and is mutated to track headings
//and relevance
var parseRecordsFromHTML = /*#__PURE__*/function () {
var _ref = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(html, meta, baseSelector) {
var title, records, initialValues, dom;
return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
title = meta.title;
records = []; // This object is merged into each record and is mutated to track headings
//and relevance
var initialValues = {
// id of the last heading seen
anchor: '',
// title of the page
section: title,
// h1 = 100, h2 = 90, h3 = 80
// Relevance decreases as nesting increases
sectionRank: 100,
// Incremented for each record. Relevance decreases as position increases
position: 0
};
var ast = html_to_ast(html);
ast.reduce(function (acc, el) {
// We only want to index certain things
if (el.type !== 'element') {
return acc;
}
initialValues = {
// id of the last heading seen
anchor: '',
// title of the page
section: title,
// h1 = 100, h2 = 90, h3 = 80
// Relevance decreases as nesting increases
sectionRank: 100,
// Incremented for each record. Relevance decreases as position increases
position: 0
}; // Fetch the initial AST
if (!canBeIndexed(el)) return acc;
var text = get_child_text(el.children).trim(); // Update the context when we get a heading.
_context.next = 5;
return html_to_ast(html);
if (/h[1-3]/.test(el.name)) {
var level = parseInt(el.name[1], 10);
acc.anchor = el.attribs.id;
acc.section = text;
acc.sectionRank = 100 * (1 - 0.1 * (level - 1)); // We don't want to create records for titles, we just want the data, so
// we'll return here.
case 5:
dom = _context.sent;
if (baseSelector) dom = Object(external_css_select_["selectOne"])(baseSelector, dom);
dom = Object(external_css_select_["selectAll"])("".concat(INCLUDE.join(',')), dom);
dom = dom.filter(function (x) {
return Object(external_css_select_["is"])(x, ":not(".concat(EXCLUDE.map(function (x) {
return "".concat(x, ", ").concat(x, " *");
}).join(','), ")"));
});
dom.reduce(function (acc, el) {
var isChildOfExistingElement = !!dom.find(function (x) {
return isDecendent(el, x);
});
if (isChildOfExistingElement) return acc;
var text = get_child_text(el).trim(); // Update the context when we get a heading.
return acc;
} // Keep track of where in the doc this is. Lower stuff is less important
if (/h[1-3]/.test(el.name)) {
var level = parseInt(el.name[1], 10);
acc.anchor = el.attribs.id;
acc.section = text;
acc.sectionRank = 100 * (1 - 0.1 * (level - 1)); // We don't want to create records for titles, we just want the data, so
// we'll return here.
return acc;
} // Keep track of where in the doc this is. Lower stuff is less important
acc.position++;
var record = _objectSpread(_objectSpread({
text: text
}, meta), acc);
acc.position++;
records.push(_objectSpread({
objectID: hash_object(record)
}, record));
return acc;
}, initialValues);
return records;
};
var record = _objectSpread(_objectSpread({
text: text
}, meta), acc);
/* harmony default export */ var html_to_algolia_record = __webpack_exports__["a"] = (html_to_algolia_record_parseRecordsFromHTML);
records.push(_objectSpread({
objectID: hash_object(record)
}, record));
return acc;
}, initialValues);
return _context.abrupt("return", records);
/***/ }),
/* 9 */
/***/ (function(module, exports) {
case 11:
case "end":
return _context.stop();
}
}
}, _callee);
}));
module.exports = require("@babel/runtime/helpers/asyncToGenerator");
return function parseRecordsFromHTML(_x, _x2, _x3) {
return _ref.apply(this, arguments);
};
}();
/* harmony default export */ var html_to_algolia_record = __webpack_exports__["a"] = (parseRecordsFromHTML);
/***/ }),
/* 10 */
/* 11 */
/***/ (function(module, exports) {

@@ -795,3 +797,3 @@

/***/ }),
/* 11 */
/* 12 */
/***/ (function(module, exports) {

@@ -802,3 +804,3 @@

/***/ }),
/* 12 */
/* 13 */
/***/ (function(module, exports) {

@@ -809,3 +811,3 @@

/***/ }),
/* 13 */
/* 14 */
/***/ (function(module, exports) {

@@ -816,3 +818,3 @@

/***/ }),
/* 14 */
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

@@ -823,7 +825,7 @@

exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(18)
exports.createHash = exports.Hash = __webpack_require__(19)
exports.createHmac = exports.Hmac = __webpack_require__(20)
exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(20)
exports.createHash = exports.Hash = __webpack_require__(21)
exports.createHmac = exports.Hmac = __webpack_require__(22)
var algos = __webpack_require__(21)
var algos = __webpack_require__(23)
var algoKeys = Object.keys(algos)

@@ -835,7 +837,7 @@ var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)

var p = __webpack_require__(22)
var p = __webpack_require__(24)
exports.pbkdf2 = p.pbkdf2
exports.pbkdf2Sync = p.pbkdf2Sync
var aes = __webpack_require__(23)
var aes = __webpack_require__(25)

@@ -853,3 +855,3 @@ exports.Cipher = aes.Cipher

var dh = __webpack_require__(24)
var dh = __webpack_require__(26)

@@ -862,3 +864,3 @@ exports.DiffieHellmanGroup = dh.DiffieHellmanGroup

var sign = __webpack_require__(25)
var sign = __webpack_require__(27)

@@ -870,5 +872,5 @@ exports.createSign = sign.createSign

exports.createECDH = __webpack_require__(26)
exports.createECDH = __webpack_require__(28)
var publicEncrypt = __webpack_require__(27)
var publicEncrypt = __webpack_require__(29)

@@ -893,3 +895,3 @@ exports.publicEncrypt = publicEncrypt.publicEncrypt

var rf = __webpack_require__(28)
var rf = __webpack_require__(30)

@@ -927,3 +929,3 @@ exports.randomFill = rf.randomFill

/***/ }),
/* 15 */
/* 16 */
/***/ (function(module, exports) {

@@ -934,10 +936,16 @@

/***/ }),
/* 16 */
/* 17 */
/***/ (function(module, exports) {
module.exports = require("domhandler");
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(17);
module.exports = __webpack_require__(19);
/***/ }),
/* 17 */
/* 19 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -947,18 +955,18 @@

__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _sentry_global_search_lib_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
/* harmony import */ var _sentry_global_search_lib_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
/* harmony import */ var _sentry_global_search_lib_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_sentry_global_search_lib_types__WEBPACK_IMPORTED_MODULE_0__);
/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _sentry_global_search_lib_types__WEBPACK_IMPORTED_MODULE_0__) if(["default","SentryGlobalSearch","sentryAlgoliaIndexSettings","htmlToAlgoliaRecord","standardSDKSlug","extrapolate"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _sentry_global_search_lib_types__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
/* harmony import */ var _sentry_global_search_sentry_global_search__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _sentry_global_search_sentry_global_search__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SentryGlobalSearch", function() { return _sentry_global_search_sentry_global_search__WEBPACK_IMPORTED_MODULE_1__["a"]; });
/* harmony import */ var _sentry_algolia_index_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
/* harmony import */ var _sentry_algolia_index_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "sentryAlgoliaIndexSettings", function() { return _sentry_algolia_index_settings__WEBPACK_IMPORTED_MODULE_2__["a"]; });
/* harmony import */ var _html_to_algolia_record_html_to_algolia_record__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
/* harmony import */ var _html_to_algolia_record_html_to_algolia_record__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "htmlToAlgoliaRecord", function() { return _html_to_algolia_record_html_to_algolia_record__WEBPACK_IMPORTED_MODULE_3__["a"]; });
/* harmony import */ var _sentry_global_search_lib_standard_sdk_slug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
/* harmony import */ var _sentry_global_search_lib_standard_sdk_slug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "standardSDKSlug", function() { return _sentry_global_search_lib_standard_sdk_slug__WEBPACK_IMPORTED_MODULE_4__["a"]; });
/* harmony import */ var _sentry_global_search_lib_extrapolate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
/* harmony import */ var _sentry_global_search_lib_extrapolate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "extrapolate", function() { return _sentry_global_search_lib_extrapolate__WEBPACK_IMPORTED_MODULE_5__["a"]; });

@@ -974,3 +982,3 @@

/***/ }),
/* 18 */
/* 20 */
/***/ (function(module, exports) {

@@ -981,3 +989,3 @@

/***/ }),
/* 19 */
/* 21 */
/***/ (function(module, exports) {

@@ -988,3 +996,3 @@

/***/ }),
/* 20 */
/* 22 */
/***/ (function(module, exports) {

@@ -995,3 +1003,3 @@

/***/ }),
/* 21 */
/* 23 */
/***/ (function(module, exports) {

@@ -1002,3 +1010,3 @@

/***/ }),
/* 22 */
/* 24 */
/***/ (function(module, exports) {

@@ -1009,3 +1017,3 @@

/***/ }),
/* 23 */
/* 25 */
/***/ (function(module, exports) {

@@ -1016,3 +1024,3 @@

/***/ }),
/* 24 */
/* 26 */
/***/ (function(module, exports) {

@@ -1023,3 +1031,3 @@

/***/ }),
/* 25 */
/* 27 */
/***/ (function(module, exports) {

@@ -1030,3 +1038,3 @@

/***/ }),
/* 26 */
/* 28 */
/***/ (function(module, exports) {

@@ -1037,3 +1045,3 @@

/***/ }),
/* 27 */
/* 29 */
/***/ (function(module, exports) {

@@ -1044,3 +1052,3 @@

/***/ }),
/* 28 */
/* 30 */
/***/ (function(module, exports) {

@@ -1047,0 +1055,0 @@

{
"name": "@sentry-internal/global-search",
"description": "JavaScript library and helper utilities for searching Sentry sites via Algolia.",
"version": "0.0.46",
"version": "0.1.1",
"author": "Sentry",

@@ -11,2 +11,4 @@ "dependencies": {

"algoliasearch": "^4.3.1",
"css-select": "^4.1.3",
"domhandler": "^4.2.0",
"dompurify": "^2.2.7",

@@ -30,2 +32,4 @@ "htmlparser2": "^4.1.0",

"@babel/preset-typescript": "^7.10.4",
"@types/domhandler": "^2.4.2",
"@types/htmlparser2": "^3.10.3",
"@types/js-yaml": "^3.12.5",

@@ -32,0 +36,0 @@ "babel-loader": "^8.1.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc