@bicharts/shape-core 0.6.31 → 0.6.33
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 +2 -0
- package/dist/types/telemetry.d.ts +60 -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 qn,b as Xn}from"./chunk-UQU75XXR.mjs";import{a as Yn,b as Zn,c as Jn,d as et,e as m,f as nt,g as tt,h as rt}from"./chunk-BIC73LQV.mjs";import{a as Un,b as $n,c as Hn,d as jn,e as Qn}from"./chunk-PK6KRKNE.mjs";import{A as In,B as An,C as Ln,D as kn,E as En,F as On,G as _n,H as Dn,I as Gn,J as Vn,K as Kn,L as zn,M as Bn,O as Wn,a as en,b as nn,c as tn,d as rn,e as ln,f as un,g as cn,h as dn,i as mn,j as fn,k as pn,l as gn,m as yn,n as hn,o as Cn,p as bn,q as Sn,r as xn,s as Rn,t as Pn,u as vn,v as Tn,w as Fn,x as Mn,y as wn,z as Nn}from"./chunk-ZVHCLXKO.mjs";import{a as on}from"./chunk-QEH7WTLB.mjs";import{a as sn,b as an}from"./chunk-2LR73DNS.mjs";import{a as q,b as X,c as Xe,d as Ye,e as Ze,f as Je}from"./chunk-C5I73OM2.mjs";import{a as N,f as I,g as S,h as A,i as G,j as Ke,k as ze,l as Q,m as y,n as Be,o as We,p as Ue,q as L,r as $e,s as He,t as je,u as Qe,v as V,w as qe}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as De,b as Ge,c as Ve}from"./chunk-35Z7JCND.mjs";import{A as _e,a as me,b as fe,c as pe,d as ge,e as ye,f as he,g as Ce,h as be,i as Se,j as xe,k as Re,l as Pe,m as ve,n as Te,o as Fe,p as Me,r as D,s as we,t as Ne,u as Ie,v as Ae,w as Le,x as ke,y as Ee,z as Oe}from"./chunk-ILHBRGIO.mjs";var K=2,J=400;function B(e){return!!I(e)}function T(e){let n=new Set;for(let t of e){if(t==null)continue;let o=N(String(t));if(!A(o)&&!n.has(o)&&(n.add(o),n.size>=J))break}return Array.from(n)}function v(e){let n=T(e);if(n.length===0||W(e)<95)return!1;let t=n.filter(u=>B(u)&&!y(u)).length,o=n.filter(u=>!B(u)&&!!y(u)).length;return t>=1&&t>=o}function Y(e,n){if(!y(e))return!1;let t=I(e);return t?n==="world"?!0:Q.has(t):!1}function W(e){let n=T(e);if(n.length===0)return 0;let t=0;for(let o of n)B(o)&&t++;return Math.round(t/n.length*1e3)/10}function k(e){let n=T(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(!A(N(o))&&!n.has(o)&&(n.add(o),n.size>=J))break}return Array.from(n)}function U(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 X(n,q)?!0:$(e).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function ot(e,n){let t=T(e);if(t.length===0)return 0;let o=0;for(let u of t)V(u,n)&&o++;return Math.round(o/t.length*1e3)/10}function z(e,n){let t=0;for(let o of T(e))n(o)&&t++;return t}function it(e,n){let t=0;for(let o of $(e))n(o)&&t++;return t}function st(e,n,t,o,u){let a=[],s=[],i={},h={},R=new Set(e),f=r=>n.map(l=>l[r]);for(let r of["city","country"]){let l=t?.[r];l&&R.has(l)&&(i[r]=l)}let ue=new Set(u??e);for(let r of["lat","lon"]){let l=t?.[r];l&&ue.has(l)&&(i[r]=l)}let C=t?.zip;if(C&&R.has(C)){let r=f(C),l=U(r);l<95?s.push(`zip=${C} (only ${l}% of values read as ZIPs)`):Z(r,C)?i.zip=C:s.push(`zip=${C} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&R.has(g)){let r=f(g),l=T(r);l.length>0&&l.every(d=>Y(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)),M=e.filter(r=>!b.has(r)&&!r.startsWith("__"));if(!i.state){let r=null;for(let l of M){let d=f(l);if(v(d))continue;let p=k(d);if(p<95)continue;let _=z(d,w=>!!y(w)),de=z(d,w=>!!y(w)&&!Y(w,o));_<K&&de<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 M){if(b.has(r))continue;let l=f(r),d=U(l);if(!(d<95)&&Z(l,r)&&!(it(l,p=>L(p).length>0)<K)){i.zip=r,b.add(r),a.push(`zip=${r} (${d}% ZIP codes)`);break}}let P=i.country;if(!P||!v(f(P))){let r=null;for(let l of M){if(b.has(l)||!v(f(l)))continue;let d=W(f(l));(!r||d>r.pct)&&(r={name:l,pct:d})}r&&(P&&(s.push(`country=${P} (only ${W(f(P))}% of values are country identifiers; using ${r.name} instead)`),h.country=P),i.country=r.name,b.add(r.name),a.push(`country=${r.name}`))}if(!i.city){let r=null;for(let l of M){if(b.has(l))continue;let d=f(l),p=ot(d,o);p<G||z(d,_=>V(_,o))<K||(!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?f(i.country):[],E=!!i.country&&v(H),ce=E?new Set(H.map(r=>I(r==null?null:String(r))).filter(Boolean)).size:0,j=E&&ce>=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&&!j&&!(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||j||O)?i:null,backfilled:a,refused:s,...Object.keys(h).length?{labelFallback:h}:{}}}function ee(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 at(e,n,t){let o=ee(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=ne(t);return i.length===0?s:s+" "+i.join(" ")}function ne(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():"",h=typeof a.name=="string"?a.name.trim():"",R=i!==""?i:h;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),x=e=>e===!0,te=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},lt=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function re(e,n){let t={};for(let[o,u]of lt){let a=c(m(e,n+u));a&&(t[o]=a)}return t}function ut(e){let n=i=>m(e,i),t=n("retryAfterSeconds"),o=n("overrideThumbnailUpload"),u=n("forceThumbnailUpload"),a=re(e,"point"),s=re(e,"destPoint");return Object.keys(s).length&&(a.dest=s),{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(a).length?a:null,creditBalanceBefore:te(n("creditBalanceBefore")),creditCost:te(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")),...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof u=="boolean"?{forceThumbnailUpload:u}:{}}}var oe=e=>e==null?void 0:Number(e),F=e=>c(e)||void 0;function ct(e){let n=m(e,"charts"),t=m(e,"refused"),o=Array.isArray(n)?n.map(a=>{let s=h=>m(a,h),i=s("recommended");return{name:c(s("chartTypeName")??s("name")),description:c(s("description")??s("chartDesc")),rank:oe(s("rank")),score:oe(s("score")),renderer:F(s("renderer")),language:F(s("language")),isPreview:x(s("isPreview")),recommended:typeof i=="boolean"?i:void 0,viaProjection:F(s("viaProjection")),viaProjectionKey:F(s("viaProjectionKey")),detailNote:F(s("detailNote"))}}).filter(a=>a.name):null,u=Array.isArray(t)?t.map(a=>({name:c(m(a,"chartTypeName")??m(a,"name")),reason:c(m(a,"reason")),isVeto:x(m(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:c(m(e,"errorMessage")),charts:o,refused:u,noFitSummary:c(m(e,"noFitSummary"))}}function dt(e){return!e||typeof e!="object"?null:{status:String(m(e,"status")??""),verdictReason:m(e,"verdictReason")??null,instruction:m(e,"instruction")??null,fix:m(e,"fix")??null,errorMessage:m(e,"errorMessage")??null}}function mt(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 ft(e){let{width:n,height:t}=e.measure();return{request:{height:t,width:n},hints:{viewportWidth:n,viewportHeight:t}}}function pt(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 ie(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 gt(e){let n=e.fetchCorrelationId!=null,o=n||e.recoveryFetchVersion!=null?!1:e.genNew,u=ie({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 yt(e){let n=t=>e.renderers.has(t);return{supportsD3:n("D3"),supportsPlotly:n("PLOTLY"),supportsVega:n("VEGA")}}function ht(e){let n=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??n,maxTries:n}}function Ct(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function se(e,n){return e!=null&&n!=null&&e!==n}function bt(e,n){return e?se(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}}var St=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function ae(e){let n=String(e??"").trim().toLowerCase();return St[n]??n}function le(e){let n="";for(let t of e)n+=JSON.stringify([String(t.name??""),t.isMeasure?"M":"D",ae(t.dataType)]);return n}function xt(e){return D(le(e))}export{G as CITY_ROLE_MATCH_PCT,xe as COMPOUND_MIN_STEM,Mn as DEFAULT_GAP_FACTOR,Ie as DEFAULT_TEMPERATURE,we as GET_RANDOM,Pe as GLUED_STEM_MIN,un as INTENSIVE_SUFFIX_TOKENS,ln as INTENSIVE_WORD_TOKENS,Wn as IndexedText,wn as MAX_RUN_BOUNDS,dn as POSITIONAL_SUFFIX_TOKENS,cn as POSITIONAL_WORD_TOKENS,qn as PREVIEW_OMITTED_FIELDS,S as ROLE_MATCH_PCT,An as SERIES_COMPLETENESS_MAX_LISTED,Ln as SERIES_COMPLETENESS_MIN_FILL,kn as SERIES_KEY_MAX_DISTINCT,D as SIMPLE_STRING_HASH,Me as STR,Te as SUBSTRING_MIN,me as SUPPORTED_LANGUAGES,fe as SUPPORTED_LANGUAGE_CODES,k as admin1MatchPct,Sn as allowedAggregations,Je as buildGeoIsoColumn,je as buildGeoPointColumns,yt as capabilityFields,qe as cityMatchPct,Qe as cityTagsFor,zn as classifyAdditivity,bn as classifyForAggregation,Bn as classifyNumericValueNature,Vn as classifyTemporal,gn as codeNeedsLegacyAggNames,vn as codeReadsColumn,Tn as codeReadsColumnsByRoleOrPosition,pn as collapseRepeatedAggPrefix,Fn as columnsTheCodeReads,tn as countryRegion,mt as credentialFields,Un as decimalSeparatorOf,xn as defaultAggregation,$n as detectDecimalSeparator,on as detectFormatSignature,Xe as detectGeo,Ve as detectOrdinalDomain,Gn as detectTextDatePattern,Zn as encodePayload,jn as engineTypeForSqlType,yn as englishImplicitAggNames,gt as fetchFields,ye as foldName,at as freemiumColumnCapRefusal,ee as freemiumColumnsOverCap,ne as freemiumDateHierarchyClauses,ve as gluedPrefixStems,Yn as gzipWireText,fn as hasDefaultAggPrefix,be as hasUnsegmentedScript,Kn as hostAggHint,Qn as ingest,Rn as isAggregationAllowed,A as isBlankLike,ze as isCityTableLoaded,Ne as isDeterministicRefusal,$e as isGeoPointAmbiguity,Dn as isIdentifierName,Ze as isJoinGeoKind,nt as isNdjsonContentType,De as isOrdinalFriendlyName,Jn as keyedSigner,Ct as leafCardinalityField,Oe as localMidnightDateColumns,Ee as localMidnightToUtcDay,v as looksLikeCountryColumn,Fe as matchNameToken,pt as maxNonMeasureCardinality,In as measureCadence,_n as measureSeriesCompleteness,et as messageSignature,an as monthLookupFor,Cn as nameLooksIntensiveRate,hn as nameLooksPositional,he as nameWords,Be as normalizeCountry,_e as normalizeLocalMidnightDates,sn as normalizeMonthKey,N as normalizePlaceName,Ue as normalizeZip5,bt as offeredShortlistFor,Ae as parseDateStable,ut as parseGenerateResponse,Hn as parseNumberText,ct as parseQualifyResponse,dt as parseReviewVerdict,Nn as parseTemporalPoint,Xn as payloadPreview,On as pickSeriesColumn,rt as readGenerateStream,Ce as readName,m as readWireField,Ke as registerCityTable,nn as registerIso3Regions,y as resolveAdmin1,ie as resolveFetchVersion,He as resolveGeoPoint,ge as resolveLanguage,st as resolvePointRoles,ht as retryFields,Ge as safeDistinctValuesToShip,le as schemaIdentity,xt as schemaIdentityKey,ae as schemaTypeFamily,En as seriesKeyVerdict,Pn as shareOfTotalIsHonest,se as shortlistIsStale,mn as stripHostAggPrefix,rn as summarizeCountryRegions,en as summarizeGeoExtent,pe as supportedLanguage,Ye as toGeoIso,Se as unsegmentedRuns,ft as viewportFields,Le as wholeDayFrame,ke as wholeDayIso,tt as wireResponseFromFetch,Re as wordEndsWith,U as zipMatchPct,L as zipPrefixCandidates,We as zipToPrefix3};
|
|
2
|
+
import{a as qn,b as Xn}from"./chunk-UQU75XXR.mjs";import{a as Yn,b as Zn,c as Jn,d as et,e as m,f as nt,g as tt,h as rt}from"./chunk-BIC73LQV.mjs";import{a as $n,b as Un,c as Hn,d as jn,e as Qn}from"./chunk-PK6KRKNE.mjs";import{A as En,B as wn,C as An,D as Ln,E as _n,F as On,G as kn,H as Dn,I as Vn,J as Gn,K as Kn,L as Wn,M as zn,O as Bn,a as en,b as nn,c as tn,d as rn,e as ln,f as un,g as cn,h as dn,i as mn,j as fn,k as pn,l as gn,m as yn,n as hn,o as Cn,p as bn,q as Sn,r as Rn,s as xn,t as Pn,u as vn,v as Tn,w as Nn,x as Fn,y as In,z as Mn}from"./chunk-ZVHCLXKO.mjs";import{a as on}from"./chunk-QEH7WTLB.mjs";import{a as sn,b as an}from"./chunk-2LR73DNS.mjs";import{a as q,b as X,c as Xe,d as Ye,e as Ze,f as Je}from"./chunk-C5I73OM2.mjs";import{a as M,f as E,g as S,h as w,i as V,j as Ke,k as We,l as Q,m as y,n as ze,o as Be,p as $e,q as A,r as Ue,s as He,t as je,u as Qe,v as G,w as qe}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as De,b as Ve,c as Ge}from"./chunk-35Z7JCND.mjs";import{A as ke,a as me,b as fe,c as pe,d as ge,e as ye,f as he,g as Ce,h as be,i as Se,j as Re,k as xe,l as Pe,m as ve,n as Te,o as Ne,p as Fe,r as D,s as Ie,t as Me,u as Ee,v as we,w as Ae,x as Le,y as _e,z as Oe}from"./chunk-ILHBRGIO.mjs";var K=2,J=400;function z(e){return!!E(e)}function T(e){let n=new Set;for(let t of e){if(t==null)continue;let o=M(String(t));if(!w(o)&&!n.has(o)&&(n.add(o),n.size>=J))break}return Array.from(n)}function v(e){let n=T(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 Y(e,n){if(!y(e))return!1;let t=E(e);return t?n==="world"?!0:Q.has(t):!1}function B(e){let n=T(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 L(e){let n=T(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 U(e){let n=new Set;for(let t of e){if(t==null)continue;let o=String(t).trim();if(!w(M(o))&&!n.has(o)&&(n.add(o),n.size>=J))break}return Array.from(n)}function $(e){let n=U(e);if(n.length===0)return 0;let t=0;for(let o of n)A(o).length>0&&t++;return Math.round(t/n.length*1e3)/10}function Z(e,n){return X(n,q)?!0:U(e).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function ot(e,n){let t=T(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 W(e,n){let t=0;for(let o of T(e))n(o)&&t++;return t}function it(e,n){let t=0;for(let o of U(e))n(o)&&t++;return t}function st(e,n,t,o,u){let a=[],s=[],i={},h={},x=new Set(e),f=r=>n.map(l=>l[r]);for(let r of["city","country"]){let l=t?.[r];l&&x.has(l)&&(i[r]=l)}let ue=new Set(u??e);for(let r of["lat","lon"]){let l=t?.[r];l&&ue.has(l)&&(i[r]=l)}let C=t?.zip;if(C&&x.has(C)){let r=f(C),l=$(r);l<95?s.push(`zip=${C} (only ${l}% of values read as ZIPs)`):Z(r,C)?i.zip=C:s.push(`zip=${C} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&x.has(g)){let r=f(g),l=T(r);l.length>0&&l.every(d=>Y(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)):L(r)<95?s.push(`state=${g} (only ${L(r)}% of values are states/provinces)`):i.state=g}let b=new Set(Object.values(i).filter(Boolean)),F=e.filter(r=>!b.has(r)&&!r.startsWith("__"));if(!i.state){let r=null;for(let l of F){let d=f(l);if(v(d))continue;let p=L(d);if(p<95)continue;let k=W(d,I=>!!y(I)),de=W(d,I=>!!y(I)&&!Y(I,o));k<K&&de<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 F){if(b.has(r))continue;let l=f(r),d=$(l);if(!(d<95)&&Z(l,r)&&!(it(l,p=>A(p).length>0)<K)){i.zip=r,b.add(r),a.push(`zip=${r} (${d}% ZIP codes)`);break}}let P=i.country;if(!P||!v(f(P))){let r=null;for(let l of F){if(b.has(l)||!v(f(l)))continue;let d=B(f(l));(!r||d>r.pct)&&(r={name:l,pct:d})}r&&(P&&(s.push(`country=${P} (only ${B(f(P))}% of values are country identifiers; using ${r.name} instead)`),h.country=P),i.country=r.name,b.add(r.name),a.push(`country=${r.name}`))}if(!i.city){let r=null;for(let l of F){if(b.has(l))continue;let d=f(l),p=ot(d,o);p<V||W(d,k=>G(k,o))<K||(!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?f(i.country):[],_=!!i.country&&v(H),ce=_?new Set(H.map(r=>E(r==null?null:String(r))).filter(Boolean)).size:0,j=_&&ce>=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&&!j&&!(i.city||i.state||i.zip||O)&&s.push(_?`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||j||O)?i:null,backfilled:a,refused:s,...Object.keys(h).length?{labelFallback:h}:{}}}function ee(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 at(e,n,t){let o=ee(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=ne(t);return i.length===0?s:s+" "+i.join(" ")}function ne(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():"",h=typeof a.name=="string"?a.name.trim():"",x=i!==""?i:h;x!==""&&o.set(s,x)}}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),R=e=>e===!0,te=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},lt=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function re(e,n){let t={};for(let[o,u]of lt){let a=c(m(e,n+u));a&&(t[o]=a)}return t}function ut(e){let n=i=>m(e,i),t=n("retryAfterSeconds"),o=n("overrideThumbnailUpload"),u=n("forceThumbnailUpload"),a=re(e,"point"),s=re(e,"destPoint");return Object.keys(s).length&&(a.dest=s),{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(a).length?a:null,creditBalanceBefore:te(n("creditBalanceBefore")),creditCost:te(n("creditCost")),isServiceError:R(n("isServiceError")),isRateLimited:R(n("isRateLimited")),isRefusal:R(n("isRefusal")),isVersionNotFound:R(n("isVersionNotFound")),isGenerationCancelled:R(n("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:c(n("servedCorrelationId")),...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof u=="boolean"?{forceThumbnailUpload:u}:{}}}var oe=e=>e==null?void 0:Number(e),N=e=>c(e)||void 0;function ct(e){let n=m(e,"charts"),t=m(e,"refused"),o=Array.isArray(n)?n.map(a=>{let s=h=>m(a,h),i=s("recommended");return{name:c(s("chartTypeName")??s("name")),description:c(s("description")??s("chartDesc")),rank:oe(s("rank")),score:oe(s("score")),renderer:N(s("renderer")),language:N(s("language")),isPreview:R(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(m(a,"chartTypeName")??m(a,"name")),reason:c(m(a,"reason")),isVeto:R(m(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:c(m(e,"errorMessage")),charts:o,refused:u,noFitSummary:c(m(e,"noFitSummary"))}}function dt(e){return!e||typeof e!="object"?null:{status:String(m(e,"status")??""),verdictReason:m(e,"verdictReason")??null,instruction:m(e,"instruction")??null,fix:m(e,"fix")??null,errorMessage:m(e,"errorMessage")??null}}function mt(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 ft(e){let{width:n,height:t}=e.measure();return{request:{height:t,width:n},hints:{viewportWidth:n,viewportHeight:t}}}function pt(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 ie(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 gt(e){let n=e.fetchCorrelationId!=null,o=n||e.recoveryFetchVersion!=null?!1:e.genNew,u=ie({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 yt(e){let n=t=>e.renderers.has(t);return{supportsD3:n("D3"),supportsPlotly:n("PLOTLY"),supportsVega:n("VEGA")}}function ht(e){let n=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??n,maxTries:n}}function Ct(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function se(e,n){return e!=null&&n!=null&&e!==n}function bt(e,n){return e?se(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}}var St=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function ae(e){let n=String(e??"").trim().toLowerCase();return St[n]??n}function le(e){let n="";for(let t of e)n+=JSON.stringify([String(t.name??""),t.isMeasure?"M":"D",ae(t.dataType)]);return n}function Rt(e){return D(le(e))}var xt=2,Pt=3,vt=4,Tt=64,Nt=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict"});function Ft(e){return!!e&&!e.includes("|")&&!e.includes(",")}function It(e,n,t,o){let u=`${e},${n}|${t}`;return o?`${u}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:u}export{V as CITY_ROLE_MATCH_PCT,Nt as CLIENT_EVENT_KINDS,Re as COMPOUND_MIN_STEM,Fn as DEFAULT_GAP_FACTOR,Ee as DEFAULT_TEMPERATURE,Ie as GET_RANDOM,Pe as GLUED_STEM_MIN,un as INTENSIVE_SUFFIX_TOKENS,ln as INTENSIVE_WORD_TOKENS,Bn as IndexedText,In as MAX_RUN_BOUNDS,dn as POSITIONAL_SUFFIX_TOKENS,cn as POSITIONAL_WORD_TOKENS,qn as PREVIEW_OMITTED_FIELDS,S as ROLE_MATCH_PCT,wn as SERIES_COMPLETENESS_MAX_LISTED,An as SERIES_COMPLETENESS_MIN_FILL,Ln as SERIES_KEY_MAX_DISTINCT,vt as SEV_ERROR,xt as SEV_INFO,Tt as SEV_USER_PRESENTED,Pt as SEV_WARNING,D as SIMPLE_STRING_HASH,Fe as STR,Te as SUBSTRING_MIN,me as SUPPORTED_LANGUAGES,fe as SUPPORTED_LANGUAGE_CODES,L as admin1MatchPct,Sn as allowedAggregations,Je as buildGeoIsoColumn,je as buildGeoPointColumns,yt as capabilityFields,qe as cityMatchPct,Qe as cityTagsFor,Wn as classifyAdditivity,bn as classifyForAggregation,zn as classifyNumericValueNature,Gn as classifyTemporal,gn as codeNeedsLegacyAggNames,vn as codeReadsColumn,Tn as codeReadsColumnsByRoleOrPosition,pn as collapseRepeatedAggPrefix,Nn as columnsTheCodeReads,tn as countryRegion,mt as credentialFields,$n as decimalSeparatorOf,Rn as defaultAggregation,Un as detectDecimalSeparator,on as detectFormatSignature,Xe as detectGeo,Ge as detectOrdinalDomain,Vn as detectTextDatePattern,Zn as encodePayload,jn as engineTypeForSqlType,yn as englishImplicitAggNames,It as eventLogLine,gt as fetchFields,ye as foldName,at as freemiumColumnCapRefusal,ee as freemiumColumnsOverCap,ne as freemiumDateHierarchyClauses,ve as gluedPrefixStems,Yn as gzipWireText,fn as hasDefaultAggPrefix,be as hasUnsegmentedScript,Kn as hostAggHint,Qn as ingest,xn as isAggregationAllowed,w as isBlankLike,We as isCityTableLoaded,Me as isDeterministicRefusal,Ft as isEventLogCode,Ue as isGeoPointAmbiguity,Dn as isIdentifierName,Ze as isJoinGeoKind,nt as isNdjsonContentType,De as isOrdinalFriendlyName,Jn as keyedSigner,Ct as leafCardinalityField,Oe as localMidnightDateColumns,_e as localMidnightToUtcDay,v as looksLikeCountryColumn,Ne as matchNameToken,pt as maxNonMeasureCardinality,En as measureCadence,kn as measureSeriesCompleteness,et as messageSignature,an as monthLookupFor,Cn as nameLooksIntensiveRate,hn as nameLooksPositional,he as nameWords,ze as normalizeCountry,ke as normalizeLocalMidnightDates,sn as normalizeMonthKey,M as normalizePlaceName,$e as normalizeZip5,bt as offeredShortlistFor,we as parseDateStable,ut as parseGenerateResponse,Hn as parseNumberText,ct as parseQualifyResponse,dt as parseReviewVerdict,Mn as parseTemporalPoint,Xn as payloadPreview,On as pickSeriesColumn,rt as readGenerateStream,Ce as readName,m as readWireField,Ke as registerCityTable,nn as registerIso3Regions,y as resolveAdmin1,ie as resolveFetchVersion,He as resolveGeoPoint,ge as resolveLanguage,st as resolvePointRoles,ht as retryFields,Ve as safeDistinctValuesToShip,le as schemaIdentity,Rt as schemaIdentityKey,ae as schemaTypeFamily,_n as seriesKeyVerdict,Pn as shareOfTotalIsHonest,se as shortlistIsStale,mn as stripHostAggPrefix,rn as summarizeCountryRegions,en as summarizeGeoExtent,pe as supportedLanguage,Ye as toGeoIso,Se as unsegmentedRuns,ft as viewportFields,Ae as wholeDayFrame,Le as wholeDayIso,tt as wireResponseFromFetch,xe as wordEndsWith,$ as zipMatchPct,A as zipPrefixCandidates,Be as zipToPrefix3};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -48,3 +48,5 @@ export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetc
|
|
|
48
48
|
export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, } from "./wireBuild";
|
|
49
49
|
export { schemaIdentity, schemaIdentityKey, schemaTypeFamily } from "./schemaIdentity";
|
|
50
50
|
export type { SchemaIdentityColumn } from "./schemaIdentity";
|
|
51
|
+
export { SEV_INFO, SEV_WARNING, SEV_ERROR, SEV_USER_PRESENTED, CLIENT_EVENT_KINDS, isEventLogCode, eventLogLine, } from "./telemetry";
|
|
52
|
+
export type { ClientMessage } from "./telemetry";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Severity levels a client message carries, in its low bits. */
|
|
2
|
+
export declare const SEV_INFO = 2;
|
|
3
|
+
export declare const SEV_WARNING = 3;
|
|
4
|
+
export declare const SEV_ERROR = 4;
|
|
5
|
+
/** A bit OR-ed onto a level: the reader SAW this (an error on screen, a warning in a banner). */
|
|
6
|
+
export declare const SEV_USER_PRESENTED = 64;
|
|
7
|
+
/**
|
|
8
|
+
* The fields of a client message, by the service's names. Every field is optional; a host sends what
|
|
9
|
+
* it knows. The service derives a failure from a non-empty StackTrace, so a failure must carry one.
|
|
10
|
+
*/
|
|
11
|
+
export interface ClientMessage {
|
|
12
|
+
Message?: string;
|
|
13
|
+
StackTrace?: string;
|
|
14
|
+
Location?: string;
|
|
15
|
+
Code?: string | null;
|
|
16
|
+
Duration?: number | null;
|
|
17
|
+
OutputHash?: string | null;
|
|
18
|
+
UpDownVote?: number | null;
|
|
19
|
+
ClientId?: string | null;
|
|
20
|
+
LanguageCode?: string | null;
|
|
21
|
+
TriesLeft?: number | null;
|
|
22
|
+
ClientRows?: number | null;
|
|
23
|
+
RenderedRowCount?: number | null;
|
|
24
|
+
ImageWidth?: number | null;
|
|
25
|
+
ImageHeight?: number | null;
|
|
26
|
+
ImageThumbnail?: string | null;
|
|
27
|
+
ThumbnailUserConsent?: boolean | null;
|
|
28
|
+
ClientVersion?: string;
|
|
29
|
+
ClientBehaviorFlags?: string | null;
|
|
30
|
+
ClientBuild?: string | null;
|
|
31
|
+
Severity?: number | null;
|
|
32
|
+
EventKind?: string | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The event kinds the service's views count by. `render-ok` and `view` are what a chart's view count
|
|
36
|
+
* counts; the others are recorded beside it without inflating it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const CLIENT_EVENT_KINDS: Readonly<{
|
|
39
|
+
readonly RENDER_START: "render-start";
|
|
40
|
+
readonly RENDER_OK: "render-ok";
|
|
41
|
+
readonly RENDER_ERROR: "render-error";
|
|
42
|
+
readonly VIEW: "view";
|
|
43
|
+
readonly VIEW_VERDICT: "view-verdict";
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Can this code name an event counter? The service splits the line on "|" and keys the counter on
|
|
47
|
+
* everything before it, with "," separating code from version - so a code carrying either delimiter
|
|
48
|
+
* would land as a DIFFERENT counter, a row nobody reports on. An empty code names nothing.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isEventLogCode(code: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The event-count line: "<code>,<version>|<clientId>", or with a magnitude
|
|
53
|
+
* "<code>,<version>|<clientId>|<count>|<nonce>" - the count rounded and floored at 0, the nonce keeping
|
|
54
|
+
* repeated equal counts from being merged by the service. Built as given: a host checks the code with
|
|
55
|
+
* `isEventLogCode` first when it did not write the code itself.
|
|
56
|
+
*/
|
|
57
|
+
export declare function eventLogLine(code: string, version: string, clientId: string, magnitude?: {
|
|
58
|
+
count: number;
|
|
59
|
+
nonce: string;
|
|
60
|
+
}): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.33",
|
|
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",
|