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
1079
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.4.1 to 0.4.2

12

CHANGELOG.md
# @backstage/plugin-search-backend-node
## 0.4.2
### Patch Changes
- a13f21cdc: Implement optional `pageCursor` based paging in search.
To use paging in your app, add a `<SearchResultPager />` to your
`SearchPage.tsx`.
- Updated dependencies
- @backstage/search-common@0.2.0
## 0.4.1

@@ -4,0 +16,0 @@

29

dist/index.cjs.js

@@ -137,2 +137,3 @@ 'use strict';

}) => {
const pageSize = 25;
return {

@@ -177,3 +178,4 @@ lunrQueryBuilder: (q) => {

},
documentTypes: types
documentTypes: types,
pageSize
};

@@ -202,3 +204,3 @@ };

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

@@ -223,6 +225,14 @@ Object.keys(this.lunrIndices).filter((type) => !documentTypes || documentTypes.includes(type)).forEach((type) => {

});
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 realResultSet = {
results: results.map((d) => {
results: results.slice(offset, offset + pageSize).map((d) => {
return {type: d.type, document: this.docStore[d.result.ref]};
})
}),
nextPageCursor,
previousPageCursor
};

@@ -232,2 +242,13 @@ return realResultSet;

}
function decodePageCursor(pageCursor) {
if (!pageCursor) {
return {page: 0};
}
return {
page: Number(Buffer.from(pageCursor, "base64").toString("utf-8"))
};
}
function encodePageCursor({page}) {
return Buffer.from(`${page}`, "utf-8").toString("base64");
}

@@ -234,0 +255,0 @@ exports.IndexBuilder = IndexBuilder;

@@ -89,2 +89,3 @@ import { DocumentCollator, DocumentDecorator, SearchEngine, IndexableDocument, QueryTranslator, SearchQuery, SearchResultSet } from '@backstage/search-common';

documentTypes?: string[];
pageSize: number;
};

@@ -91,0 +92,0 @@ declare type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery;

10

package.json
{
"name": "@backstage/plugin-search-backend-node",
"version": "0.4.1",
"version": "0.4.2",
"main": "dist/index.cjs.js",

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

"dependencies": {
"@backstage/search-common": "^0.1.3",
"@backstage/search-common": "^0.2.0",
"@types/lunr": "^2.3.3",

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

"devDependencies": {
"@backstage/backend-common": "^0.8.8",
"@backstage/cli": "^0.7.7"
"@backstage/backend-common": "^0.9.1",
"@backstage/cli": "^0.7.10"
},

@@ -36,3 +36,3 @@ "files": [

],
"gitHead": "0cbbc971f3894862bf5a248603b5b997f8052da1"
"gitHead": "174a8b532e8b6dda0e733ec943d1aa7187a3821a"
}

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