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

@backstage/plugin-search-backend-node

Package Overview
Dependencies
Maintainers
4
Versions
1086
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/plugin-search-backend-node - npm Package Compare versions

Comparing version 0.0.0-nightly-202111222339 to 0.0.0-nightly-2021112322755

46

dist/index.cjs.js

@@ -12,3 +12,3 @@ 'use strict';

class IndexBuilder {
constructor({logger, searchEngine}) {
constructor({ logger, searchEngine }) {
this.collators = {};

@@ -32,3 +32,3 @@ this.decorators = {};

}
addDecorator({decorator}) {
addDecorator({ decorator }) {
const types = decorator.types || ["*"];

@@ -45,3 +45,3 @@ this.logger.info(`Added decorator ${decorator.constructor.name} to types ${types.join(", ")}`);

async build() {
const scheduler = new Scheduler({logger: this.logger});
const scheduler = new Scheduler({ logger: this.logger });
Object.keys(this.collators).forEach((type) => {

@@ -106,3 +106,3 @@ scheduler.addToSchedule(async () => {

class Scheduler {
constructor({logger}) {
constructor({ logger }) {
this.runningTasks = [];

@@ -116,7 +116,7 @@ this.logger = logger;

}
this.schedule.push({task, interval});
this.schedule.push({ task, interval });
}
start() {
this.logger.info("Starting all scheduled search tasks.");
this.schedule.forEach(({task, interval}) => {
this.schedule.forEach(({ task, interval }) => {
this.runningTasks.push(runPeriodically(() => task(), interval));

@@ -135,3 +135,3 @@ });

class LunrSearchEngine {
constructor({logger}) {
constructor({ logger }) {
this.lunrIndices = {};

@@ -146,3 +146,3 @@ this.translator = ({

lunrQueryBuilder: (q) => {
const termToken = lunr__default['default'].tokenizer(term);
const termToken = lunr__default["default"].tokenizer(term);
q.term(termToken, {

@@ -155,3 +155,3 @@ usePipeline: true,

boost: 10,
wildcard: lunr__default['default'].Query.wildcard.TRAILING
wildcard: lunr__default["default"].Query.wildcard.TRAILING
});

@@ -170,4 +170,4 @@ q.term(termToken, {

if (["string", "number", "boolean"].includes(typeof value)) {
q.term(lunr__default['default'].tokenizer(value == null ? void 0 : value.toString()), {
presence: lunr__default['default'].Query.presence.REQUIRED,
q.term(lunr__default["default"].tokenizer(value == null ? void 0 : value.toString()), {
presence: lunr__default["default"].Query.presence.REQUIRED,
fields: [field]

@@ -177,4 +177,4 @@ });

this.logger.warn(`Non-scalar filter value used for field ${field}. Consider using a different Search Engine for better results.`);
q.term(lunr__default['default'].tokenizer(value), {
presence: lunr__default['default'].Query.presence.OPTIONAL,
q.term(lunr__default["default"].tokenizer(value), {
presence: lunr__default["default"].Query.presence.OPTIONAL,
fields: [field]

@@ -199,5 +199,5 @@ });

async index(type, documents) {
const lunrBuilder = new lunr__default['default'].Builder();
lunrBuilder.pipeline.add(lunr__default['default'].trimmer, lunr__default['default'].stopWordFilter, lunr__default['default'].stemmer);
lunrBuilder.searchPipeline.add(lunr__default['default'].stemmer);
const lunrBuilder = new lunr__default["default"].Builder();
lunrBuilder.pipeline.add(lunr__default["default"].trimmer, lunr__default["default"].stopWordFilter, lunr__default["default"].stemmer);
lunrBuilder.searchPipeline.add(lunr__default["default"].stemmer);
Object.keys(documents[0]).forEach((field) => {

@@ -214,3 +214,3 @@ lunrBuilder.field(field);

async query(query) {
const {lunrQueryBuilder, documentTypes, pageSize} = this.translator(query);
const { lunrQueryBuilder, documentTypes, pageSize } = this.translator(query);
const results = [];

@@ -235,11 +235,11 @@ Object.keys(this.lunrIndices).filter((type) => !documentTypes || documentTypes.includes(type)).forEach((type) => {

});
const {page} = decodePageCursor(query.pageCursor);
const { page } = decodePageCursor(query.pageCursor);
const offset = page * pageSize;
const hasPreviousPage = page > 0;
const hasNextPage = results.length > offset + pageSize;
const nextPageCursor = hasNextPage ? encodePageCursor({page: page + 1}) : void 0;
const previousPageCursor = hasPreviousPage ? encodePageCursor({page: page - 1}) : void 0;
const nextPageCursor = hasNextPage ? encodePageCursor({ page: page + 1 }) : void 0;
const previousPageCursor = hasPreviousPage ? encodePageCursor({ page: page - 1 }) : void 0;
const realResultSet = {
results: results.slice(offset, offset + pageSize).map((d) => {
return {type: d.type, document: this.docStore[d.result.ref]};
return { type: d.type, document: this.docStore[d.result.ref] };
}),

@@ -254,3 +254,3 @@ nextPageCursor,

if (!pageCursor) {
return {page: 0};
return { page: 0 };
}

@@ -261,3 +261,3 @@ return {

}
function encodePageCursor({page}) {
function encodePageCursor({ page }) {
return Buffer.from(`${page}`, "utf-8").toString("base64");

@@ -264,0 +264,0 @@ }

{
"name": "@backstage/plugin-search-backend-node",
"description": "A library for Backstage backend plugins that want to interact with the search backend plugin",
"version": "0.0.0-nightly-202111222339",
"version": "0.0.0-nightly-2021112322755",
"main": "dist/index.cjs.js",

@@ -23,3 +23,3 @@ "types": "dist/index.d.ts",

"dependencies": {
"@backstage/search-common": "^0.0.0-nightly-202111222339",
"@backstage/search-common": "^0.2.1",
"winston": "^3.2.1",

@@ -30,4 +30,4 @@ "lunr": "^2.3.9",

"devDependencies": {
"@backstage/backend-common": "^0.0.0-nightly-202111222339",
"@backstage/cli": "^0.0.0-nightly-202111222339"
"@backstage/backend-common": "^0.0.0-nightly-2021112322755",
"@backstage/cli": "^0.0.0-nightly-2021112322755"
},

@@ -34,0 +34,0 @@ "files": [

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