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

@internetarchive/search-service

Package Overview
Dependencies
Maintainers
13
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internetarchive/search-service - npm Package Compare versions

Comparing version 0.1.3-alpha.1 to 0.2.0

2

dist/src/search-backend/default-search-backend.d.ts

@@ -11,3 +11,5 @@ import { SearchBackendInterface } from './search-backend-interface';

constructor(baseUrl?: string);
/** @inheritdoc */
performSearch(params: SearchParams): Promise<Result<any, SearchServiceError>>;
/** @inheritdoc */
fetchMetadata(identifier: string, keypath?: string): Promise<Result<any, SearchServiceError>>;

@@ -14,0 +16,0 @@ private fetchUrl;

@@ -9,2 +9,3 @@ import { SearchServiceError, SearchServiceErrorType, } from '../search-service-error';

}
/** @inheritdoc */
async performSearch(params) {

@@ -16,2 +17,3 @@ const urlSearchParam = params.asUrlSearchParams;

}
/** @inheritdoc */
async fetchMetadata(identifier, keypath) {

@@ -18,0 +20,0 @@ const path = keypath ? `/${keypath}` : '';

@@ -18,4 +18,15 @@ import { Result } from '@internetarchive/result-type';

export interface SearchBackendInterface {
/**
* Perform a search for the given parameters.
*
* @param params
*/
performSearch(params: SearchParams): Promise<Result<any, SearchServiceError>>;
/**
* Fetch metadata for a single item with an optional keypath
*
* @param identifier
* @param keypath
*/
fetchMetadata(identifier: string, keypath?: string): Promise<Result<any, SearchServiceError>>;
}

@@ -21,3 +21,4 @@ import { SearchResponse } from './responses/search/search-response';

fetchMetadata(identifier: string): Promise<Result<MetadataResponse, SearchServiceError>>;
/** @inheritdoc */
fetchMetadataValue<T>(identifier: string, keypath: string): Promise<Result<T, SearchServiceError>>;
}

@@ -38,2 +38,3 @@ import { SearchResponse } from './responses/search/search-response';

}
/** @inheritdoc */
async fetchMetadataValue(identifier, keypath) {

@@ -40,0 +41,0 @@ var _a;

15

dist/test/search-service.test.js

@@ -73,3 +73,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */

it('returns an error result if the item is not found', async () => {
var _a;
var _a, _b;
class MockSearchBackend {

@@ -90,5 +90,8 @@ performSearch(params) {

expect((_a = result.error) === null || _a === void 0 ? void 0 : _a.type).to.equal(SearchServiceErrorType.itemNotFound);
const valueResult = await service.fetchMetadataValue('foo', 'metadata');
expect(valueResult.error).to.not.equal(undefined);
expect((_b = valueResult.error) === null || _b === void 0 ? void 0 : _b.type).to.equal(SearchServiceErrorType.itemNotFound);
});
it('returns the search backend network error if one occurs', async () => {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f;
class MockSearchBackend {

@@ -110,7 +113,11 @@ async performSearch(params) {

expect((_b = metadataResult.error) === null || _b === void 0 ? void 0 : _b.message).to.equal('network error');
const metadataValueResult = await service.fetchMetadataValue('foo', 'bar');
expect(metadataValueResult.error).to.not.equal(undefined);
expect((_c = metadataValueResult.error) === null || _c === void 0 ? void 0 : _c.type).to.equal(SearchServiceErrorType.networkError);
expect((_d = metadataValueResult.error) === null || _d === void 0 ? void 0 : _d.message).to.equal('network error');
const params = new SearchParams({ query: 'boop' });
const searchResult = await service.search(params);
expect(searchResult.error).to.not.equal(undefined);
expect((_c = searchResult.error) === null || _c === void 0 ? void 0 : _c.type).to.equal(SearchServiceErrorType.networkError);
expect((_d = searchResult.error) === null || _d === void 0 ? void 0 : _d.message).to.equal('network error');
expect((_e = searchResult.error) === null || _e === void 0 ? void 0 : _e.type).to.equal(SearchServiceErrorType.networkError);
expect((_f = searchResult.error) === null || _f === void 0 ? void 0 : _f.message).to.equal('network error');
});

@@ -117,0 +124,0 @@ it('returns the search backend decoding error if one occurs', async () => {

{
"name": "@internetarchive/search-service",
"version": "0.1.3-alpha.1",
"version": "0.2.0",
"description": "A search service for the Internet Archive",

@@ -5,0 +5,0 @@ "license": "AGPL-3.0-only",

@@ -20,2 +20,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

/** @inheritdoc */
async performSearch(

@@ -30,2 +31,3 @@ params: SearchParams

/** @inheritdoc */
async fetchMetadata(

@@ -32,0 +34,0 @@ identifier: string,

@@ -20,3 +20,15 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

export interface SearchBackendInterface {
/**
* Perform a search for the given parameters.
*
* @param params
*/
performSearch(params: SearchParams): Promise<Result<any, SearchServiceError>>;
/**
* Fetch metadata for a single item with an optional keypath
*
* @param identifier
* @param keypath
*/
fetchMetadata(

@@ -23,0 +35,0 @@ identifier: string,

@@ -61,2 +61,3 @@ import { SearchResponse } from './responses/search/search-response';

/** @inheritdoc */
async fetchMetadataValue<T>(

@@ -63,0 +64,0 @@ identifier: string,

@@ -136,2 +136,8 @@ /* eslint-disable @typescript-eslint/no-unused-vars */

expect(result.error?.type).to.equal(SearchServiceErrorType.itemNotFound);
const valueResult = await service.fetchMetadataValue('foo', 'metadata');
expect(valueResult.error).to.not.equal(undefined);
expect(valueResult.error?.type).to.equal(
SearchServiceErrorType.itemNotFound
);
});

@@ -170,2 +176,9 @@

const metadataValueResult = await service.fetchMetadataValue('foo', 'bar');
expect(metadataValueResult.error).to.not.equal(undefined);
expect(metadataValueResult.error?.type).to.equal(
SearchServiceErrorType.networkError
);
expect(metadataValueResult.error?.message).to.equal('network error');
const params = new SearchParams({ query: 'boop' });

@@ -172,0 +185,0 @@ const searchResult = await service.search(params);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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