@bicharts/shape-core 0.6.25 → 0.6.27
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.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/wireBuild.d.ts +30 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{a as Un,b as Qn}from"./chunk-UQU75XXR.mjs";import{a as jn,b as qn,c as Xn,d as Zn,e as f,f as Yn,g as Jn,h as et}from"./chunk-BIC73LQV.mjs";import{a as zn,b as Bn,c as Wn,d as $n,e as Hn}from"./chunk-PK6KRKNE.mjs";import{A as wn,B as Tn,C as Mn,D as An,E as In,F as Ln,G as kn,H as En,I as On,J as _n,K as Dn,L as Gn,M as Vn,O as Kn,a as Ze,b as Ye,c as Je,d as en,e as on,f as sn,g as an,h as ln,i as un,j as cn,k as dn,l as fn,m as mn,n as pn,o as gn,p as yn,q as Cn,r as hn,s as bn,t as Sn,u as Pn,v as Rn,w as xn,x as vn,y as Fn,z as Nn}from"./chunk-ZVHCLXKO.mjs";import{a as nn}from"./chunk-QEH7WTLB.mjs";import{a as tn,b as rn}from"./chunk-2LR73DNS.mjs";import{a as j,b as q,c as Qe,d as je,e as qe,f as Xe}from"./chunk-C5I73OM2.mjs";import{a as M,f as A,g as S,h as I,i as D,j as De,k as Ge,l as Q,m as y,n as Ve,o as Ke,p as ze,q as L,r as Be,s as We,t as $e,u as He,v as G,w as Ue}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as Ee,b as Oe,c as _e}from"./chunk-35Z7JCND.mjs";import{A as ke,a as le,b as ue,c as ce,d as de,e as fe,f as me,g as pe,h as ge,i as ye,j as Ce,k as he,l as be,m as Se,n as Pe,o as Re,p as xe,r as ve,s as Fe,t as Ne,u as we,v as Te,w as Me,x as Ae,y as Ie,z as Le}from"./chunk-ILHBRGIO.mjs";var V=2,Y=400;function z(e){return!!A(e)}function F(e){let n=new Set;for(let t of e){if(t==null)continue;let o=M(String(t));if(!I(o)&&!n.has(o)&&(n.add(o),n.size>=Y))break}return Array.from(n)}function v(e){let n=F(e);if(n.length===0||B(e)<95)return!1;let t=n.filter(u=>z(u)&&!y(u)).length,o=n.filter(u=>!z(u)&&!!y(u)).length;return t>=1&&t>=o}function X(e,n){if(!y(e))return!1;let t=A(e);return t?n==="world"?!0:Q.has(t):!1}function B(e){let n=F(e);if(n.length===0)return 0;let t=0;for(let o of n)z(o)&&t++;return Math.round(t/n.length*1e3)/10}function k(e){let n=F(e);if(n.length===0)return 0;let t=0;for(let o of n)y(o)&&t++;return Math.round(t/n.length*1e3)/10}function $(e){let n=new Set;for(let t of e){if(t==null)continue;let o=String(t).trim();if(!I(M(o))&&!n.has(o)&&(n.add(o),n.size>=Y))break}return Array.from(n)}function W(e){let n=$(e);if(n.length===0)return 0;let t=0;for(let o of n)L(o).length>0&&t++;return Math.round(t/n.length*1e3)/10}function Z(e,n){return q(n,j)?!0:$(e).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function nt(e,n){let t=F(e);if(t.length===0)return 0;let o=0;for(let u of t)G(u,n)&&o++;return Math.round(o/t.length*1e3)/10}function K(e,n){let t=0;for(let o of F(e))n(o)&&t++;return t}function tt(e,n){let t=0;for(let o of $(e))n(o)&&t++;return t}function rt(e,n,t,o,u){let a=[],s=[],i={},C={},R=new Set(e),m=r=>n.map(l=>l[r]);for(let r of["city","country"]){let l=t?.[r];l&&R.has(l)&&(i[r]=l)}let ie=new Set(u??e);for(let r of["lat","lon"]){let l=t?.[r];l&&ie.has(l)&&(i[r]=l)}let h=t?.zip;if(h&&R.has(h)){let r=m(h),l=W(r);l<95?s.push(`zip=${h} (only ${l}% of values read as ZIPs)`):Z(r,h)?i.zip=h:s.push(`zip=${h} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&R.has(g)){let r=m(g),l=F(r);l.length>0&&l.every(d=>X(d,o))?s.push(`state=${g} (every value is "CA", which is both Canada and California)`):v(r)?(s.push(`state=${g} (every value is a country, not a state)`),i.country||(i.country=g)):k(r)<95?s.push(`state=${g} (only ${k(r)}% of values are states/provinces)`):i.state=g}let b=new Set(Object.values(i).filter(Boolean)),w=e.filter(r=>!b.has(r)&&!r.startsWith("__"));if(!i.state){let r=null;for(let l of w){let d=m(l);if(v(d))continue;let p=k(d);if(p<95)continue;let _=K(d,T=>!!y(T)),ae=K(d,T=>!!y(T)&&!X(T,o));_<V&&ae<1||(!r||p>r.pct)&&(r={name:l,pct:p})}r&&(i.state=r.name,b.add(r.name),a.push(`state=${r.name} (${r.pct}% states/provinces)`))}if(!i.zip)for(let r of w){if(b.has(r))continue;let l=m(r),d=W(l);if(!(d<95)&&Z(l,r)&&!(tt(l,p=>L(p).length>0)<V)){i.zip=r,b.add(r),a.push(`zip=${r} (${d}% ZIP codes)`);break}}let x=i.country;if(!x||!v(m(x))){let r=null;for(let l of w){if(b.has(l)||!v(m(l)))continue;let d=B(m(l));(!r||d>r.pct)&&(r={name:l,pct:d})}r&&(x&&(s.push(`country=${x} (only ${B(m(x))}% of values are country identifiers; using ${r.name} instead)`),C.country=x),i.country=r.name,b.add(r.name),a.push(`country=${r.name}`))}if(!i.city){let r=null;for(let l of w){if(b.has(l))continue;let d=m(l),p=nt(d,o);p<D||K(d,_=>G(_,o))<V||(!r||p>r.pct)&&(r={name:l,pct:p})}r&&(i.city=r.name,a.push(`city=${r.name} (${r.pct}% known cities)`))}let H=i.country?m(i.country):[],E=!!i.country&&v(H),se=E?new Set(H.map(r=>A(r==null?null:String(r))).filter(Boolean)).size:0,U=E&&se>=2,O=!!(i.lat&&i.lon)&&n.some(r=>{let l=+String(r[i.lat]??"").trim(),d=+String(r[i.lon]??"").trim();return isFinite(l)&&isFinite(d)&&l>=-90&&l<=90&&d>=-180&&d<=180&&String(r[i.lat]??"").trim()!==""&&String(r[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!O&&s.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!U&&!(i.city||i.state||i.zip||O)&&s.push(E?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||U||O)?i:null,backfilled:a,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}function J(e,n){let t=n?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(e)||e<=t?0:Math.round(e-t)}function ot(e,n,t){let o=J(e,n);if(o===null||o<=0)return null;let u=typeof n?.freemiumColumnCapPivot=="number"?n.freemiumColumnCapPivot:4,a=o>u?n?.freemiumColumnCapMessageMany:n?.freemiumColumnCapMessageFew;if(typeof a!="string"||a.trim().length===0)return null;let s=a.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=ee(t);return i.length===0?s:s+" "+i.join(" ")}function ee(e){if(!e||e.length===0)return[];let n=[],t=new Map,o=new Map;for(let a of e){let s=typeof a?.dateGroupId=="string"?a.dateGroupId.trim():"";if(s!==""&&(t.has(s)||(n.push(s),t.set(s,0)),a.isDatePart===!0&&t.set(s,t.get(s)+1),a.isReassembledDate===!0&&!o.has(s))){let i=typeof a.sourceField=="string"?a.sourceField.trim():"",C=typeof a.name=="string"?a.name.trim():"",R=i!==""?i:C;R!==""&&o.set(s,R)}}let u=[];for(let a of n){let s=o.get(a),i=t.get(a)??0;!s||i===0||u.push(`'${s}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return u}var c=e=>e==null?"":String(e),P=e=>e===!0,ne=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);return Number.isFinite(n)?n:null}return null},it=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function te(e,n){let t={};for(let[o,u]of it){let a=c(f(e,n+u));a&&(t[o]=a)}return t}function st(e){let n=a=>f(e,a),t=n("retryAfterSeconds"),o=te(e,"point"),u=te(e,"destPoint");return Object.keys(u).length&&(o.dest=u),{errorMessage:c(n("errorMessage")),code:c(n("code")),language:c(n("language")),version:Number(n("version")??0),codeSummary:c(n("codeSummary")),chartName:c(n("chartName")??n("chartType")),finalChartName:c(n("finalChartName")),warningMessage:c(n("warningMessage")),outputHash:c(n("outputHash")),validatorToken:c(n("validatorToken")),editCodeKey:c(n("editCodeKey")),signedLLMRequestID:c(n("signedLLMRequestID")),userReply:c(n("userReply")),userReplyOutcome:c(n("userReplyOutcome")),improvementSuggestion:c(n("improvementSuggestion")),geoColumn:c(n("geoColumn")),geoKind:c(n("geoKind")),geoPointCols:Object.keys(o).length?o:null,creditBalanceBefore:ne(n("creditBalanceBefore")),creditCost:ne(n("creditCost")),isServiceError:P(n("isServiceError")),isRateLimited:P(n("isRateLimited")),isRefusal:P(n("isRefusal")),isVersionNotFound:P(n("isVersionNotFound")),isGenerationCancelled:P(n("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:c(n("servedCorrelationId"))}}var re=e=>e==null?void 0:Number(e),N=e=>c(e)||void 0;function at(e){let n=f(e,"charts"),t=f(e,"refused"),o=Array.isArray(n)?n.map(a=>{let s=C=>f(a,C),i=s("recommended");return{name:c(s("chartTypeName")??s("name")),description:c(s("description")??s("chartDesc")),rank:re(s("rank")),score:re(s("score")),renderer:N(s("renderer")),language:N(s("language")),isPreview:P(s("isPreview")),recommended:typeof i=="boolean"?i:void 0,viaProjection:N(s("viaProjection")),viaProjectionKey:N(s("viaProjectionKey")),detailNote:N(s("detailNote"))}}).filter(a=>a.name):null,u=Array.isArray(t)?t.map(a=>({name:c(f(a,"chartTypeName")??f(a,"name")),reason:c(f(a,"reason")),isVeto:P(f(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:c(f(e,"errorMessage")),charts:o,refused:u,noFitSummary:c(f(e,"noFitSummary"))}}function lt(e){return!e||typeof e!="object"?null:{status:String(f(e,"status")??""),verdictReason:f(e,"verdictReason")??null,instruction:f(e,"instruction")??null,fix:f(e,"fix")??null,errorMessage:f(e,"errorMessage")??null}}function ut(e){let n=e.linkNonce?(e.linkNonce()??"").trim():null,t=n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:t.licenseKey,licensee:t.licensee,secretKey:t.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:n}}function ct(e){let{width:n,height:t}=e.measure();return{request:{height:t,width:n},hints:{viewportWidth:n,viewportHeight:t}}}function dt(e){let n=0;for(let t of e){if(t.isMeasure)continue;let o=t.distinctCount;typeof o=="number"&&o>n&&(n=o)}return n}function oe(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let n=e.settingVersion??null;if(e.genNew)return{version:n,fetchOnly:void 0};let t=(n??0)>0?n:null,o=(e.codeVersion??0)>0?e.codeVersion:null,u=t??o??n;return{version:u,fetchOnly:u!=null&&u>0?!0:void 0}}function ft(e){let n=e.fetchCorrelationId!=null,o=n||e.recoveryFetchVersion!=null?!1:e.genNew,u=oe({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:n,settingVersion:e.settingVersion,codeVersion:e.codeVersion});return{genNew:o,version:u.version,fetchOnly:u.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0}}function mt(e){let n=t=>e.renderers.has(t);return{supportsD3:n("D3"),supportsPlotly:n("PLOTLY"),supportsVega:n("VEGA")}}function pt(e){let n=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??n,maxTries:n}}function gt(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}export{D as CITY_ROLE_MATCH_PCT,Ce as COMPOUND_MIN_STEM,vn as DEFAULT_GAP_FACTOR,we as DEFAULT_TEMPERATURE,Fe as GET_RANDOM,be as GLUED_STEM_MIN,sn as INTENSIVE_SUFFIX_TOKENS,on as INTENSIVE_WORD_TOKENS,Kn as IndexedText,Fn as MAX_RUN_BOUNDS,ln as POSITIONAL_SUFFIX_TOKENS,an as POSITIONAL_WORD_TOKENS,Un as PREVIEW_OMITTED_FIELDS,S as ROLE_MATCH_PCT,Tn as SERIES_COMPLETENESS_MAX_LISTED,Mn as SERIES_COMPLETENESS_MIN_FILL,An as SERIES_KEY_MAX_DISTINCT,ve as SIMPLE_STRING_HASH,xe as STR,Pe as SUBSTRING_MIN,le as SUPPORTED_LANGUAGES,ue as SUPPORTED_LANGUAGE_CODES,k as admin1MatchPct,Cn as allowedAggregations,Xe as buildGeoIsoColumn,$e as buildGeoPointColumns,mt as capabilityFields,Ue as cityMatchPct,He as cityTagsFor,Gn as classifyAdditivity,yn as classifyForAggregation,Vn as classifyNumericValueNature,_n as classifyTemporal,fn as codeNeedsLegacyAggNames,Pn as codeReadsColumn,Rn as codeReadsColumnsByRoleOrPosition,dn as collapseRepeatedAggPrefix,xn as columnsTheCodeReads,Je as countryRegion,ut as credentialFields,zn as decimalSeparatorOf,hn as defaultAggregation,Bn as detectDecimalSeparator,nn as detectFormatSignature,Qe as detectGeo,_e as detectOrdinalDomain,On as detectTextDatePattern,qn as encodePayload,$n as engineTypeForSqlType,mn as englishImplicitAggNames,ft as fetchFields,fe as foldName,ot as freemiumColumnCapRefusal,J as freemiumColumnsOverCap,ee as freemiumDateHierarchyClauses,Se as gluedPrefixStems,jn as gzipWireText,cn as hasDefaultAggPrefix,ge as hasUnsegmentedScript,Dn as hostAggHint,Hn as ingest,bn as isAggregationAllowed,I as isBlankLike,Ge as isCityTableLoaded,Ne as isDeterministicRefusal,Be as isGeoPointAmbiguity,En as isIdentifierName,qe as isJoinGeoKind,Yn as isNdjsonContentType,Ee as isOrdinalFriendlyName,Xn as keyedSigner,gt as leafCardinalityField,Le as localMidnightDateColumns,Ie as localMidnightToUtcDay,v as looksLikeCountryColumn,Re as matchNameToken,dt as maxNonMeasureCardinality,wn as measureCadence,kn as measureSeriesCompleteness,Zn as messageSignature,rn as monthLookupFor,gn as nameLooksIntensiveRate,pn as nameLooksPositional,me as nameWords,Ve as normalizeCountry,ke as normalizeLocalMidnightDates,tn as normalizeMonthKey,M as normalizePlaceName,ze as normalizeZip5,Te as parseDateStable,st as parseGenerateResponse,Wn as parseNumberText,at as parseQualifyResponse,lt as parseReviewVerdict,Nn as parseTemporalPoint,Qn as payloadPreview,Ln as pickSeriesColumn,et as readGenerateStream,pe as readName,f as readWireField,De as registerCityTable,Ye as registerIso3Regions,y as resolveAdmin1,oe as resolveFetchVersion,We as resolveGeoPoint,de as resolveLanguage,rt as resolvePointRoles,pt as retryFields,Oe as safeDistinctValuesToShip,In as seriesKeyVerdict,Sn as shareOfTotalIsHonest,un as stripHostAggPrefix,en as summarizeCountryRegions,Ze as summarizeGeoExtent,ce as supportedLanguage,je as toGeoIso,ye as unsegmentedRuns,ct as viewportFields,Me as wholeDayFrame,Ae as wholeDayIso,Jn as wireResponseFromFetch,he as wordEndsWith,W as zipMatchPct,L as zipPrefixCandidates,Ke as zipToPrefix3};
|
|
2
|
+
import{a as jn,b as Qn}from"./chunk-UQU75XXR.mjs";import{a as qn,b as Xn,c as Zn,d as Yn,e as f,f as Jn,g as et,h as nt}from"./chunk-BIC73LQV.mjs";import{a as Bn,b as Wn,c as $n,d as Hn,e as Un}from"./chunk-PK6KRKNE.mjs";import{A as Tn,B as Nn,C as An,D as In,E as Ln,F as kn,G as En,H as On,I as _n,J as Dn,K as Gn,L as Vn,M as Kn,O as zn,a as Ye,b as Je,c as en,d as nn,e as sn,f as an,g as ln,h as un,i as cn,j as dn,k as fn,l as mn,m as pn,n as gn,o as yn,p as Cn,q as hn,r as bn,s as Sn,t as xn,u as Pn,v as Rn,w as vn,x as Fn,y as Mn,z as wn}from"./chunk-ZVHCLXKO.mjs";import{a as tn}from"./chunk-QEH7WTLB.mjs";import{a as rn,b as on}from"./chunk-2LR73DNS.mjs";import{a as Q,b as q,c as Qe,d as qe,e as Xe,f as Ze}from"./chunk-C5I73OM2.mjs";import{a as N,f as A,g as S,h as I,i as D,j as Ge,k as Ve,l as j,m as y,n as Ke,o as ze,p as Be,q as L,r as We,s as $e,t as He,u as Ue,v as G,w as je}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as Oe,b as _e,c as De}from"./chunk-35Z7JCND.mjs";import{A as Ee,a as ue,b as ce,c as de,d as fe,e as me,f as pe,g as ge,h as ye,i as Ce,j as he,k as be,l as Se,m as xe,n as Pe,o as Re,p as ve,r as Fe,s as Me,t as we,u as Te,v as Ne,w as Ae,x as Ie,y as Le,z as ke}from"./chunk-ILHBRGIO.mjs";var V=2,Y=400;function z(e){return!!A(e)}function F(e){let n=new Set;for(let t of e){if(t==null)continue;let o=N(String(t));if(!I(o)&&!n.has(o)&&(n.add(o),n.size>=Y))break}return Array.from(n)}function v(e){let n=F(e);if(n.length===0||B(e)<95)return!1;let t=n.filter(u=>z(u)&&!y(u)).length,o=n.filter(u=>!z(u)&&!!y(u)).length;return t>=1&&t>=o}function X(e,n){if(!y(e))return!1;let t=A(e);return t?n==="world"?!0:j.has(t):!1}function B(e){let n=F(e);if(n.length===0)return 0;let t=0;for(let o of n)z(o)&&t++;return Math.round(t/n.length*1e3)/10}function k(e){let n=F(e);if(n.length===0)return 0;let t=0;for(let o of n)y(o)&&t++;return Math.round(t/n.length*1e3)/10}function $(e){let n=new Set;for(let t of e){if(t==null)continue;let o=String(t).trim();if(!I(N(o))&&!n.has(o)&&(n.add(o),n.size>=Y))break}return Array.from(n)}function W(e){let n=$(e);if(n.length===0)return 0;let t=0;for(let o of n)L(o).length>0&&t++;return Math.round(t/n.length*1e3)/10}function Z(e,n){return q(n,Q)?!0:$(e).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function tt(e,n){let t=F(e);if(t.length===0)return 0;let o=0;for(let u of t)G(u,n)&&o++;return Math.round(o/t.length*1e3)/10}function K(e,n){let t=0;for(let o of F(e))n(o)&&t++;return t}function rt(e,n){let t=0;for(let o of $(e))n(o)&&t++;return t}function ot(e,n,t,o,u){let a=[],s=[],i={},C={},P=new Set(e),m=r=>n.map(l=>l[r]);for(let r of["city","country"]){let l=t?.[r];l&&P.has(l)&&(i[r]=l)}let se=new Set(u??e);for(let r of["lat","lon"]){let l=t?.[r];l&&se.has(l)&&(i[r]=l)}let h=t?.zip;if(h&&P.has(h)){let r=m(h),l=W(r);l<95?s.push(`zip=${h} (only ${l}% of values read as ZIPs)`):Z(r,h)?i.zip=h:s.push(`zip=${h} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&P.has(g)){let r=m(g),l=F(r);l.length>0&&l.every(d=>X(d,o))?s.push(`state=${g} (every value is "CA", which is both Canada and California)`):v(r)?(s.push(`state=${g} (every value is a country, not a state)`),i.country||(i.country=g)):k(r)<95?s.push(`state=${g} (only ${k(r)}% of values are states/provinces)`):i.state=g}let b=new Set(Object.values(i).filter(Boolean)),w=e.filter(r=>!b.has(r)&&!r.startsWith("__"));if(!i.state){let r=null;for(let l of w){let d=m(l);if(v(d))continue;let p=k(d);if(p<95)continue;let _=K(d,T=>!!y(T)),le=K(d,T=>!!y(T)&&!X(T,o));_<V&&le<1||(!r||p>r.pct)&&(r={name:l,pct:p})}r&&(i.state=r.name,b.add(r.name),a.push(`state=${r.name} (${r.pct}% states/provinces)`))}if(!i.zip)for(let r of w){if(b.has(r))continue;let l=m(r),d=W(l);if(!(d<95)&&Z(l,r)&&!(rt(l,p=>L(p).length>0)<V)){i.zip=r,b.add(r),a.push(`zip=${r} (${d}% ZIP codes)`);break}}let R=i.country;if(!R||!v(m(R))){let r=null;for(let l of w){if(b.has(l)||!v(m(l)))continue;let d=B(m(l));(!r||d>r.pct)&&(r={name:l,pct:d})}r&&(R&&(s.push(`country=${R} (only ${B(m(R))}% of values are country identifiers; using ${r.name} instead)`),C.country=R),i.country=r.name,b.add(r.name),a.push(`country=${r.name}`))}if(!i.city){let r=null;for(let l of w){if(b.has(l))continue;let d=m(l),p=tt(d,o);p<D||K(d,_=>G(_,o))<V||(!r||p>r.pct)&&(r={name:l,pct:p})}r&&(i.city=r.name,a.push(`city=${r.name} (${r.pct}% known cities)`))}let H=i.country?m(i.country):[],E=!!i.country&&v(H),ae=E?new Set(H.map(r=>A(r==null?null:String(r))).filter(Boolean)).size:0,U=E&&ae>=2,O=!!(i.lat&&i.lon)&&n.some(r=>{let l=+String(r[i.lat]??"").trim(),d=+String(r[i.lon]??"").trim();return isFinite(l)&&isFinite(d)&&l>=-90&&l<=90&&d>=-180&&d<=180&&String(r[i.lat]??"").trim()!==""&&String(r[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!O&&s.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!U&&!(i.city||i.state||i.zip||O)&&s.push(E?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||U||O)?i:null,backfilled:a,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}function J(e,n){let t=n?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(e)||e<=t?0:Math.round(e-t)}function it(e,n,t){let o=J(e,n);if(o===null||o<=0)return null;let u=typeof n?.freemiumColumnCapPivot=="number"?n.freemiumColumnCapPivot:4,a=o>u?n?.freemiumColumnCapMessageMany:n?.freemiumColumnCapMessageFew;if(typeof a!="string"||a.trim().length===0)return null;let s=a.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=ee(t);return i.length===0?s:s+" "+i.join(" ")}function ee(e){if(!e||e.length===0)return[];let n=[],t=new Map,o=new Map;for(let a of e){let s=typeof a?.dateGroupId=="string"?a.dateGroupId.trim():"";if(s!==""&&(t.has(s)||(n.push(s),t.set(s,0)),a.isDatePart===!0&&t.set(s,t.get(s)+1),a.isReassembledDate===!0&&!o.has(s))){let i=typeof a.sourceField=="string"?a.sourceField.trim():"",C=typeof a.name=="string"?a.name.trim():"",P=i!==""?i:C;P!==""&&o.set(s,P)}}let u=[];for(let a of n){let s=o.get(a),i=t.get(a)??0;!s||i===0||u.push(`'${s}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return u}var c=e=>e==null?"":String(e),x=e=>e===!0,ne=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);return Number.isFinite(n)?n:null}return null},st=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function te(e,n){let t={};for(let[o,u]of st){let a=c(f(e,n+u));a&&(t[o]=a)}return t}function at(e){let n=a=>f(e,a),t=n("retryAfterSeconds"),o=te(e,"point"),u=te(e,"destPoint");return Object.keys(u).length&&(o.dest=u),{errorMessage:c(n("errorMessage")),code:c(n("code")),language:c(n("language")),version:Number(n("version")??0),codeSummary:c(n("codeSummary")),chartName:c(n("chartName")??n("chartType")),finalChartName:c(n("finalChartName")),warningMessage:c(n("warningMessage")),outputHash:c(n("outputHash")),validatorToken:c(n("validatorToken")),editCodeKey:c(n("editCodeKey")),signedLLMRequestID:c(n("signedLLMRequestID")),userReply:c(n("userReply")),userReplyOutcome:c(n("userReplyOutcome")),improvementSuggestion:c(n("improvementSuggestion")),geoColumn:c(n("geoColumn")),geoKind:c(n("geoKind")),geoPointCols:Object.keys(o).length?o:null,creditBalanceBefore:ne(n("creditBalanceBefore")),creditCost:ne(n("creditCost")),isServiceError:x(n("isServiceError")),isRateLimited:x(n("isRateLimited")),isRefusal:x(n("isRefusal")),isVersionNotFound:x(n("isVersionNotFound")),isGenerationCancelled:x(n("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:c(n("servedCorrelationId"))}}var re=e=>e==null?void 0:Number(e),M=e=>c(e)||void 0;function lt(e){let n=f(e,"charts"),t=f(e,"refused"),o=Array.isArray(n)?n.map(a=>{let s=C=>f(a,C),i=s("recommended");return{name:c(s("chartTypeName")??s("name")),description:c(s("description")??s("chartDesc")),rank:re(s("rank")),score:re(s("score")),renderer:M(s("renderer")),language:M(s("language")),isPreview:x(s("isPreview")),recommended:typeof i=="boolean"?i:void 0,viaProjection:M(s("viaProjection")),viaProjectionKey:M(s("viaProjectionKey")),detailNote:M(s("detailNote"))}}).filter(a=>a.name):null,u=Array.isArray(t)?t.map(a=>({name:c(f(a,"chartTypeName")??f(a,"name")),reason:c(f(a,"reason")),isVeto:x(f(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:c(f(e,"errorMessage")),charts:o,refused:u,noFitSummary:c(f(e,"noFitSummary"))}}function ut(e){return!e||typeof e!="object"?null:{status:String(f(e,"status")??""),verdictReason:f(e,"verdictReason")??null,instruction:f(e,"instruction")??null,fix:f(e,"fix")??null,errorMessage:f(e,"errorMessage")??null}}function ct(e){let n=e.linkNonce?(e.linkNonce()??"").trim():null,t=n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:t.licenseKey,licensee:t.licensee,secretKey:t.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:n}}function dt(e){let{width:n,height:t}=e.measure();return{request:{height:t,width:n},hints:{viewportWidth:n,viewportHeight:t}}}function ft(e){let n=0;for(let t of e){if(t.isMeasure)continue;let o=t.distinctCount;typeof o=="number"&&o>n&&(n=o)}return n}function oe(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let n=e.settingVersion??null;if(e.genNew)return{version:n,fetchOnly:void 0};let t=(n??0)>0?n:null,o=(e.codeVersion??0)>0?e.codeVersion:null,u=t??o??n;return{version:u,fetchOnly:u!=null&&u>0?!0:void 0}}function mt(e){let n=e.fetchCorrelationId!=null,o=n||e.recoveryFetchVersion!=null?!1:e.genNew,u=oe({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:n,settingVersion:e.settingVersion,codeVersion:e.codeVersion});return{genNew:o,version:u.version,fetchOnly:u.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0}}function pt(e){let n=t=>e.renderers.has(t);return{supportsD3:n("D3"),supportsPlotly:n("PLOTLY"),supportsVega:n("VEGA")}}function gt(e){let n=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??n,maxTries:n}}function yt(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function ie(e,n){return e!=null&&n!=null&&e!==n}function Ct(e,n){return e?ie(n.capturedFor,n.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:n.atMs>0?Math.max(0,Math.round(n.nowMs-n.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}export{D as CITY_ROLE_MATCH_PCT,he as COMPOUND_MIN_STEM,Fn as DEFAULT_GAP_FACTOR,Te as DEFAULT_TEMPERATURE,Me as GET_RANDOM,Se as GLUED_STEM_MIN,an as INTENSIVE_SUFFIX_TOKENS,sn as INTENSIVE_WORD_TOKENS,zn as IndexedText,Mn as MAX_RUN_BOUNDS,un as POSITIONAL_SUFFIX_TOKENS,ln as POSITIONAL_WORD_TOKENS,jn as PREVIEW_OMITTED_FIELDS,S as ROLE_MATCH_PCT,Nn as SERIES_COMPLETENESS_MAX_LISTED,An as SERIES_COMPLETENESS_MIN_FILL,In as SERIES_KEY_MAX_DISTINCT,Fe as SIMPLE_STRING_HASH,ve as STR,Pe as SUBSTRING_MIN,ue as SUPPORTED_LANGUAGES,ce as SUPPORTED_LANGUAGE_CODES,k as admin1MatchPct,hn as allowedAggregations,Ze as buildGeoIsoColumn,He as buildGeoPointColumns,pt as capabilityFields,je as cityMatchPct,Ue as cityTagsFor,Vn as classifyAdditivity,Cn as classifyForAggregation,Kn as classifyNumericValueNature,Dn as classifyTemporal,mn as codeNeedsLegacyAggNames,Pn as codeReadsColumn,Rn as codeReadsColumnsByRoleOrPosition,fn as collapseRepeatedAggPrefix,vn as columnsTheCodeReads,en as countryRegion,ct as credentialFields,Bn as decimalSeparatorOf,bn as defaultAggregation,Wn as detectDecimalSeparator,tn as detectFormatSignature,Qe as detectGeo,De as detectOrdinalDomain,_n as detectTextDatePattern,Xn as encodePayload,Hn as engineTypeForSqlType,pn as englishImplicitAggNames,mt as fetchFields,me as foldName,it as freemiumColumnCapRefusal,J as freemiumColumnsOverCap,ee as freemiumDateHierarchyClauses,xe as gluedPrefixStems,qn as gzipWireText,dn as hasDefaultAggPrefix,ye as hasUnsegmentedScript,Gn as hostAggHint,Un as ingest,Sn as isAggregationAllowed,I as isBlankLike,Ve as isCityTableLoaded,we as isDeterministicRefusal,We as isGeoPointAmbiguity,On as isIdentifierName,Xe as isJoinGeoKind,Jn as isNdjsonContentType,Oe as isOrdinalFriendlyName,Zn as keyedSigner,yt as leafCardinalityField,ke as localMidnightDateColumns,Le as localMidnightToUtcDay,v as looksLikeCountryColumn,Re as matchNameToken,ft as maxNonMeasureCardinality,Tn as measureCadence,En as measureSeriesCompleteness,Yn as messageSignature,on as monthLookupFor,yn as nameLooksIntensiveRate,gn as nameLooksPositional,pe as nameWords,Ke as normalizeCountry,Ee as normalizeLocalMidnightDates,rn as normalizeMonthKey,N as normalizePlaceName,Be as normalizeZip5,Ct as offeredShortlistFor,Ne as parseDateStable,at as parseGenerateResponse,$n as parseNumberText,lt as parseQualifyResponse,ut as parseReviewVerdict,wn as parseTemporalPoint,Qn as payloadPreview,kn as pickSeriesColumn,nt as readGenerateStream,ge as readName,f as readWireField,Ge as registerCityTable,Je as registerIso3Regions,y as resolveAdmin1,oe as resolveFetchVersion,$e as resolveGeoPoint,fe as resolveLanguage,ot as resolvePointRoles,gt as retryFields,_e as safeDistinctValuesToShip,Ln as seriesKeyVerdict,xn as shareOfTotalIsHonest,ie as shortlistIsStale,cn as stripHostAggPrefix,nn as summarizeCountryRegions,Ye as summarizeGeoExtent,de as supportedLanguage,qe as toGeoIso,Ce as unsegmentedRuns,dt as viewportFields,Ae as wholeDayFrame,Ie as wholeDayIso,et as wireResponseFromFetch,be as wordEndsWith,W as zipMatchPct,L as zipPrefixCandidates,ze as zipToPrefix3};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -44,5 +44,5 @@ export type { GzipText } from "./wire";
|
|
|
44
44
|
export { readGenerateStream, isNdjsonContentType, wireResponseFromFetch } from "./wireStream";
|
|
45
45
|
export { parseGenerateResponse, parseQualifyResponse, parseReviewVerdict } from "./wireParse";
|
|
46
46
|
export type { ParsedGenerateResponse, ParsedQualifyResponse, ParsedQualifyChart, ParsedQualifyRefusal, ParsedReviewVerdict, WirePointBinding, WirePointColumns, } from "./wireParse";
|
|
47
|
-
export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, } from "./wireBuild";
|
|
47
|
+
export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, shortlistIsStale, offeredShortlistFor, } from "./wireBuild";
|
|
48
48
|
export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, } from "./wireBuild";
|
|
@@ -181,3 +181,33 @@ export declare function retryFields(p: {
|
|
|
181
181
|
export declare function leafCardinalityField(count: number | null | undefined): {
|
|
182
182
|
leafCardinality?: number;
|
|
183
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* IS A CAPTURED "WHAT FITS" LIST STALE? True when the list was captured for one schema and the
|
|
186
|
+
* request now describes another - the reader changed the fields since they looked, so the list is not
|
|
187
|
+
* the one in front of them. The keys are the host's own schema keys, compared as given; an unknown
|
|
188
|
+
* key on either side (null or undefined) is not evidence of a change, and the list stands.
|
|
189
|
+
*/
|
|
190
|
+
export declare function shortlistIsStale(capturedFor: string | number | null | undefined, now: string | number | null | undefined): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* THE SHORTLIST A REQUEST CARRIES - the "what fits" list the reader was looking at when they chose, and
|
|
193
|
+
* how long ago they saw it.
|
|
194
|
+
*
|
|
195
|
+
* A list captured for a different schema is DROPPED rather than sent with a misleading age
|
|
196
|
+
* (`shortlistIsStale`): it was computed for other fields, which makes it wrong rather than merely old.
|
|
197
|
+
* There is no age CAP - a reader who studied the list for ten minutes and then generated was still
|
|
198
|
+
* working from it. `ageMs` is the whole milliseconds since `atMs` (never negative), and undefined when
|
|
199
|
+
* no capture time is known; it follows the list's own fields.
|
|
200
|
+
*
|
|
201
|
+
* `stale` says why a present list was not returned, so a host can record the drop.
|
|
202
|
+
*/
|
|
203
|
+
export declare function offeredShortlistFor<T extends object>(shortlist: T | null | undefined, at: {
|
|
204
|
+
capturedFor?: string | number | null;
|
|
205
|
+
now?: string | number | null;
|
|
206
|
+
atMs: number;
|
|
207
|
+
nowMs: number;
|
|
208
|
+
}): {
|
|
209
|
+
shortlist: (T & {
|
|
210
|
+
ageMs?: number;
|
|
211
|
+
}) | undefined;
|
|
212
|
+
stale: boolean;
|
|
213
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.27",
|
|
4
4
|
"description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|