New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@internetarchive/search-service

Package Overview
Dependencies
Maintainers
12
Versions
158
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.13 to 0.0.1-alpha.14

dist/src/models/metadata-fields/field-types/mediatype.d.ts

4

dist/src/models/file.js

@@ -27,5 +27,3 @@ /* eslint-disable @typescript-eslint/camelcase */

: undefined;
this.size = json.size
? ByteParser.shared.parseValue(json.size)
: undefined;
this.size = json.size ? ByteParser.shared.parseValue(json.size) : undefined;
this.height = json.height

@@ -32,0 +30,0 @@ ? NumberParser.shared.parseValue(json.height)

@@ -0,3 +1,4 @@

export declare type FieldParserRawValue = string | number | boolean;
export interface FieldParserInterface<T> {
parseValue(rawValue: string): T | undefined;
parseValue(rawValue: FieldParserRawValue): T | undefined;
}

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

import { FieldParserInterface } from '../field-parser-interface';
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';
export declare class BooleanParser implements FieldParserInterface<boolean> {
static shared: BooleanParser;
parseValue(rawValue: string): boolean;
parseValue(rawValue: FieldParserRawValue): boolean;
}

@@ -7,0 +7,0 @@ export declare class BooleanField extends MetadataField<boolean, BooleanParser> {

import { MetadataField } from '../metadata-field';
export class BooleanParser {
parseValue(rawValue) {
if (rawValue === 'false' || rawValue === '0') {
if (typeof rawValue === 'string' &&
(rawValue === 'false' || rawValue === '0')) {
return false;

@@ -6,0 +7,0 @@ }

@@ -1,2 +0,2 @@

import { FieldParserInterface } from '../field-parser-interface';
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -14,3 +14,3 @@ export declare type Byte = number;

static shared: ByteParser;
parseValue(rawValue: string): Byte | undefined;
parseValue(rawValue: FieldParserRawValue): Byte | undefined;
}

@@ -17,0 +17,0 @@ /**

@@ -16,2 +16,4 @@ import { MetadataField } from '../metadata-field';

parseJSDate(rawValue) {
if (typeof rawValue !== 'string')
return undefined;
// fix for Safari not supporting `yyyy-mm-dd HH:MM:SS` format, insert a `T` into the space

@@ -18,0 +20,0 @@ if (rawValue.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s{1}[0-9]{2}:[0-9]{2}:[0-9]{2}$/)) {

@@ -1,2 +0,2 @@

import { FieldParserInterface } from '../field-parser-interface';
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -14,3 +14,3 @@ /**

static shared: DurationParser;
parseValue(rawValue: string): Duration | undefined;
parseValue(rawValue: FieldParserRawValue): Duration | undefined;
}

@@ -17,0 +17,0 @@ /**

@@ -9,2 +9,6 @@ import { MetadataField } from '../metadata-field';

parseValue(rawValue) {
if (typeof rawValue === 'number')
return rawValue;
if (typeof rawValue === 'boolean')
return undefined;
const componentArray = rawValue.split(':');

@@ -11,0 +15,0 @@ const componentCount = componentArray.length;

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

import { FieldParserInterface } from '../field-parser-interface';
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';
export declare class NumberParser implements FieldParserInterface<number> {
static shared: NumberParser;
parseValue(rawValue: string): number | undefined;
parseValue(rawValue: FieldParserRawValue): number | undefined;
}

@@ -7,0 +7,0 @@ export declare class NumberField extends MetadataField<number, NumberParser> {

import { MetadataField } from '../metadata-field';
export class NumberParser {
parseValue(rawValue) {
if (typeof rawValue === 'number')
return rawValue;
if (typeof rawValue === 'boolean')
return undefined;
const value = parseFloat(rawValue);

@@ -5,0 +9,0 @@ if (Number.isNaN(value)) {

@@ -1,2 +0,2 @@

import { FieldParserInterface } from '../field-parser-interface';
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -9,3 +9,3 @@ export declare enum PageProgression {

static shared: PageProgressionParser;
parseValue(rawValue: string): PageProgression | undefined;
parseValue(rawValue: FieldParserRawValue): PageProgression | undefined;
}

@@ -12,0 +12,0 @@ export declare class PageProgressionField extends MetadataField<PageProgression, PageProgressionParser> {

@@ -9,2 +9,4 @@ import { MetadataField } from '../metadata-field';

parseValue(rawValue) {
if (typeof rawValue !== 'string')
return undefined;
switch (rawValue) {

@@ -11,0 +13,0 @@ case 'rl':

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

import { FieldParserInterface } from '../field-parser-interface';
import { FieldParserInterface, FieldParserRawValue } from '../field-parser-interface';
import { MetadataField } from '../metadata-field';
export declare class StringParser implements FieldParserInterface<string> {
static shared: StringParser;
parseValue(rawValue: string): string;
parseValue(rawValue: FieldParserRawValue): string;
}

@@ -7,0 +7,0 @@ export declare class StringField extends MetadataField<string, StringParser> {

import { FieldParserInterface } from './field-parser-interface';
export declare type MetadataRawValue = string | string[] | number | boolean;
/**

@@ -30,6 +31,6 @@ * The MetadataField is responsible for three things:

*
* @type {*}
* @type {MetadataRawValue}
* @memberof MetadataField
*/
rawValue?: string[] | string;
rawValue?: MetadataRawValue;
/**

@@ -53,3 +54,3 @@ * The array of all values for the field.

get value(): Type | undefined;
constructor(parser: FieldParserInterfaceType, rawValue?: any);
constructor(parser: FieldParserInterfaceType, rawValue?: MetadataRawValue);
private parser;

@@ -56,0 +57,0 @@ private processRawValue;

@@ -8,2 +8,3 @@ import { BooleanField } from './metadata-fields/field-types/boolean';

import { ByteField } from './metadata-fields/field-types/byte';
import { MediaTypeField } from './metadata-fields/field-types/mediatype';
/**

@@ -101,3 +102,3 @@ * Metadata is an expansive model that describes an Item.

month?: NumberField;
mediatype?: StringField;
mediatype?: MediaTypeField;
noindex?: BooleanField;

@@ -104,0 +105,0 @@ notes?: StringField;

@@ -10,2 +10,3 @@ /* eslint-disable @typescript-eslint/camelcase */

import { ByteField } from './metadata-fields/field-types/byte';
import { MediaTypeField } from './metadata-fields/field-types/mediatype';
/**

@@ -68,3 +69,3 @@ * Metadata is an expansive model that describes an Item.

this.mediatype = json.mediatype
? new StringField(json.mediatype)
? new MediaTypeField(json.mediatype)
: undefined;

@@ -71,0 +72,0 @@ this.month = json.month ? new NumberField(json.month) : undefined;

{
"name": "@internetarchive/search-service",
"version": "0.0.1-alpha.13",
"version": "0.0.1-alpha.14",
"description": "A search service for the Internet Archive",

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

@@ -67,5 +67,3 @@ /* eslint-disable @typescript-eslint/camelcase */

: undefined;
this.size = json.size
? ByteParser.shared.parseValue(json.size)
: undefined;
this.size = json.size ? ByteParser.shared.parseValue(json.size) : undefined;
this.height = json.height

@@ -72,0 +70,0 @@ ? NumberParser.shared.parseValue(json.height)

@@ -0,3 +1,5 @@

export type FieldParserRawValue = string | number | boolean;
export interface FieldParserInterface<T> {
parseValue(rawValue: string): T | undefined;
parseValue(rawValue: FieldParserRawValue): T | undefined;
}

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -9,4 +12,7 @@

parseValue(rawValue: string): boolean {
if (rawValue === 'false' || rawValue === '0') {
parseValue(rawValue: FieldParserRawValue): boolean {
if (
typeof rawValue === 'string' &&
(rawValue === 'false' || rawValue === '0')
) {
return false;

@@ -13,0 +19,0 @@ }

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -20,3 +23,3 @@ import { NumberParser } from './number';

parseValue(rawValue: string): Byte | undefined {
parseValue(rawValue: FieldParserRawValue): Byte | undefined {
const parser = NumberParser.shared;

@@ -23,0 +26,0 @@ return parser.parseValue(rawValue);

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -23,3 +26,5 @@

private parseJSDate(rawValue: string): Date | undefined {
private parseJSDate(rawValue: FieldParserRawValue): Date | undefined {
if (typeof rawValue !== 'string') return undefined;
// fix for Safari not supporting `yyyy-mm-dd HH:MM:SS` format, insert a `T` into the space

@@ -26,0 +31,0 @@ if (

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -19,3 +22,6 @@

parseValue(rawValue: string): Duration | undefined {
parseValue(rawValue: FieldParserRawValue): Duration | undefined {
if (typeof rawValue === 'number') return rawValue;
if (typeof rawValue === 'boolean') return undefined;
const componentArray: string[] = rawValue.split(':');

@@ -22,0 +28,0 @@ const componentCount: number = componentArray.length;

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -9,3 +12,6 @@

parseValue(rawValue: string): number | undefined {
parseValue(rawValue: FieldParserRawValue): number | undefined {
if (typeof rawValue === 'number') return rawValue;
if (typeof rawValue === 'boolean') return undefined;
const value = parseFloat(rawValue);

@@ -12,0 +18,0 @@ if (Number.isNaN(value)) {

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -15,3 +18,5 @@

parseValue(rawValue: string): PageProgression | undefined {
parseValue(rawValue: FieldParserRawValue): PageProgression | undefined {
if (typeof rawValue !== 'string') return undefined;
switch (rawValue) {

@@ -18,0 +23,0 @@ case 'rl':

@@ -1,2 +0,5 @@

import { FieldParserInterface } from '../field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from '../field-parser-interface';
import { MetadataField } from '../metadata-field';

@@ -9,3 +12,3 @@

parseValue(rawValue: string): string {
parseValue(rawValue: FieldParserRawValue): string {
return String(rawValue);

@@ -12,0 +15,0 @@ }

@@ -1,4 +0,8 @@

/* eslint-disable @typescript-eslint/no-explicit-any */
import { FieldParserInterface } from './field-parser-interface';
import {
FieldParserInterface,
FieldParserRawValue,
} from './field-parser-interface';
export type MetadataRawValue = string | string[] | number | boolean;
/**

@@ -35,6 +39,6 @@ * The MetadataField is responsible for three things:

*
* @type {*}
* @type {MetadataRawValue}
* @memberof MetadataField
*/
rawValue?: string[] | string;
rawValue?: MetadataRawValue;

@@ -63,3 +67,3 @@ /**

constructor(parser: FieldParserInterfaceType, rawValue?: any) {
constructor(parser: FieldParserInterfaceType, rawValue?: MetadataRawValue) {
this.parser = parser;

@@ -87,3 +91,3 @@ this.rawValue = rawValue;

private parseAndPersistValue(value: any): void {
private parseAndPersistValue(value: FieldParserRawValue): void {
const parsedValue = this.parser.parseValue(value);

@@ -90,0 +94,0 @@ if (parsedValue !== undefined) {

@@ -12,2 +12,3 @@ /* eslint-disable @typescript-eslint/camelcase */

import { ByteField } from './metadata-fields/field-types/byte';
import { MediaTypeField } from './metadata-fields/field-types/mediatype';

@@ -126,3 +127,3 @@ /**

mediatype?: StringField;
mediatype?: MediaTypeField;

@@ -227,3 +228,3 @@ noindex?: BooleanField;

this.mediatype = json.mediatype
? new StringField(json.mediatype)
? new MediaTypeField(json.mediatype)
: undefined;

@@ -230,0 +231,0 @@ this.month = json.month ? new NumberField(json.month) : undefined;

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

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

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