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

@internetarchive/search-service

Package Overview
Dependencies
Maintainers
12
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.0.1-alpha.15 to 0.0.1-alpha.16

3

dist/src/models/metadata-fields/field-types/byte.d.ts
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';
/**
* A Byte is a unit-specific `number`, in bytes.
*/
export declare type Byte = number;

@@ -4,0 +7,0 @@ /**

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

private fetchUrl;
private getErrorResult;
}

26

dist/src/search-backend/default-search-backend.js

@@ -28,5 +28,3 @@ import { Result } from '../responses/result';

const message = err instanceof Error ? err.message : err;
const error = new SearchServiceError(SearchServiceErrorType.networkError, message);
const result = new Result(undefined, error);
return result;
return this.getErrorResult(SearchServiceErrorType.networkError, message);
}

@@ -36,13 +34,25 @@ // then try json decoding and return a decodingError if it fails

const json = await response.json();
const result = new Result(json);
return result;
// the advanced search endpoint doesn't return an HTTP Error 400
// and instead returns an HTTP 200 with an `error` key in the payload
const error = json['error'];
if (error) {
const forensics = json['forensics'];
return this.getErrorResult(SearchServiceErrorType.searchEngineError, error, forensics);
}
else {
// success
return new Result(json, undefined);
}
}
catch (err) {
const message = err instanceof Error ? err.message : err;
const error = new SearchServiceError(SearchServiceErrorType.decodingError, message);
const result = new Result(undefined, error);
return result;
return this.getErrorResult(SearchServiceErrorType.decodingError, message);
}
}
getErrorResult(errorType, message, details) {
const error = new SearchServiceError(errorType, message, details);
const result = new Result(undefined, error);
return result;
}
}
//# sourceMappingURL=default-search-backend.js.map
export declare enum SearchServiceErrorType {
networkError = 0,
itemNotFound = 1,
decodingError = 2
decodingError = 2,
searchEngineError = 3
}
export declare class SearchServiceError extends Error {
type: SearchServiceErrorType;
constructor(type: SearchServiceErrorType, message?: string);
details?: any;
constructor(type: SearchServiceErrorType, message?: string, details?: any);
}

@@ -6,9 +6,12 @@ export var SearchServiceErrorType;

SearchServiceErrorType[SearchServiceErrorType["decodingError"] = 2] = "decodingError";
SearchServiceErrorType[SearchServiceErrorType["searchEngineError"] = 3] = "searchEngineError";
})(SearchServiceErrorType || (SearchServiceErrorType = {}));
export class SearchServiceError extends Error {
constructor(type, message) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(type, message, details) {
super(message);
this.type = type;
this.details = details;
}
}
//# sourceMappingURL=search-service-error.js.map
{
"name": "@internetarchive/search-service",
"version": "0.0.1-alpha.15",
"version": "0.0.1-alpha.16",
"description": "A search service for the Internet Archive",

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

@@ -8,2 +8,5 @@ import {

/**
* A Byte is a unit-specific `number`, in bytes.
*/
export type Byte = number;

@@ -10,0 +13,0 @@

@@ -45,8 +45,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

const message = err instanceof Error ? err.message : err;
const error = new SearchServiceError(
SearchServiceErrorType.networkError,
message
);
const result = new Result<any, SearchServiceError>(undefined, error);
return result;
return this.getErrorResult(SearchServiceErrorType.networkError, message);
}

@@ -57,14 +52,31 @@

const json = await response.json();
const result = new Result<any, SearchServiceError>(json);
return result;
// the advanced search endpoint doesn't return an HTTP Error 400
// and instead returns an HTTP 200 with an `error` key in the payload
const error = json['error'];
if (error) {
const forensics = json['forensics'];
return this.getErrorResult(
SearchServiceErrorType.searchEngineError,
error,
forensics
);
} else {
// success
return new Result<any, SearchServiceError>(json, undefined);
}
} catch (err) {
const message = err instanceof Error ? err.message : err;
const error = new SearchServiceError(
SearchServiceErrorType.decodingError,
message
);
const result = new Result<any, SearchServiceError>(undefined, error);
return result;
return this.getErrorResult(SearchServiceErrorType.decodingError, message);
}
}
private getErrorResult(
errorType: SearchServiceErrorType,
message?: string,
details?: any
): Result<any, SearchServiceError> {
const error = new SearchServiceError(errorType, message, details);
const result = new Result<any, SearchServiceError>(undefined, error);
return result;
}
}

@@ -5,2 +5,3 @@ export enum SearchServiceErrorType {

decodingError,
searchEngineError,
}

@@ -11,6 +12,11 @@

constructor(type: SearchServiceErrorType, message?: string) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
details?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(type: SearchServiceErrorType, message?: string, details?: any) {
super(message);
this.type = type;
this.details = details;
}
}

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