@financial-times/community-event-client
Advanced tools
Comparing version 0.3.1 to 0.4.0-alpha.1536.0
@@ -6,2 +6,8 @@ # Change Log | ||
# [0.4.0-alpha.1536.0](https://github.com/Financial-Times/community-promo-kit/compare/@financial-times/community-event-client@0.3.1...@financial-times/community-event-client@0.4.0-alpha.1536.0) (2023-06-23) | ||
### Features | ||
- **@financial-times/community-event-client:** added getRecommendedEventsForContent ([49b36f7](https://github.com/Financial-Times/community-promo-kit/commit/49b36f7f433962fbb79a889839f065b9f73f71bb)) | ||
## [0.3.1](https://github.com/Financial-Times/community-promo-kit/compare/@financial-times/community-event-client@0.3.1-alpha.1497.1...@financial-times/community-event-client@0.3.1) (2023-06-08) | ||
@@ -8,0 +14,0 @@ |
import { LiveEventsPollerConfig } from "./live-events-poller-config.model"; | ||
import { LiveEvent } from "./live-events-response.model"; | ||
export declare const refreshIntervalMs: number; | ||
export interface Options extends LiveEventsPollerConfig { | ||
export interface LiveEventsPollerOptions extends LiveEventsPollerConfig { | ||
logger?: { | ||
@@ -9,6 +9,12 @@ error: (message: any) => void; | ||
} | ||
export declare function initLiveEventsPoller(options: Options): void; | ||
export declare function getLiveEvents(logger?: { | ||
warn: (message: any) => void; | ||
}): LiveEvent[]; | ||
export declare function initLiveEventsPoller(options: LiveEventsPollerOptions): void; | ||
export interface GetLiveEventsOptions { | ||
logger?: { | ||
warn: (message: any) => void; | ||
}; | ||
startDate?: Date; | ||
} | ||
export declare function getLiveEvents(options: GetLiveEventsOptions): LiveEvent[]; | ||
export { LiveEvent } from "./live-events-response.model"; | ||
export { getRecommendedEventsForContent } from "./get-recommended-events-for-content"; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLiveEvents = exports.initLiveEventsPoller = exports.refreshIntervalMs = void 0; | ||
exports.getRecommendedEventsForContent = exports.getLiveEvents = exports.initLiveEventsPoller = exports.refreshIntervalMs = void 0; | ||
const live_events_poller_1 = require("./live-events-poller"); | ||
@@ -11,4 +11,4 @@ exports.refreshIntervalMs = 15 * 1000 * 60; | ||
poller = new live_events_poller_1.LiveEventsPoller({ refreshInterval: exports.refreshIntervalMs, ...options }); | ||
poller.start({ initialRequest: true }); | ||
} | ||
poller.start({ initialRequest: true }); | ||
if (logger?.error?.apply) { | ||
@@ -24,9 +24,17 @@ poller.on("error", (error) => { | ||
exports.initLiveEventsPoller = initLiveEventsPoller; | ||
function getLiveEvents(logger) { | ||
function getLiveEvents(options) { | ||
if (poller) { | ||
return poller.getData(); | ||
let events = poller.getData(); | ||
if (options.startDate) { | ||
events = events.filter((event) => { | ||
return (event.startDate && | ||
new Date(event.startDate).getTime() >= | ||
(options?.startDate?.getTime() ?? new Date().getTime())); | ||
}); | ||
} | ||
return events; | ||
} | ||
else { | ||
if (logger?.warn?.apply) { | ||
logger.warn({ | ||
if (options?.logger?.warn?.apply) { | ||
options?.logger.warn({ | ||
event: "LIVE_EVENTS_POLLER_INSTANCE_MISSING", | ||
@@ -39,2 +47,4 @@ }); | ||
exports.getLiveEvents = getLiveEvents; | ||
var get_recommended_events_for_content_1 = require("./get-recommended-events-for-content"); | ||
Object.defineProperty(exports, "getRecommendedEventsForContent", { enumerable: true, get: function () { return get_recommended_events_for_content_1.getRecommendedEventsForContent; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -6,6 +6,6 @@ export interface LiveEvent { | ||
identifiers?: Identifier[]; | ||
startDate: Date; | ||
endDate: Date; | ||
publishedDate?: Date | null; | ||
lastModified: Date; | ||
startDate: string; | ||
endDate: string; | ||
publishedDate?: string | null; | ||
lastModified: string; | ||
brandCategory?: string; | ||
@@ -50,3 +50,3 @@ type?: string; | ||
} | ||
interface Annotation { | ||
export interface Annotation { | ||
apiUrl?: string | null; | ||
@@ -53,0 +53,0 @@ id?: string | null; |
@@ -6,3 +6,3 @@ export { Eventpromo } from "./Eventpromo"; | ||
export { getEventsToPromote } from "./get-events-to-promote"; | ||
export { initLiveEventsPoller, getLiveEvents } from "./live-events-poller"; | ||
export { initLiveEventsPoller, getLiveEvents, LiveEventsPollerOptions, GetLiveEventsOptions, LiveEvent, } from "./live-events-poller"; | ||
//# sourceMappingURL=serverside.d.ts.map |
{ | ||
"name": "@financial-times/community-event-client", | ||
"version": "0.3.1", | ||
"version": "0.4.0-alpha.1536.0", | ||
"description": "A client for retrieving community-events", | ||
@@ -26,3 +26,3 @@ "main": "dist/serverside.js", | ||
}, | ||
"gitHead": "6fb56f96f9205da8fa1443d127cf42817ed46e8d" | ||
"gitHead": "fe73bb87617ceb2cfaac28d6d612906cf04f7f66" | ||
} |
@@ -7,3 +7,3 @@ import { LiveEventsPoller } from "./live-events-poller"; | ||
export interface Options extends LiveEventsPollerConfig { | ||
export interface LiveEventsPollerOptions extends LiveEventsPollerConfig { | ||
logger?: { error: (message) => void }; | ||
@@ -14,3 +14,3 @@ } | ||
export function initLiveEventsPoller(options: Options) { | ||
export function initLiveEventsPoller(options: LiveEventsPollerOptions) { | ||
const { logger } = options; | ||
@@ -20,5 +20,6 @@ | ||
poller = new LiveEventsPoller({ refreshInterval: refreshIntervalMs, ...options }); | ||
poller.start({ initialRequest: true }); | ||
} | ||
poller.start({ initialRequest: true }); | ||
if (logger?.error?.apply) { | ||
@@ -34,8 +35,25 @@ poller.on("error", (error) => { | ||
export function getLiveEvents(logger?: { warn: (message) => void }): LiveEvent[] { | ||
export interface GetLiveEventsOptions { | ||
logger?: { warn: (message) => void }; | ||
startDate?: Date; | ||
} | ||
export function getLiveEvents(options: GetLiveEventsOptions): LiveEvent[] { | ||
if (poller) { | ||
return poller.getData(); | ||
let events = poller.getData(); | ||
if (options.startDate) { | ||
events = events.filter((event) => { | ||
return ( | ||
event.startDate && | ||
new Date(event.startDate).getTime() >= | ||
(options?.startDate?.getTime() ?? new Date().getTime()) | ||
); | ||
}); | ||
} | ||
return events; | ||
} else { | ||
if (logger?.warn?.apply) { | ||
logger.warn({ | ||
if (options?.logger?.warn?.apply) { | ||
options?.logger.warn({ | ||
event: "LIVE_EVENTS_POLLER_INSTANCE_MISSING", | ||
@@ -48,1 +66,4 @@ }); | ||
} | ||
export { LiveEvent } from "./live-events-response.model"; | ||
export { getRecommendedEventsForContent } from "./get-recommended-events-for-content"; |
@@ -6,6 +6,6 @@ export interface LiveEvent { | ||
identifiers?: Identifier[]; | ||
startDate: Date; | ||
endDate: Date; | ||
publishedDate?: Date | null; | ||
lastModified: Date; | ||
startDate: string; | ||
endDate: string; | ||
publishedDate?: string | null; | ||
lastModified: string; | ||
brandCategory?: string; | ||
@@ -56,3 +56,3 @@ type?: string; | ||
interface Annotation { | ||
export interface Annotation { | ||
apiUrl?: string | null; | ||
@@ -59,0 +59,0 @@ id?: string | null; |
@@ -6,2 +6,8 @@ export { Eventpromo } from "./Eventpromo"; | ||
export { getEventsToPromote } from "./get-events-to-promote"; | ||
export { initLiveEventsPoller, getLiveEvents } from "./live-events-poller"; | ||
export { | ||
initLiveEventsPoller, | ||
getLiveEvents, | ||
LiveEventsPollerOptions, | ||
GetLiveEventsOptions, | ||
LiveEvent, | ||
} from "./live-events-poller"; |
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
99598
99
1950