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 5.1.0 to 6.0.0

lib/src/filters.d.ts

4

lib/src/api.js

@@ -21,3 +21,3 @@ "use strict";

this.apikey = apikey;
this.restEndpoint = endpoint.restProtocol + "://" + endpoint.host;
this.restEndpoint = endpoint.restProtocol + "://" + endpoint.host + "/api/v3";
}

@@ -29,3 +29,3 @@ changeApikey(apikey) {

return __awaiter(this, void 0, void 0, function* () {
return yield this.post('/api/v2/news', filter);
return yield this.post('/news', filter);
});

@@ -32,0 +32,0 @@ }

@@ -15,3 +15,3 @@ "use strict";

const chai_1 = require("chai");
const types_1 = require("./types");
const filters_1 = require("./filters");
describe("Api historical search", () => {

@@ -104,25 +104,13 @@ let context;

let actualNews = yield api.search({
query: {
type: types_1.QueryType.TEXT,
term: "one",
onlyBody: true
}
filter: (0, filters_1.text)("one", { onlyBody: true })
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
query: {
type: types_1.QueryType.TEXT,
term: "1",
onlyBody: true
}
filter: (0, filters_1.text)("1", { onlyBody: true })
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
query: {
type: types_1.QueryType.TEXT,
term: "1 two",
onlyBody: true
}
filter: (0, filters_1.text)("1 two", { onlyBody: true })
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
(0, chai_1.expect)(actualNews.length).to.eq(0);
}));

@@ -132,27 +120,105 @@ it("by headline", () => __awaiter(void 0, void 0, void 0, function* () {

let actualNews = yield api.search({
query: {
type: types_1.QueryType.TEXT,
term: "one",
onlyHeadline: true
}
filter: (0, filters_1.text)("one", { onlyHeadline: true })
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
query: {
type: types_1.QueryType.TEXT,
term: "one 2",
onlyHeadline: true
}
filter: (0, filters_1.text)("one 2", { onlyHeadline: true })
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
filter: (0, filters_1.text)("1", { onlyHeadline: true })
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
}));
it("by category code", () => __awaiter(void 0, void 0, void 0, function* () {
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterArrayAction.ANY, ["categoryCode1", "categoryCode2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
query: {
type: types_1.QueryType.TEXT,
term: "1",
onlyHeadline: true
}
filter: (0, filters_1.categoryCodes)(enums_1.FilterArrayAction.ALL, ["categoryCode1", "categoryCode2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterArrayAction.ALL, ["categoryCode1", "categoryCode11"])
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
filter: (0, filters_1.categoryCodes)(enums_1.FilterArrayAction.EXCLUDE, ["categoryCode1", "categoryCode2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(4);
}));
it("by tickers", () => __awaiter(void 0, void 0, void 0, function* () {
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterArrayAction.ANY, ["ticker1", "ticker2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterArrayAction.ALL, ["ticker1", "ticker2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterArrayAction.ALL, ["ticker1", "ticker11"])
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
filter: (0, filters_1.tickers)(enums_1.FilterArrayAction.EXCLUDE, ["ticker1", "ticker2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(4);
}));
it("by ciks", () => __awaiter(void 0, void 0, void 0, function* () {
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterArrayAction.ANY, [1, 2])
});
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterArrayAction.ALL, [1, 2])
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
actualNews = yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterArrayAction.ALL, [1, 11])
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
filter: (0, filters_1.ciks)(enums_1.FilterArrayAction.EXCLUDE, [1, 2])
});
(0, chai_1.expect)(actualNews.length).to.eq(4);
}));
it("by source", () => __awaiter(void 0, void 0, void 0, function* () {
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
filter: (0, filters_1.source)(enums_1.FilterArrayAction.ANY, ["source1", "source2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
filter: (0, filters_1.source)(enums_1.FilterArrayAction.EXCLUDE, ["source1", "source2"])
});
(0, chai_1.expect)(actualNews.length).to.eq(4);
}));
it("by and condition", () => __awaiter(void 0, void 0, void 0, function* () {
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
filter: (0, filters_1.and)((0, filters_1.text)("1"), (0, filters_1.ciks)(enums_1.FilterArrayAction.ANY, [1]))
});
(0, chai_1.expect)(actualNews.length).to.eq(1);
actualNews = yield api.search({
filter: (0, filters_1.and)((0, filters_1.text)("2"), (0, filters_1.ciks)(enums_1.FilterArrayAction.ANY, [1]))
});
(0, chai_1.expect)(actualNews.length).to.eq(0);
}));
it("by or condition", () => __awaiter(void 0, void 0, void 0, function* () {
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST);
let actualNews = yield api.search({
filter: (0, filters_1.or)((0, filters_1.text)("1"), (0, filters_1.ciks)(enums_1.FilterArrayAction.ANY, [2]))
});
(0, chai_1.expect)(actualNews.length).to.eq(2);
actualNews = yield api.search({
filter: (0, filters_1.or)((0, filters_1.text)("2"), (0, filters_1.ciks)(enums_1.FilterArrayAction.ANY, [1]), (0, filters_1.tickers)(enums_1.FilterArrayAction.ANY, ["ticker3"]))
});
(0, chai_1.expect)(actualNews.length).to.eq(3);
}));
});
//# sourceMappingURL=api.test.js.map
import { EndpointDescription } from "./types";
export declare enum QueryType {
And = "and",
Or = "or",
Text = "text"
export declare enum FilterType {
AND = "and",
OR = "or",
TEXT = "text",
TICKERS = "tickers",
CATEGORY_CODES = "categoryCodes",
CIKS = "ciks",
SOURCE = "source"
}
export declare enum FilterTextAction {
MATCH = "match",
EXCLUDE = "exclude"
}
export declare enum FilterArrayAction {
ALL = "all",
ANY = "any",
EXCLUDE = "exclude"
}
export declare enum Source {

@@ -8,0 +21,0 @@ DowJones = "DJ",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Endpoint = exports.WebsocketResponseType = exports.WebsocketMethod = exports.Source = exports.QueryType = void 0;
var QueryType;
(function (QueryType) {
QueryType["And"] = "and";
QueryType["Or"] = "or";
QueryType["Text"] = "text";
})(QueryType || (exports.QueryType = QueryType = {}));
exports.Endpoint = exports.WebsocketResponseType = exports.WebsocketMethod = exports.Source = exports.FilterArrayAction = exports.FilterTextAction = exports.FilterType = void 0;
var FilterType;
(function (FilterType) {
FilterType["AND"] = "and";
FilterType["OR"] = "or";
FilterType["TEXT"] = "text";
FilterType["TICKERS"] = "tickers";
FilterType["CATEGORY_CODES"] = "categoryCodes";
FilterType["CIKS"] = "ciks";
FilterType["SOURCE"] = "source";
})(FilterType || (exports.FilterType = FilterType = {}));
var FilterTextAction;
(function (FilterTextAction) {
FilterTextAction["MATCH"] = "match";
FilterTextAction["EXCLUDE"] = "exclude";
})(FilterTextAction || (exports.FilterTextAction = FilterTextAction = {}));
var FilterArrayAction;
(function (FilterArrayAction) {
FilterArrayAction["ALL"] = "all";
FilterArrayAction["ANY"] = "any";
FilterArrayAction["EXCLUDE"] = "exclude";
})(FilterArrayAction || (exports.FilterArrayAction = FilterArrayAction = {}));
var Source;

@@ -11,0 +26,0 @@ (function (Source) {

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

export { or, and, text } from "./queries";
export { or, and, text, ciks, tickers, source, categoryCodes } from "./filters";
export { Api } from "./api";
export { WsApi } from "./wsApi";
export { News, Filter, TextOptions, WebsocketResponse, WebsocketErrorResponse, ConnectOptions } from "./types";
export { Source, WebsocketMethod, WebsocketResponseType } from "./enums";
export { News, Filter, TextOptions, WebsocketResponse, WebsocketErrorResponse, ConnectOptions, HistoricalFilter } from "./types";
export { Source, WebsocketMethod, WebsocketResponseType, FilterType, FilterArrayAction, FilterTextAction } from "./enums";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebsocketResponseType = exports.WebsocketMethod = exports.Source = exports.WsApi = exports.Api = exports.text = exports.and = exports.or = void 0;
var queries_1 = require("./queries");
Object.defineProperty(exports, "or", { enumerable: true, get: function () { return queries_1.or; } });
Object.defineProperty(exports, "and", { enumerable: true, get: function () { return queries_1.and; } });
Object.defineProperty(exports, "text", { enumerable: true, get: function () { return queries_1.text; } });
exports.FilterTextAction = exports.FilterArrayAction = exports.FilterType = exports.WebsocketResponseType = exports.WebsocketMethod = exports.Source = exports.WsApi = exports.Api = exports.categoryCodes = exports.source = exports.tickers = exports.ciks = exports.text = exports.and = exports.or = void 0;
var filters_1 = require("./filters");
Object.defineProperty(exports, "or", { enumerable: true, get: function () { return filters_1.or; } });
Object.defineProperty(exports, "and", { enumerable: true, get: function () { return filters_1.and; } });
Object.defineProperty(exports, "text", { enumerable: true, get: function () { return filters_1.text; } });
Object.defineProperty(exports, "ciks", { enumerable: true, get: function () { return filters_1.ciks; } });
Object.defineProperty(exports, "tickers", { enumerable: true, get: function () { return filters_1.tickers; } });
Object.defineProperty(exports, "source", { enumerable: true, get: function () { return filters_1.source; } });
Object.defineProperty(exports, "categoryCodes", { enumerable: true, get: function () { return filters_1.categoryCodes; } });
var api_1 = require("./api");

@@ -16,2 +20,5 @@ Object.defineProperty(exports, "Api", { enumerable: true, get: function () { return api_1.Api; } });

Object.defineProperty(exports, "WebsocketResponseType", { enumerable: true, get: function () { return enums_1.WebsocketResponseType; } });
Object.defineProperty(exports, "FilterType", { enumerable: true, get: function () { return enums_1.FilterType; } });
Object.defineProperty(exports, "FilterArrayAction", { enumerable: true, get: function () { return enums_1.FilterArrayAction; } });
Object.defineProperty(exports, "FilterTextAction", { enumerable: true, get: function () { return enums_1.FilterTextAction; } });
//# sourceMappingURL=index.js.map
/// <reference types="ws" />
import { CloseEvent } from "isomorphic-ws";
import { Source, WebsocketMethod, WebsocketResponseType } from "./enums";
export interface Filter {
query?: Query;
tickers?: string[];
sources?: Source[];
ciks?: number[];
}
import { FilterArrayAction, FilterTextAction, FilterType, WebsocketMethod, WebsocketResponseType } from "./enums";
export interface RestResponse {

@@ -27,22 +21,31 @@ error: ApiResponseError;

creationTime: string;
categoryCodes: string;
}
export interface TextQuery extends TextOptions {
type: QueryType.TEXT;
term: string;
export interface FilterText extends TextOptions {
type: FilterType.TEXT;
value: string;
}
export interface ConditionQuery {
type: QueryType.AND | QueryType.OR;
queries: Query[];
export interface FilterCondition {
type: FilterType.AND | FilterType.OR;
value: Filter[];
}
export interface TextOptions {
action?: FilterTextAction;
onlyBody?: boolean;
onlyHeadline?: boolean;
ignore?: boolean;
}
export declare enum QueryType {
AND = "and",
OR = "or",
TEXT = "text"
}
export type Query = ConditionQuery | TextQuery;
export type FilterArray = {
type: FilterType.CATEGORY_CODES | FilterType.TICKERS;
action: FilterArrayAction;
value: string[];
} | {
type: FilterType.SOURCE;
action: FilterArrayAction.ANY | FilterArrayAction.EXCLUDE;
value: string[];
} | {
type: FilterType.CIKS;
action: FilterArrayAction;
value: number[];
};
export type Filter = FilterCondition | FilterText | FilterArray;
export interface EndpointDescription {

@@ -62,8 +65,9 @@ host: string;

subscriptionId: string;
filter: Filter;
filter?: Filter;
}
export interface HistoricalFilter extends Filter {
export interface HistoricalFilter {
pagination?: Pagination;
publishedAfter?: number;
publishedBefore?: number;
filter?: Filter;
}

@@ -77,3 +81,3 @@ export interface Pagination {

id: string;
payload: Filter;
payload?: Filter;
} | {

@@ -80,0 +84,0 @@ method: WebsocketMethod.UNSUBSCRIBE;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryType = void 0;
var QueryType;
(function (QueryType) {
QueryType["AND"] = "and";
QueryType["OR"] = "or";
QueryType["TEXT"] = "text";
})(QueryType || (exports.QueryType = QueryType = {}));
//# sourceMappingURL=types.js.map

@@ -13,3 +13,3 @@ "use strict";

this.reconnectMessages = [];
this.websocketEndpoint = endpoint.websocketProtocol + "://" + endpoint.host;
this.websocketEndpoint = endpoint.websocketProtocol + "://" + endpoint.host + "/ws/v3";
this.connect(options);

@@ -29,3 +29,3 @@ }

});
this.socket = new isomorphic_ws_1.default(`${this.websocketEndpoint}/ws/v2?${urlParams.toString()}`);
this.socket = new isomorphic_ws_1.default(`${this.websocketEndpoint}?${urlParams.toString()}`);
this.socket.onmessage = (event) => {

@@ -32,0 +32,0 @@ const response = JSON.parse(event.data.toString());

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

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

import {Api} from "./api";
import {Endpoint} from "./enums";
import {Endpoint, FilterArrayAction} from "./enums";
import {expect} from "chai"
import {TestsContext} from "../test/setup";
import {QueryType} from "./types";
import {and, categoryCodes, ciks, or, source, text, tickers} from "./filters";

@@ -111,7 +111,3 @@ describe("Api historical search", () => {

let actualNews = await api.search({
query: {
type: QueryType.TEXT,
term: "one",
onlyBody: true
}
filter: text("one", {onlyBody: true})
})

@@ -121,7 +117,3 @@ expect(actualNews.length).to.eq(1)

actualNews = await api.search({
query: {
type: QueryType.TEXT,
term: "1",
onlyBody: true
}
filter: text("1", {onlyBody: true})
})

@@ -131,9 +123,5 @@ expect(actualNews.length).to.eq(0)

actualNews = await api.search({
query: {
type: QueryType.TEXT,
term: "1 two",
onlyBody: true
}
filter: text("1 two", {onlyBody: true})
})
expect(actualNews.length).to.eq(1)
expect(actualNews.length).to.eq(0)
})

@@ -145,7 +133,3 @@

let actualNews = await api.search({
query: {
type: QueryType.TEXT,
term: "one",
onlyHeadline: true
}
filter: text("one", {onlyHeadline: true})
})

@@ -155,19 +139,138 @@ expect(actualNews.length).to.eq(0)

actualNews = await api.search({
query: {
type: QueryType.TEXT,
term: "one 2",
onlyHeadline: true
}
filter: text("one 2", {onlyHeadline: true})
})
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
filter: text("1", {onlyHeadline: true})
})
expect(actualNews.length).to.eq(1)
})
it("by category code", async () => {
const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
filter: categoryCodes(FilterArrayAction.ANY, ["categoryCode1", "categoryCode2"])
})
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
query: {
type: QueryType.TEXT,
term: "1",
onlyHeadline: true
}
filter: categoryCodes(FilterArrayAction.ALL, ["categoryCode1", "categoryCode2"])
})
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
filter: categoryCodes(FilterArrayAction.ALL, ["categoryCode1", "categoryCode11"])
})
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
filter: categoryCodes(FilterArrayAction.EXCLUDE, ["categoryCode1", "categoryCode2"])
})
expect(actualNews.length).to.eq(4)
})
it("by tickers", async () => {
const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
filter: tickers(FilterArrayAction.ANY, ["ticker1", "ticker2"])
})
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
filter: tickers(FilterArrayAction.ALL, ["ticker1", "ticker2"])
})
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
filter: tickers(FilterArrayAction.ALL, ["ticker1", "ticker11"])
})
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
filter: tickers(FilterArrayAction.EXCLUDE, ["ticker1", "ticker2"])
})
expect(actualNews.length).to.eq(4)
})
it("by ciks", async () => {
const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
filter: ciks(FilterArrayAction.ANY, [1, 2])
})
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
filter: ciks(FilterArrayAction.ALL, [1, 2])
})
expect(actualNews.length).to.eq(0)
actualNews = await api.search({
filter: ciks(FilterArrayAction.ALL, [1, 11])
})
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
filter: ciks(FilterArrayAction.EXCLUDE, [1, 2])
})
expect(actualNews.length).to.eq(4)
})
it("by source", async () => {
const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
filter: source(FilterArrayAction.ANY, ["source1", "source2"])
})
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
filter: source(FilterArrayAction.EXCLUDE, ["source1", "source2"])
})
expect(actualNews.length).to.eq(4)
})
it("by and condition", async () => {
const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
filter: and(
text("1"),
ciks(FilterArrayAction.ANY, [1])
)
})
expect(actualNews.length).to.eq(1)
actualNews = await api.search({
filter: and(
text("2"),
ciks(FilterArrayAction.ANY, [1])
)
})
expect(actualNews.length).to.eq(0)
})
it("by or condition", async () => {
const api = new Api(context.config.apikey, Endpoint.LOCALHOST)
let actualNews = await api.search({
filter: or(
text("1"),
ciks(FilterArrayAction.ANY, [2])
)
})
expect(actualNews.length).to.eq(2)
actualNews = await api.search({
filter: or(
text("2"),
ciks(FilterArrayAction.ANY, [1]),
tickers(FilterArrayAction.ANY, ["ticker3"])
)
})
expect(actualNews.length).to.eq(3)
})
})

@@ -12,3 +12,3 @@ import {EndpointDescription, HistoricalFilter, News, RestResponse} from "./types"

) {
this.restEndpoint = endpoint.restProtocol + "://" + endpoint.host
this.restEndpoint = endpoint.restProtocol + "://" + endpoint.host + "/api/v3"
}

@@ -21,3 +21,3 @@

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

@@ -24,0 +24,0 @@

import {EndpointDescription} from "./types";
export enum QueryType {
And = "and",
Or = "or",
Text = "text"
export enum FilterType {
AND = "and",
OR = "or",
TEXT = "text",
TICKERS = "tickers",
CATEGORY_CODES = "categoryCodes",
CIKS = "ciks",
SOURCE = "source"
}
export enum FilterTextAction {
MATCH = "match",
EXCLUDE = "exclude"
}
export enum FilterArrayAction {
ALL = "all",
ANY = "any",
EXCLUDE = "exclude"
}
export enum Source {

@@ -10,0 +24,0 @@ DowJones = "DJ",

@@ -1,7 +0,13 @@

export {or, and, text} from "./queries";
export {or, and, text, ciks, tickers, source, categoryCodes} from "./filters";
export {Api} from "./api"
export {WsApi} from "./wsApi"
export {
News, Filter, TextOptions, WebsocketResponse, WebsocketErrorResponse, ConnectOptions
News,
Filter,
TextOptions,
WebsocketResponse,
WebsocketErrorResponse,
ConnectOptions,
HistoricalFilter
} from "./types"
export {Source, WebsocketMethod, WebsocketResponseType} from "./enums"
export {Source, WebsocketMethod, WebsocketResponseType, FilterType, FilterArrayAction, FilterTextAction} from "./enums"

@@ -1,11 +0,4 @@

import {CloseEvent} from "isomorphic-ws";
import {Source, WebsocketMethod, WebsocketResponseType} from "./enums";
import {CloseEvent} from "isomorphic-ws"
import {FilterArrayAction, FilterTextAction, FilterType, WebsocketMethod, WebsocketResponseType} from "./enums"
export interface Filter {
query?: Query
tickers?: string[]
sources?: Source[]
ciks?: number[]
}
export interface RestResponse {

@@ -17,40 +10,49 @@ error: ApiResponseError

export interface ApiResponseError {
code: number;
message: string;
code: number
message: string
}
export interface News {
id: string;
source: string;
tickers: string[];
headline: string;
body: string;
publicationTime: string;
receivedTime: string;
creationTime: string;
id: string
source: string
tickers: string[]
headline: string
body: string
publicationTime: string
receivedTime: string
creationTime: string
categoryCodes: string
}
export interface TextQuery extends TextOptions {
type: QueryType.TEXT
term: string
export interface FilterText extends TextOptions {
type: FilterType.TEXT
value: string
}
export interface ConditionQuery {
type: QueryType.AND | QueryType.OR
queries: Query[]
export interface FilterCondition {
type: FilterType.AND | FilterType.OR
value: Filter[]
}
export interface TextOptions {
action?: FilterTextAction // Defaults to "match"
onlyBody?: boolean
onlyHeadline?: boolean
ignore?: boolean
}
export enum QueryType {
AND = "and",
OR = "or",
TEXT = "text"
export type FilterArray = {
type: FilterType.CATEGORY_CODES | FilterType.TICKERS
action: FilterArrayAction
value: string[]
} | {
type: FilterType.SOURCE
action: FilterArrayAction.ANY | FilterArrayAction.EXCLUDE
value: string[]
} | {
type: FilterType.CIKS
action: FilterArrayAction
value: number[]
}
export type Query = ConditionQuery | TextQuery
export type Filter = FilterCondition | FilterText | FilterArray

@@ -73,9 +75,10 @@ export interface EndpointDescription {

subscriptionId: string,
filter: Filter,
filter?: Filter,
}
export interface HistoricalFilter extends Filter {
export interface HistoricalFilter {
pagination?: Pagination
publishedAfter?: number
publishedBefore?: number
filter?: Filter
}

@@ -91,3 +94,3 @@

id: string
payload: Filter
payload?: Filter
} | {

@@ -94,0 +97,0 @@ method: WebsocketMethod.UNSUBSCRIBE

@@ -16,3 +16,3 @@ import {ConnectOptions, EndpointDescription, SubscribeOptions, WebsocketRequest, WebsocketResponse,} from "./types";

) {
this.websocketEndpoint = endpoint.websocketProtocol + "://" + endpoint.host
this.websocketEndpoint = endpoint.websocketProtocol + "://" + endpoint.host + "/ws/v3"
this.connect(options)

@@ -36,3 +36,3 @@ }

this.socket = new WebSocket(`${this.websocketEndpoint}/ws/v2?${urlParams.toString()}`)
this.socket = new WebSocket(`${this.websocketEndpoint}?${urlParams.toString()}`)
this.socket.onmessage = (event: MessageEvent) => {

@@ -39,0 +39,0 @@ const response = JSON.parse(event.data.toString()) as WebsocketResponse

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