Comparing version 5.0.0-beta.1 to 5.0.0-beta.2
@@ -19,2 +19,3 @@ "use strict"; | ||
const wsclient_1 = require("./wsclient"); | ||
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); | ||
class Api { | ||
@@ -34,3 +35,3 @@ constructor(apikey, endpoint = enums_1.Endpoint.PRODUCTION) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.post('/v1/api/news', filter); | ||
return yield this.post('/v2/api/news', filter); | ||
}); | ||
@@ -42,3 +43,3 @@ } | ||
try { | ||
const res = yield fetch(this.restEndpoint + path, { | ||
const res = yield (0, isomorphic_fetch_1.default)(this.restEndpoint + path, { | ||
method: "POST", | ||
@@ -45,0 +46,0 @@ body: JSON.stringify(body), |
@@ -15,2 +15,3 @@ "use strict"; | ||
const chai_1 = require("chai"); | ||
const types_1 = require("./types"); | ||
describe("Api historical search", () => { | ||
@@ -24,3 +25,3 @@ let context; | ||
it("paginate", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.Localhost); | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = yield api.search({ | ||
@@ -49,3 +50,3 @@ pagination: { | ||
it("published after", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.Localhost); | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = yield api.search({ | ||
@@ -65,3 +66,3 @@ publishedAfter: 3000 | ||
it("published before", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.Localhost); | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = yield api.search({ | ||
@@ -81,3 +82,3 @@ publishedBefore: 1000 | ||
it("published between", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.Localhost); | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = yield api.search({ | ||
@@ -105,9 +106,8 @@ publishedAfter: 1000, | ||
it("by body", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.Localhost); | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = yield api.search({ | ||
query: { | ||
text: { | ||
text: "one", | ||
searchBody: true | ||
} | ||
type: types_1.QueryType.TEXT, | ||
term: "one", | ||
searchBody: true | ||
} | ||
@@ -118,6 +118,5 @@ }); | ||
query: { | ||
text: { | ||
text: "1", | ||
searchBody: true | ||
} | ||
type: types_1.QueryType.TEXT, | ||
term: "1", | ||
searchBody: true | ||
} | ||
@@ -128,6 +127,5 @@ }); | ||
query: { | ||
text: { | ||
text: "1 two", | ||
searchBody: true | ||
} | ||
type: types_1.QueryType.TEXT, | ||
term: "1 two", | ||
searchBody: true | ||
} | ||
@@ -138,9 +136,8 @@ }); | ||
it("by headline", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.Localhost); | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = yield api.search({ | ||
query: { | ||
text: { | ||
text: "one", | ||
searchHeadline: true | ||
} | ||
type: types_1.QueryType.TEXT, | ||
term: "one", | ||
searchHeadline: true | ||
} | ||
@@ -151,6 +148,5 @@ }); | ||
query: { | ||
text: { | ||
text: "one 2", | ||
searchHeadline: true | ||
} | ||
type: types_1.QueryType.TEXT, | ||
term: "one 2", | ||
searchHeadline: true | ||
} | ||
@@ -161,6 +157,5 @@ }); | ||
query: { | ||
text: { | ||
text: "1", | ||
searchHeadline: true | ||
} | ||
type: types_1.QueryType.TEXT, | ||
term: "1", | ||
searchHeadline: true | ||
} | ||
@@ -167,0 +162,0 @@ }); |
export { or, and, text } from "./queries"; | ||
export { Api } from "./api"; | ||
export { WsClient } from "./wsclient"; | ||
export { News, Filter, TextOptions, EndpointDescription, WebsocketResponse, WebsocketRequest, WebsocketErrorResponse, Query } from "./types"; | ||
export { Source, WebsocketMethod, WebsocketResponseType, QueryType, Endpoint } from "./enums"; | ||
export { News, Filter, TextOptions, WebsocketResponse, WebsocketErrorResponse } from "./types"; | ||
export { Source, WebsocketMethod, WebsocketResponseType } from "./enums"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Endpoint = exports.QueryType = exports.WebsocketResponseType = exports.WebsocketMethod = exports.Source = exports.WsClient = exports.Api = exports.text = exports.and = exports.or = void 0; | ||
exports.WebsocketResponseType = exports.WebsocketMethod = exports.Source = exports.WsClient = exports.Api = exports.text = exports.and = exports.or = void 0; | ||
var queries_1 = require("./queries"); | ||
@@ -16,4 +16,2 @@ Object.defineProperty(exports, "or", { enumerable: true, get: function () { return queries_1.or; } }); | ||
Object.defineProperty(exports, "WebsocketResponseType", { enumerable: true, get: function () { return enums_1.WebsocketResponseType; } }); | ||
Object.defineProperty(exports, "QueryType", { enumerable: true, get: function () { return enums_1.QueryType; } }); | ||
Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return enums_1.Endpoint; } }); | ||
//# sourceMappingURL=index.js.map |
import { Query, TextOptions } from "./types"; | ||
export declare const and: (...queries: Query[]) => Query; | ||
export declare const or: (...queries: Query[]) => Query; | ||
export declare const text: (text: string, options?: TextOptions) => Query; | ||
export declare const text: (term: string, options?: TextOptions) => Query; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.text = exports.or = exports.and = void 0; | ||
const types_1 = require("./types"); | ||
const and = (...queries) => { | ||
return { | ||
and: queries | ||
type: types_1.QueryType.AND, | ||
queries: queries | ||
}; | ||
@@ -12,10 +14,9 @@ }; | ||
return { | ||
or: queries | ||
type: types_1.QueryType.OR, | ||
queries: queries | ||
}; | ||
}; | ||
exports.or = or; | ||
const text = (text, options) => { | ||
return { | ||
text: Object.assign(Object.assign({ text: text }, textOptionsDefault), options) | ||
}; | ||
const text = (term, options) => { | ||
return Object.assign(Object.assign({ type: types_1.QueryType.TEXT, term }, textOptionsDefault), options); | ||
}; | ||
@@ -22,0 +23,0 @@ exports.text = text; |
@@ -29,3 +29,4 @@ /// <reference types="ws" /> | ||
export interface TextQuery extends TextOptions { | ||
text: string; | ||
type: QueryType.TEXT; | ||
term: string; | ||
} | ||
@@ -38,9 +39,11 @@ export interface TextOptions { | ||
} | ||
export declare enum QueryType { | ||
AND = "and", | ||
OR = "or", | ||
TEXT = "text" | ||
} | ||
export type Query = { | ||
and: Query[]; | ||
} | { | ||
or: Query[]; | ||
} | { | ||
text: TextQuery; | ||
}; | ||
type: QueryType.AND | QueryType.OR; | ||
queries: Query[]; | ||
} | TextQuery; | ||
export interface EndpointDescription { | ||
@@ -47,0 +50,0 @@ host: string; |
"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 |
{ | ||
"name": "newsware", | ||
"version": "5.0.0-beta.1", | ||
"version": "5.0.0-beta.2", | ||
"description": "Typescript client for interacting with the Newsware API", | ||
@@ -40,2 +40,3 @@ "main": "lib/src/index.js", | ||
"@types/chai": "^4.3.6", | ||
"@types/isomorphic-fetch": "^0.0.38", | ||
"@types/js-yaml": "^4.0.6", | ||
@@ -51,4 +52,5 @@ "@types/mocha": "^10.0.1", | ||
"dependencies": { | ||
"isomorphic-fetch": "^3.0.0", | ||
"isomorphic-ws": "^5.0.0" | ||
} | ||
} |
@@ -5,12 +5,13 @@ import {Api} from "./api"; | ||
import {TestsContext} from "../test/setup"; | ||
import {QueryType} from "./types"; | ||
describe("Api historical search", () => { | ||
let context: TestsContext | ||
before(async function () { | ||
context = this as TestsContext | ||
}) | ||
it("paginate", async () => { | ||
const api = new Api(context.config.apikey, Endpoint.Localhost) | ||
const api = new Api(context.config.apikey, Endpoint.LOCALHOST) | ||
let actualNews = await api.search({ | ||
@@ -42,4 +43,4 @@ pagination: { | ||
it("published after", async () => { | ||
const api = new Api(context.config.apikey, Endpoint.Localhost) | ||
const api = new Api(context.config.apikey, Endpoint.LOCALHOST) | ||
let actualNews = await api.search({ | ||
@@ -62,3 +63,3 @@ publishedAfter: 3000 | ||
it("published before", async () => { | ||
const api = new Api(context.config.apikey, Endpoint.Localhost) | ||
const api = new Api(context.config.apikey, Endpoint.LOCALHOST) | ||
@@ -82,3 +83,3 @@ let actualNews = await api.search({ | ||
it("published between", async () => { | ||
const api = new Api(context.config.apikey, Endpoint.Localhost) | ||
const api = new Api(context.config.apikey, Endpoint.LOCALHOST) | ||
@@ -111,10 +112,9 @@ let actualNews = await api.search({ | ||
it("by body", async () => { | ||
const api = new Api(context.config.apikey, Endpoint.Localhost) | ||
const api = new Api(context.config.apikey, Endpoint.LOCALHOST) | ||
let actualNews = await api.search({ | ||
query: { | ||
text: { | ||
text: "one", | ||
searchBody: true | ||
} | ||
type: QueryType.TEXT, | ||
term: "one", | ||
searchBody: true | ||
} | ||
@@ -126,6 +126,5 @@ }) | ||
query: { | ||
text: { | ||
text: "1", | ||
searchBody: true | ||
} | ||
type: QueryType.TEXT, | ||
term: "1", | ||
searchBody: true | ||
} | ||
@@ -137,6 +136,5 @@ }) | ||
query: { | ||
text: { | ||
text: "1 two", | ||
searchBody: true | ||
} | ||
type: QueryType.TEXT, | ||
term: "1 two", | ||
searchBody: true | ||
} | ||
@@ -148,10 +146,9 @@ }) | ||
it("by headline", async () => { | ||
const api = new Api(context.config.apikey, Endpoint.Localhost) | ||
const api = new Api(context.config.apikey, Endpoint.LOCALHOST) | ||
let actualNews = await api.search({ | ||
query: { | ||
text: { | ||
text: "one", | ||
searchHeadline: true | ||
} | ||
type: QueryType.TEXT, | ||
term: "one", | ||
searchHeadline: true | ||
} | ||
@@ -163,6 +160,5 @@ }) | ||
query: { | ||
text: { | ||
text: "one 2", | ||
searchHeadline: true | ||
} | ||
type: QueryType.TEXT, | ||
term: "one 2", | ||
searchHeadline: true | ||
} | ||
@@ -174,6 +170,5 @@ }) | ||
query: { | ||
text: { | ||
text: "1", | ||
searchHeadline: true | ||
} | ||
type: QueryType.TEXT, | ||
term: "1", | ||
searchHeadline: true | ||
} | ||
@@ -180,0 +175,0 @@ }) |
@@ -5,2 +5,3 @@ import {ConnectOptions, EndpointDescription, HistoricalFilter, News, RestResponse} from "./types" | ||
import {WsClient} from "./wsclient" | ||
import fetch from "isomorphic-fetch" | ||
@@ -28,3 +29,3 @@ export class Api { | ||
async search(filter: HistoricalFilter): Promise<News[]> { | ||
return await this.post<HistoricalFilter, News[]>('/v1/api/news', filter) | ||
return await this.post<HistoricalFilter, News[]>('/v2/api/news', filter) | ||
} | ||
@@ -31,0 +32,0 @@ |
@@ -5,4 +5,4 @@ export {or, and, text} from "./queries"; | ||
export { | ||
News, Filter, TextOptions, EndpointDescription, WebsocketResponse, WebsocketRequest, WebsocketErrorResponse, Query | ||
News, Filter, TextOptions, WebsocketResponse, WebsocketErrorResponse | ||
} from "./types" | ||
export {Source, WebsocketMethod, WebsocketResponseType, QueryType, Endpoint} from "./enums" | ||
export {Source, WebsocketMethod, WebsocketResponseType} from "./enums" |
@@ -1,6 +0,7 @@ | ||
import {Query, TextOptions} from "./types"; | ||
import {Query, QueryType, TextOptions} from "./types"; | ||
export const and = (...queries: Query[]): Query => { | ||
return { | ||
and: queries | ||
type: QueryType.AND, | ||
queries: queries | ||
} | ||
@@ -11,13 +12,13 @@ } | ||
return { | ||
or: queries | ||
type: QueryType.OR, | ||
queries: queries | ||
} | ||
} | ||
export const text = (text: string, options?: TextOptions): Query => { | ||
export const text = (term: string, options?: TextOptions): Query => { | ||
return { | ||
text: { | ||
text: text, | ||
...textOptionsDefault, | ||
...options | ||
} | ||
type: QueryType.TEXT, | ||
term, | ||
...textOptionsDefault, | ||
...options | ||
} | ||
@@ -24,0 +25,0 @@ } |
@@ -33,3 +33,4 @@ import {CloseEvent} from "isomorphic-ws"; | ||
export interface TextQuery extends TextOptions { | ||
text: string | ||
type: QueryType.TEXT | ||
term: string | ||
} | ||
@@ -44,10 +45,13 @@ | ||
export type Query = { | ||
and: Query[] | ||
} | { | ||
or: Query[] | ||
} | { | ||
text: TextQuery | ||
export enum QueryType { | ||
AND = "and", | ||
OR = "or", | ||
TEXT = "text" | ||
} | ||
export type Query = { | ||
type: QueryType.AND | QueryType.OR | ||
queries: Query[] | ||
} | TextQuery | ||
export interface EndpointDescription { | ||
@@ -54,0 +58,0 @@ host: string |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
52724
1100
0
2
11
+ Addedisomorphic-fetch@^3.0.0
+ Addedisomorphic-fetch@3.0.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
+ Addedwhatwg-url@5.0.0(transitive)