@versini/sassysaint-common 4.67.0 → 4.68.0

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/index.d.ts CHANGED
@@ -557,6 +557,8 @@ export declare const isHardCategory: (category: string) => boolean;
557
557
  */
558
558
  export declare const isModelAllowedForPlan: (selectedModel: string | undefined | null, allowedModels: string[]) => boolean;
559
559
 
560
+ export declare function isNewsImageUrl(value: unknown): value is string;
561
+
560
562
  /**
561
563
  * Runtime guard: true only for a real, SDK-instantiable provider literal.
562
564
  * Returns false for undefined, null, and anything else. Shared by the server
@@ -840,6 +842,7 @@ export declare const MODELS_PER_PROVIDER: {
840
842
  export declare interface NewsBrief {
841
843
  asOf: string;
842
844
  note?: string;
845
+ place?: string;
843
846
  earlier?: {
844
847
  chatId: string;
845
848
  time: string;
@@ -854,6 +857,7 @@ export declare interface NewsBriefItem {
854
857
  title: string;
855
858
  summary: string;
856
859
  local: boolean;
860
+ image?: string;
857
861
  evidence: NewsEvidence[];
858
862
  commentary?: NewsCommentary[];
859
863
  }
@@ -1 +1 @@
1
- function t(t){return"string"==typeof t&&""!==t.trim()}let e=new Set(['"',"\\","/","b","f","n","r","t","u"]),r={"\n":"\\n","\r":"\\r"," ":"\\t"};function n(t){return t.replace(/\\([\\|[\]])/g,"$1")}function a(e){if(!t(e))return!1;try{let{protocol:t}=new URL(e);return"http:"===t||"https:"===t}catch{return!1}}function l(e,r){return Array.isArray(e)?e.flatMap(e=>{let{author:l,newsletter:i,title:u,url:f,summary:o}=e??{};return!t(l)||!t(i)||!t(u)||!t(o)||!a(f)||r.has(f)?[]:(r.add(f),[{author:n(l),newsletter:i,title:n(u),url:f,summary:o}])}):[]}function i(i){let u,f=i.trim();if(!f||f.length>4e4)return null;try{u=function(t){try{return JSON.parse(t)}catch{return JSON.parse(function(t){let n="",a=!1;for(let l=0;l<t.length;l++){let i=t[l];if(a)if("\\"===i){let r=t[l+1]??"";n+=e.has(r)?`\\${r}`:`\\\\${r}`,l++}else'"'===i?(a=!1,n+=i):i<" "?n+=r[i]??`\\u${i.charCodeAt(0).toString(16).padStart(4,"0")}`:n+=i;else a='"'===i,n+=i}return n}(t))}}(f)}catch{return null}if(!u||!t(u.asOf)||!Array.isArray(u.items))return null;let o=new Set,s=function(e){let{title:r,url:l,line:i}=e??{};return t(r)&&a(l)&&t(i)?{title:n(r),url:l,line:i}:void 0}(u.onThisDay),c=new Set(s?[s.url]:[]),h=u.items.flatMap(e=>{let{id:r,title:i,summary:u,local:f,evidence:s,commentary:h}=e??{};if(!t(r)||o.has(r)||!t(i)||!t(u))return[];o.add(r);let d=l(h,c);return[{id:r,title:i,summary:u,local:!0===f,evidence:function(e){if(!Array.isArray(e))return[];let r=new Set;return e.flatMap(e=>{let{outlet:l,headline:i,url:u}=e??{};return!t(l)||!t(i)||!a(u)||r.has(u)?[]:(r.add(u),[{outlet:n(l),headline:n(i),url:u}])})}(s),...d.length>0?{commentary:d}:{}}]}),d=l(u.otherCommentary,c),m=u.earlier;return{asOf:u.asOf,...t(u.note)?{note:u.note}:{},...m&&t(m.chatId)&&t(m.time)?{earlier:{chatId:m.chatId,time:m.time}}:{},items:h,...d.length>0?{otherCommentary:d}:{},...s?{onThisDay:s}:{}}}let u=/^[^\S\n]{0,3}```(\w*)[^\S\n]*\n([\s\S]*?)\n[^\S\n]{0,3}```/gm;function f(t){for(let[,e,r]of t.matchAll(u))if("newsbrief"===e.toLowerCase()||""===e&&/"asOf"/.test(r)){let t=i(r);if(t)return t}return null}export{f as findNewsBrief,i as parseNewsBrief};
1
+ let t=/^https:\/\/encrypted-tbn\d\.gstatic\.com\/images\?q=tbn:[\w-]+$/;function e(e){return"string"==typeof e&&t.test(e)}function r(t){return"string"==typeof t&&""!==t.trim()}let n=new Set(['"',"\\","/","b","f","n","r","t","u"]),a={"\n":"\\n","\r":"\\r"," ":"\\t"};function l(t){return t.replace(/\\([\\|[\]])/g,"$1")}function i(t){if(!r(t))return!1;try{let{protocol:e}=new URL(t);return"http:"===e||"https:"===e}catch{return!1}}function u(t,e){return Array.isArray(t)?t.flatMap(t=>{let{author:n,newsletter:a,title:u,url:f,summary:s}=t??{};return!r(n)||!r(a)||!r(u)||!r(s)||!i(f)||e.has(f)?[]:(e.add(f),[{author:l(n),newsletter:a,title:l(u),url:f,summary:s}])}):[]}function f(t){let f,s=t.trim();if(!s||s.length>4e4)return null;try{f=function(t){try{return JSON.parse(t)}catch{return JSON.parse(function(t){let e="",r=!1;for(let l=0;l<t.length;l++){let i=t[l];if(r)if("\\"===i){let r=t[l+1]??"";e+=n.has(r)?`\\${r}`:`\\\\${r}`,l++}else'"'===i?(r=!1,e+=i):i<" "?e+=a[i]??`\\u${i.charCodeAt(0).toString(16).padStart(4,"0")}`:e+=i;else r='"'===i,e+=i}return e}(t))}}(s)}catch{return null}if(!f||!r(f.asOf)||!Array.isArray(f.items))return null;let o=new Set,c=function(t){let{title:e,url:n,line:a}=t??{};return r(e)&&i(n)&&r(a)?{title:l(e),url:n,line:a}:void 0}(f.onThisDay),h=new Set(c?[c.url]:[]),p=f.items.flatMap(t=>{let{id:n,title:a,summary:f,local:s,image:c,evidence:p,commentary:d}=t??{};if(!r(n)||o.has(n)||!r(a)||!r(f))return[];o.add(n);let m=u(d,h);return[{id:n,title:a,summary:f,local:!0===s,...e(c)?{image:c}:{},evidence:function(t){if(!Array.isArray(t))return[];let e=new Set;return t.flatMap(t=>{let{outlet:n,headline:a,url:u}=t??{};return!r(n)||!r(a)||!i(u)||e.has(u)?[]:(e.add(u),[{outlet:l(n),headline:l(a),url:u}])})}(p),...m.length>0?{commentary:m}:{}}]}),d=u(f.otherCommentary,h),m=f.earlier;return{asOf:f.asOf,...r(f.note)?{note:f.note}:{},...r(f.place)?{place:f.place}:{},...m&&r(m.chatId)&&r(m.time)?{earlier:{chatId:m.chatId,time:m.time}}:{},items:p,...d.length>0?{otherCommentary:d}:{},...c?{onThisDay:c}:{}}}let s=/^[^\S\n]{0,3}```(\w*)[^\S\n]*\n([\s\S]*?)\n[^\S\n]{0,3}```/gm;function o(t){for(let[,e,r]of t.matchAll(s))if("newsbrief"===e.toLowerCase()||""===e&&/"asOf"/.test(r)){let t=f(r);if(t)return t}return null}export{o as findNewsBrief,e as isNewsImageUrl,f as parseNewsBrief};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/sassysaint-common",
3
- "version": "4.67.0",
3
+ "version": "4.68.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {