@signaliz/cli 1.0.79 → 1.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +35 -14
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -236,27 +236,48 @@ function firstValidSignalValue(values, normalize) {
|
|
|
236
236
|
}
|
|
237
237
|
return "";
|
|
238
238
|
}
|
|
239
|
+
function publicSignalSummary(value, title) {
|
|
240
|
+
if (!value) return "";
|
|
241
|
+
const severePageChrome = /\[share\]\(mailto:|\blast modified on\b|\bprefer the guardian on google\b|\b(?:business wire|globe newswire)\s*$/i.test(value);
|
|
242
|
+
let cleaned = value.replace(/^#\s*/, "").replace(/^[A-Z][A-Z .'-]+--\((?:BUSINESS WIRE|GLOBE NEWSWIRE)\)--\s*/i, "").replace(/\[(?:share|email)\]\((?:mailto:|https?:\/\/)[^)]+\)/gi, " ").replace(/\bskip to content\b[\s\S]*$/i, " ").replace(/\b(?:explore stocks|trading disclosure)\b[\s\S]*$/i, " ").replace(/\bimage by:\s*([A-Z][A-Za-z0-9.&'-]*)\s+\1\b/gi, "$1").replace(/\bimage by:\s*[^.!?]{1,80}(?=[.!?]|$)/gi, " ").replace(/[^.!?]{0,100}\b(?:logo|image|photo)\b[^.!?]{0,100}[.!?]\s*\((?:Reuters|AP)\)\s*/gi, " ").replace(/(?:(?:read\s*post|read\s*more|keep\s*reading|learn\s*more)\s*)+/gi, " ").replace(/\b(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\s+\d{1,2},\s+\d{4}\b/gi, " ").replace(/\s*\.{3,}\s*/g, " ").replace(/\s+/g, " ").replace(/\s+([,.!?])/g, "$1").trim();
|
|
243
|
+
const sentenceEnds = Array.from(cleaned.matchAll(/[.!?](?=\s+[A-Z]|$)/g));
|
|
244
|
+
const lastSentenceEnd = sentenceEnds[sentenceEnds.length - 1]?.index ?? -1;
|
|
245
|
+
if (cleaned.length > 240 && lastSentenceEnd >= 100 && cleaned.length - lastSentenceEnd > 20) {
|
|
246
|
+
cleaned = cleaned.slice(0, lastSentenceEnd + 1);
|
|
247
|
+
}
|
|
248
|
+
const metadataAfterTitle = /\b(?:\d+\s+min(?:ute)?s?\s+read|news\s+\d+\s+mins?)\b/i.test(cleaned);
|
|
249
|
+
if (title && cleaned.toLowerCase().startsWith(title.toLowerCase())) {
|
|
250
|
+
const remainder = cleaned.slice(title.length).replace(/^\s*(?:[:|\-–—]\s*)?/, "");
|
|
251
|
+
if (/^(?:[A-Z]|news\b)/.test(remainder)) cleaned = remainder;
|
|
252
|
+
}
|
|
253
|
+
cleaned = cleaned.replace(/^By\s+\[[^\]]+\]\(https?:\/\/[^)]+\)\s*-\s*/i, "").replace(/^\[[^\]]+\]\(https?:\/\/[^)]*\/(?:wp-content|images?)\/[^)]+\)\s*/i, "").trim();
|
|
254
|
+
const key = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
255
|
+
const cleanedKey = key(cleaned);
|
|
256
|
+
const titleKey = key(title);
|
|
257
|
+
return severePageChrome || metadataAfterTitle || !cleaned || /^(?:api)$/i.test(cleaned) || titleKey && (cleanedKey === titleKey || cleanedKey === `${titleKey} ${titleKey}`) ? title : cleaned;
|
|
258
|
+
}
|
|
239
259
|
function publicSignalRow(value, fallbackCompany) {
|
|
240
260
|
const signal = record(value);
|
|
241
261
|
const raw = record(signal.raw_data);
|
|
242
262
|
const company = record(signal.company);
|
|
243
263
|
const rawCompany = record(raw.company);
|
|
244
264
|
const fallback = record(fallbackCompany);
|
|
265
|
+
const signalTitle = firstValidSignalValue([
|
|
266
|
+
signal.signal_title,
|
|
267
|
+
signal.signalTitle,
|
|
268
|
+
raw.signal_title,
|
|
269
|
+
raw.signalTitle,
|
|
270
|
+
signal.title,
|
|
271
|
+
raw.title,
|
|
272
|
+
signal.headline,
|
|
273
|
+
raw.headline,
|
|
274
|
+
signal.name,
|
|
275
|
+
raw.name
|
|
276
|
+
], signalText);
|
|
245
277
|
const row = {
|
|
246
278
|
signal_type: publicSignalType(signal),
|
|
247
|
-
signal_title:
|
|
248
|
-
|
|
249
|
-
signal.signalTitle,
|
|
250
|
-
raw.signal_title,
|
|
251
|
-
raw.signalTitle,
|
|
252
|
-
signal.title,
|
|
253
|
-
raw.title,
|
|
254
|
-
signal.headline,
|
|
255
|
-
raw.headline,
|
|
256
|
-
signal.name,
|
|
257
|
-
raw.name
|
|
258
|
-
], signalText),
|
|
259
|
-
signal_summary: firstValidSignalValue([
|
|
279
|
+
signal_title: signalTitle,
|
|
280
|
+
signal_summary: publicSignalSummary(firstValidSignalValue([
|
|
260
281
|
signal.signal_summary,
|
|
261
282
|
signal.signalSummary,
|
|
262
283
|
raw.signal_summary,
|
|
@@ -271,7 +292,7 @@ function publicSignalRow(value, fallbackCompany) {
|
|
|
271
292
|
raw.content,
|
|
272
293
|
signal.description,
|
|
273
294
|
raw.description
|
|
274
|
-
], signalText),
|
|
295
|
+
], signalText), signalTitle),
|
|
275
296
|
source: firstValidSignalValue([
|
|
276
297
|
signal.canonical_source_url,
|
|
277
298
|
signal.canonicalSourceUrl,
|
package/package.json
CHANGED