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

newsware

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newsware - npm Package Compare versions

Comparing version 6.1.0 to 7.0.0

4

lib/src/api.d.ts

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

import { EndpointDescription, HistoricalFilter, News } from "./types";
import { EndpointDescription, HistoricalFilter, RestResponse } from "./types";
export declare class Api {

@@ -7,4 +7,4 @@ private apikey;

changeApikey(apikey: string): void;
search(filter: HistoricalFilter): Promise<News[]>;
search(filter: HistoricalFilter): Promise<RestResponse>;
post<T, Z>(path: string, body: T): Promise<Z>;
}

@@ -43,7 +43,7 @@ "use strict";

});
const apiResponse = yield res.json();
if (res.status < 200 || res.status > 299 || apiResponse.error) {
throw Error(`Status ${res.status}${apiResponse.error ? ": " + apiResponse.error.message : ""}`);
const restResponse = yield res.json();
if (res.status < 200 || res.status > 299 || restResponse.error) {
throw Error(`Status ${res.status}${restResponse.error ? ": " + restResponse.error.message : ""}`);
}
return apiResponse.data;
return restResponse;
}

@@ -50,0 +50,0 @@ catch (e) {

@@ -24,23 +24,40 @@ "use strict";

it("paginate", () => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let res = yield api.search({
pagination: {
limit: 2,
page: 1
}
});
let actualNews = res.data;
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
res = yield api.search({
pagination: {
limit: 4,
page: 1
}
});
actualNews = res.data;
(0, chai_1.expect)(actualNews.length).to.eq(4);
actualNews = yield api.search({
res = yield api.search({
pagination: {
limit: 10,
page: 2
limit: 3,
}
});
actualNews = res.data;
(0, chai_1.expect)(actualNews.length).to.eq(3);
res = yield api.search({
pagination: {
limit: 3,
cursor: (_a = res.pagination) === null || _a === void 0 ? void 0 : _a.cursor
}
});
actualNews = res.data;
(0, chai_1.expect)(actualNews.length).to.eq(3);
res = yield api.search({
pagination: {
limit: 3,
cursor: (_b = res.pagination) === null || _b === void 0 ? void 0 : _b.cursor
}
});
actualNews = res.data;
(0, chai_1.expect)(actualNews.length).to.eq(0);

@@ -50,13 +67,13 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
publishedAfter: 3000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(3);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedAfter: 5000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedAfter: 6000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);

@@ -66,13 +83,13 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
publishedBefore: 1000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedBefore: 5000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(4);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedBefore: 6000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(5);

@@ -82,21 +99,21 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
publishedAfter: 1000,
publishedBefore: 3000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedAfter: 4000,
publishedBefore: 6000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedAfter: 1000,
publishedBefore: 6000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(4);
actualNews = yield api.search({
actualNews = (yield api.search({
publishedAfter: 6000,
publishedBefore: 10000
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);

@@ -106,13 +123,13 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.text)(["one"], { onlyBody: true })
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.text)(["1"], { onlyBody: true })
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.text)(["1 two"], { onlyBody: true })
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);

@@ -122,13 +139,13 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.text)(["one"], { onlyHeadline: true })
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.text)(["one 2"], { onlyHeadline: true })
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.text)(["1"], { onlyHeadline: true })
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);

@@ -138,17 +155,17 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterAction.ANY, ["categoryCode1", "categoryCode2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterAction.ALL, ["categoryCode1", "categoryCode2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterAction.ALL, ["categoryCode1", "categoryCode11"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterAction.EXCLUDE, ["categoryCode1", "categoryCode2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(4);

@@ -158,17 +175,17 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterAction.ANY, ["ticker1", "ticker2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterAction.ALL, ["ticker1", "ticker2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterAction.ALL, ["ticker1", "ticker11"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterAction.EXCLUDE, ["ticker1", "ticker2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(4);

@@ -178,17 +195,17 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterAction.ANY, [1, 2])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterAction.ALL, [1, 2])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterAction.ALL, [1, 11])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterAction.EXCLUDE, [1, 2])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(4);

@@ -198,9 +215,9 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.source)(enums_1.FilterAction.ANY, ["source1", "source2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.source)(enums_1.FilterAction.EXCLUDE, ["source1", "source2"])
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(4);

@@ -210,9 +227,9 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.and)((0, filters_1.text)(["1"]), (0, filters_1.ciks)(enums_1.FilterAction.ANY, [1]))
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.and)((0, filters_1.text)(["2"]), (0, filters_1.ciks)(enums_1.FilterAction.ANY, [1]))
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(0);

@@ -222,9 +239,9 @@ }));

const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
let actualNews = (yield api.search({
filter: (0, filters_1.or)((0, filters_1.text)(["1"]), (0, filters_1.ciks)(enums_1.FilterAction.ANY, [2]))
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
actualNews = (yield api.search({
filter: (0, filters_1.or)((0, filters_1.text)(["2"]), (0, filters_1.ciks)(enums_1.FilterAction.ANY, [1]), (0, filters_1.tickers)(enums_1.FilterAction.ANY, ["ticker3"]))
});
})).data;
(0, chai_1.expect)(actualNews.length).to.eq(3);

@@ -231,0 +248,0 @@ }));

/// <reference types="ws" />
import { CloseEvent } from "isomorphic-ws";
import { FilterAction, FilterType, WebsocketMethod, WebsocketResponseType } from "./enums";
export interface RestResponse {
export type RestResponse = {
error: ApiResponseError;
data: News[];
}
pagination?: {
cursor: (string | number)[];
};
};
export interface ApiResponseError {

@@ -73,4 +76,4 @@ code: number;

export interface Pagination {
limit?: number;
page?: number;
limit: number;
cursor?: (string | number)[];
}

@@ -77,0 +80,0 @@ export type WebsocketRequest = {

{
"name": "newsware",
"version": "6.1.0",
"version": "7.0.0",
"description": "Typescript client for interacting with the Newsware API",

@@ -5,0 +5,0 @@ "main": "lib/src/index.js",

@@ -16,24 +16,42 @@ import {Api} from "./api";

const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
let res = await api.search({
pagination: {
limit: 2,
page: 1
}
})
let actualNews = res.data
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
res = await api.search({
pagination: {
limit: 4,
page: 1
}
})
actualNews = res.data
expect(actualNews.length).to.eq(4)
actualNews = await api.search({
res = await api.search({
pagination: {
limit: 10,
page: 2
limit: 3,
}
})
actualNews = res.data
expect(actualNews.length).to.eq(3)
res = await api.search({
pagination: {
limit: 3,
cursor: res.pagination?.cursor
}
})
actualNews = res.data
expect(actualNews.length).to.eq(3)
res = await api.search({
pagination: {
limit: 3,
cursor: res.pagination?.cursor
}
})
actualNews = res.data
expect(actualNews.length).to.eq(0)

@@ -45,15 +63,15 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
publishedAfter: 3000
})
})).data
expect(actualNews.length).to.eq(3)
actualNews = await api.search({
actualNews = (await api.search({
publishedAfter: 5000
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
publishedAfter: 6000
})
})).data
expect(actualNews.length).to.eq(0)

@@ -65,15 +83,15 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
publishedBefore: 1000
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
publishedBefore: 5000
})
})).data
expect(actualNews.length).to.eq(4)
actualNews = await api.search({
actualNews = (await api.search({
publishedBefore: 6000
})
})).data
expect(actualNews.length).to.eq(5)

@@ -85,24 +103,24 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
publishedAfter: 1000,
publishedBefore: 3000
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
publishedAfter: 4000,
publishedBefore: 6000
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
publishedAfter: 1000,
publishedBefore: 6000
})
})).data
expect(actualNews.length).to.eq(4)
actualNews = await api.search({
actualNews = (await api.search({
publishedAfter: 6000,
publishedBefore: 10000
})
})).data
expect(actualNews.length).to.eq(0)

@@ -114,15 +132,15 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: text(["one"], {onlyBody: true})
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
filter: text(["1"], {onlyBody: true})
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
filter: text(["1 two"], {onlyBody: true})
})
})).data
expect(actualNews.length).to.eq(0)

@@ -134,15 +152,15 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: text(["one"], {onlyHeadline: true})
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
filter: text(["one 2"], {onlyHeadline: true})
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
filter: text(["1"], {onlyHeadline: true})
})
})).data
expect(actualNews.length).to.eq(1)

@@ -154,20 +172,20 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: categoryCodes(FilterAction.ANY, ["categoryCode1", "categoryCode2"])
})
})).data
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
actualNews = (await api.search({
filter: categoryCodes(FilterAction.ALL, ["categoryCode1", "categoryCode2"])
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
filter: categoryCodes(FilterAction.ALL, ["categoryCode1", "categoryCode11"])
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
filter: categoryCodes(FilterAction.EXCLUDE, ["categoryCode1", "categoryCode2"])
})
})).data
expect(actualNews.length).to.eq(4)

@@ -179,20 +197,20 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: tickers(FilterAction.ANY, ["ticker1", "ticker2"])
})
})).data
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
actualNews = (await api.search({
filter: tickers(FilterAction.ALL, ["ticker1", "ticker2"])
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
filter: tickers(FilterAction.ALL, ["ticker1", "ticker11"])
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
filter: tickers(FilterAction.EXCLUDE, ["ticker1", "ticker2"])
})
})).data
expect(actualNews.length).to.eq(4)

@@ -204,20 +222,20 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: ciks(FilterAction.ANY, [1, 2])
})
})).data
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
actualNews = (await api.search({
filter: ciks(FilterAction.ALL, [1, 2])
})
})).data
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
actualNews = (await api.search({
filter: ciks(FilterAction.ALL, [1, 11])
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
filter: ciks(FilterAction.EXCLUDE, [1, 2])
})
})).data
expect(actualNews.length).to.eq(4)

@@ -229,10 +247,10 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: source(FilterAction.ANY, ["source1", "source2"])
})
})).data
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
actualNews = (await api.search({
filter: source(FilterAction.EXCLUDE, ["source1", "source2"])
})
})).data
expect(actualNews.length).to.eq(4)

@@ -244,3 +262,3 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: and(

@@ -250,6 +268,6 @@ text(["1"]),

)
})
})).data
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
actualNews = (await api.search({
filter: and(

@@ -259,3 +277,3 @@ text(["2"]),

)
})
})).data
expect(actualNews.length).to.eq(0)

@@ -267,3 +285,3 @@ })

let actualNews = await api.search({
let actualNews = (await api.search({
filter: or(

@@ -273,6 +291,6 @@ text(["1"]),

)
})
})).data
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
actualNews = (await api.search({
filter: or(

@@ -283,5 +301,5 @@ text(["2"]),

)
})
})).data
expect(actualNews.length).to.eq(3)
})
})

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

import {EndpointDescription, HistoricalFilter, News, RestResponse} from "./types"
import {EndpointDescription, HistoricalFilter, RestResponse} from "./types"
import {Endpoint} from "./enums"

@@ -19,4 +19,4 @@ import fetch from "isomorphic-fetch"

async search(filter: HistoricalFilter): Promise<News[]> {
return await this.post<HistoricalFilter, News[]>('/news', filter)
async search(filter: HistoricalFilter): Promise<RestResponse> {
return await this.post<HistoricalFilter, RestResponse>('/news', filter)
}

@@ -35,9 +35,9 @@

const apiResponse = await res.json() as RestResponse
const restResponse = await res.json() as RestResponse
if (res.status < 200 || res.status > 299 || apiResponse.error) {
throw Error(`Status ${res.status}${apiResponse.error ? ": " + apiResponse.error.message : ""}`)
if (res.status < 200 || res.status > 299 || restResponse.error) {
throw Error(`Status ${res.status}${restResponse.error ? ": " + restResponse.error.message : ""}`)
}
return apiResponse.data as Z
return restResponse as Z
} catch (e: any) {

@@ -44,0 +44,0 @@ if (e.cause?.errors?.length > 0) {

import {CloseEvent} from "isomorphic-ws"
import {FilterAction, FilterType, WebsocketMethod, WebsocketResponseType} from "./enums"
export interface RestResponse {
export type RestResponse = {
error: ApiResponseError
data: News[]
pagination?: {
cursor: (string | number)[]
}
}

@@ -85,4 +88,4 @@

export interface Pagination {
limit?: number
page?: number
limit: number
cursor?: (string | number)[]
}

@@ -89,0 +92,0 @@

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