@bicharts/shape-core 0.6.13 → 0.6.15
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/wireBuild.d.ts +39 -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 Hn}from"./chunk-UQU75XXR.mjs";import{a as Qn,b as jn,c as qn,d as Xn,e as f,f as Zn,g as Yn,h as Jn}from"./chunk-BIC73LQV.mjs";import{a as Bn,b as Kn,c as Wn,d as $n,e as Vn}from"./chunk-PK6KRKNE.mjs";import{A as vn,B as An,C as Nn,D as In,E as wn,F as Ln,G as kn,H as En,I as _n,J as Dn,K as On,L as Gn,M as Fn,O as zn,a as Xe,b as Ze,c as Ye,d as Je,e as on,f as rn,g as sn,h as an,i as un,j as ln,k as cn,l as mn,m as fn,n as dn,o as pn,p as gn,q as yn,r as Cn,s as Pn,t as Sn,u as hn,v as Rn,w as xn,x as bn,y as Tn,z as Mn}from"./chunk-ZVHCLXKO.mjs";import{a as en}from"./chunk-QEH7WTLB.mjs";import{a as nn,b as tn}from"./chunk-2LR73DNS.mjs";import{a as j,b as q,c as He,d as Qe,e as je,f as qe}from"./chunk-C5I73OM2.mjs";import{a as I,f as w,g as h,h as L,i as G,j as Oe,k as Ge,l as Q,m as y,n as Fe,o as ze,p as Be,q as k,r as Ke,s as We,t as $e,u as Ve,v as F,w as Ue}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as Ee,b as _e,c as De}from"./chunk-35Z7JCND.mjs";import{A as ke,a as ae,b as ue,c as le,d as ce,e as me,f as fe,g as de,h as pe,i as ge,j as ye,k as Ce,l as Pe,m as Se,n as he,o as Re,p as xe,r as be,s as Te,t as Me,u as ve,v as Ae,w as Ne,x as Ie,y as we,z as Le}from"./chunk-ILHBRGIO.mjs";var z=2,Y=400;function K(n){return!!w(n)}function M(n){let e=new Set;for(let t of n){if(t==null)continue;let i=I(String(t));if(!L(i)&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function T(n){let e=M(n);if(e.length===0||W(n)<95)return!1;let t=e.filter(c=>K(c)&&!y(c)).length,i=e.filter(c=>!K(c)&&!!y(c)).length;return t>=1&&t>=i}function X(n,e){if(!y(n))return!1;let t=w(n);return t?e==="world"?!0:Q.has(t):!1}function W(n){let e=M(n);if(e.length===0)return 0;let t=0;for(let i of e)K(i)&&t++;return Math.round(t/e.length*1e3)/10}function E(n){let e=M(n);if(e.length===0)return 0;let t=0;for(let i of e)y(i)&&t++;return Math.round(t/e.length*1e3)/10}function V(n){let e=new Set;for(let t of n){if(t==null)continue;let i=String(t).trim();if(!L(I(i))&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function $(n){let e=V(n);if(e.length===0)return 0;let t=0;for(let i of e)k(i).length>0&&t++;return Math.round(t/e.length*1e3)/10}function Z(n,e){return q(e,j)?!0:V(n).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function et(n,e){let t=M(n);if(t.length===0)return 0;let i=0;for(let c of t)F(c,e)&&i++;return Math.round(i/t.length*1e3)/10}function B(n,e){let t=0;for(let i of M(n))e(i)&&t++;return t}function nt(n,e){let t=0;for(let i of V(n))e(i)&&t++;return t}function tt(n,e,t,i,c){let a=[],s=[],r={},C={},x=new Set(n),d=o=>e.map(u=>u[o]);for(let o of["city","country"]){let u=t?.[o];u&&x.has(u)&&(r[o]=u)}let re=new Set(c??n);for(let o of["lat","lon"]){let u=t?.[o];u&&re.has(u)&&(r[o]=u)}let P=t?.zip;if(P&&x.has(P)){let o=d(P),u=$(o);u<95?s.push(`zip=${P} (only ${u}% of values read as ZIPs)`):Z(o,P)?r.zip=P:s.push(`zip=${P} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&x.has(g)){let o=d(g),u=M(o);u.length>0&&u.every(m=>X(m,i))?s.push(`state=${g} (every value is "CA", which is both Canada and California)`):T(o)?(s.push(`state=${g} (every value is a country, not a state)`),r.country||(r.country=g)):E(o)<95?s.push(`state=${g} (only ${E(o)}% of values are states/provinces)`):r.state=g}let S=new Set(Object.values(r).filter(Boolean)),A=n.filter(o=>!S.has(o)&&!o.startsWith("__"));if(!r.state){let o=null;for(let u of A){let m=d(u);if(T(m))continue;let p=E(m);if(p<95)continue;let O=B(m,N=>!!y(N)),se=B(m,N=>!!y(N)&&!X(N,i));O<z&&se<1||(!o||p>o.pct)&&(o={name:u,pct:p})}o&&(r.state=o.name,S.add(o.name),a.push(`state=${o.name} (${o.pct}% states/provinces)`))}if(!r.zip)for(let o of A){if(S.has(o))continue;let u=d(o),m=$(u);if(!(m<95)&&Z(u,o)&&!(nt(u,p=>k(p).length>0)<z)){r.zip=o,S.add(o),a.push(`zip=${o} (${m}% ZIP codes)`);break}}let b=r.country;if(!b||!T(d(b))){let o=null;for(let u of A){if(S.has(u)||!T(d(u)))continue;let m=W(d(u));(!o||m>o.pct)&&(o={name:u,pct:m})}o&&(b&&(s.push(`country=${b} (only ${W(d(b))}% of values are country identifiers; using ${o.name} instead)`),C.country=b),r.country=o.name,S.add(o.name),a.push(`country=${o.name}`))}if(!r.city){let o=null;for(let u of A){if(S.has(u))continue;let m=d(u),p=et(m,i);p<G||B(m,O=>F(O,i))<z||(!o||p>o.pct)&&(o={name:u,pct:p})}o&&(r.city=o.name,a.push(`city=${o.name} (${o.pct}% known cities)`))}let U=r.country?d(r.country):[],_=!!r.country&&T(U),ie=_?new Set(U.map(o=>w(o==null?null:String(o))).filter(Boolean)).size:0,H=_&&ie>=2,D=!!(r.lat&&r.lon)&&e.some(o=>{let u=+String(o[r.lat]??"").trim(),m=+String(o[r.lon]??"").trim();return isFinite(u)&&isFinite(m)&&u>=-90&&u<=90&&m>=-180&&m<=180&&String(o[r.lat]??"").trim()!==""&&String(o[r.lon]??"").trim()!==""});return r.lat&&r.lon&&!D&&s.push(`lat/lon=${r.lat}/${r.lon} (no row holds a usable coordinate pair)`),r.country&&!H&&!(r.city||r.state||r.zip||D)&&s.push(_?`country=${r.country} (every row resolves to the same country - nothing to place apart)`:`country=${r.country} (values are not country identifiers)`),{bind:!!(r.city||r.state||r.zip||H||D)?r:null,backfilled:a,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}function J(n,e){let t=e?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(n)||n<=t?0:Math.round(n-t)}function ot(n,e,t){let i=J(n,e);if(i===null||i<=0)return null;let c=typeof e?.freemiumColumnCapPivot=="number"?e.freemiumColumnCapPivot:4,a=i>c?e?.freemiumColumnCapMessageMany:e?.freemiumColumnCapMessageFew;if(typeof a!="string"||a.trim().length===0)return null;let s=a.split("{n}").join(String(i)).split("{fields}").join(i===1?"field":"fields"),r=ee(t);return r.length===0?s:s+" "+r.join(" ")}function ee(n){if(!n||n.length===0)return[];let e=[],t=new Map,i=new Map;for(let a of n){let s=typeof a?.dateGroupId=="string"?a.dateGroupId.trim():"";if(s!==""&&(t.has(s)||(e.push(s),t.set(s,0)),a.isDatePart===!0&&t.set(s,t.get(s)+1),a.isReassembledDate===!0&&!i.has(s))){let r=typeof a.sourceField=="string"?a.sourceField.trim():"",C=typeof a.name=="string"?a.name.trim():"",x=r!==""?r:C;x!==""&&i.set(s,x)}}let c=[];for(let a of e){let s=i.get(a),r=t.get(a)??0;!s||r===0||c.push(`'${s}' is a date hierarchy and counts as ${r+1} fields - bind the date itself instead of its hierarchy.`)}return c}var l=n=>n==null?"":String(n),R=n=>n===!0,ne=n=>{if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null},rt=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function te(n,e){let t={};for(let[i,c]of rt){let a=l(f(n,e+c));a&&(t[i]=a)}return t}function it(n){let e=a=>f(n,a),t=e("retryAfterSeconds"),i=te(n,"point"),c=te(n,"destPoint");return Object.keys(c).length&&(i.dest=c),{errorMessage:l(e("errorMessage")),code:l(e("code")),language:l(e("language")),version:Number(e("version")??0),codeSummary:l(e("codeSummary")),chartName:l(e("chartName")??e("chartType")),finalChartName:l(e("finalChartName")),warningMessage:l(e("warningMessage")),outputHash:l(e("outputHash")),validatorToken:l(e("validatorToken")),editCodeKey:l(e("editCodeKey")),signedLLMRequestID:l(e("signedLLMRequestID")),userReply:l(e("userReply")),userReplyOutcome:l(e("userReplyOutcome")),improvementSuggestion:l(e("improvementSuggestion")),geoColumn:l(e("geoColumn")),geoKind:l(e("geoKind")),geoPointCols:Object.keys(i).length?i:null,creditBalanceBefore:ne(e("creditBalanceBefore")),creditCost:ne(e("creditCost")),isServiceError:R(e("isServiceError")),isRateLimited:R(e("isRateLimited")),isRefusal:R(e("isRefusal")),isVersionNotFound:R(e("isVersionNotFound")),isGenerationCancelled:R(e("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:l(e("servedCorrelationId"))}}var oe=n=>n==null?void 0:Number(n),v=n=>l(n)||void 0;function st(n){let e=f(n,"charts"),t=f(n,"refused"),i=Array.isArray(e)?e.map(a=>{let s=C=>f(a,C),r=s("recommended");return{name:l(s("chartTypeName")??s("name")),description:l(s("description")??s("chartDesc")),rank:oe(s("rank")),score:oe(s("score")),renderer:v(s("renderer")),language:v(s("language")),isPreview:R(s("isPreview")),recommended:typeof r=="boolean"?r:void 0,viaProjection:v(s("viaProjection")),viaProjectionKey:v(s("viaProjectionKey")),detailNote:v(s("detailNote"))}}).filter(a=>a.name):null,c=Array.isArray(t)?t.map(a=>({name:l(f(a,"chartTypeName")??f(a,"name")),reason:l(f(a,"reason")),isVeto:R(f(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:l(f(n,"errorMessage")),charts:i,refused:c,noFitSummary:l(f(n,"noFitSummary"))}}function at(n){return!n||typeof n!="object"?null:{status:String(f(n,"status")??""),verdictReason:f(n,"verdictReason")??null,instruction:f(n,"instruction")??null,fix:f(n,"fix")??null,errorMessage:f(n,"errorMessage")??null}}export{G as CITY_ROLE_MATCH_PCT,ye as COMPOUND_MIN_STEM,bn as DEFAULT_GAP_FACTOR,ve as DEFAULT_TEMPERATURE,Te as GET_RANDOM,Pe as GLUED_STEM_MIN,rn as INTENSIVE_SUFFIX_TOKENS,on as INTENSIVE_WORD_TOKENS,zn as IndexedText,Tn as MAX_RUN_BOUNDS,an as POSITIONAL_SUFFIX_TOKENS,sn as POSITIONAL_WORD_TOKENS,Un as PREVIEW_OMITTED_FIELDS,h as ROLE_MATCH_PCT,An as SERIES_COMPLETENESS_MAX_LISTED,Nn as SERIES_COMPLETENESS_MIN_FILL,In as SERIES_KEY_MAX_DISTINCT,be as SIMPLE_STRING_HASH,xe as STR,he as SUBSTRING_MIN,ae as SUPPORTED_LANGUAGES,ue as SUPPORTED_LANGUAGE_CODES,E as admin1MatchPct,yn as allowedAggregations,qe as buildGeoIsoColumn,$e as buildGeoPointColumns,Ue as cityMatchPct,Ve as cityTagsFor,Gn as classifyAdditivity,gn as classifyForAggregation,Fn as classifyNumericValueNature,Dn as classifyTemporal,mn as codeNeedsLegacyAggNames,hn as codeReadsColumn,Rn as codeReadsColumnsByRoleOrPosition,cn as collapseRepeatedAggPrefix,xn as columnsTheCodeReads,Ye as countryRegion,Bn as decimalSeparatorOf,Cn as defaultAggregation,Kn as detectDecimalSeparator,en as detectFormatSignature,He as detectGeo,De as detectOrdinalDomain,_n as detectTextDatePattern,jn as encodePayload,$n as engineTypeForSqlType,fn as englishImplicitAggNames,me as foldName,ot as freemiumColumnCapRefusal,J as freemiumColumnsOverCap,ee as freemiumDateHierarchyClauses,Se as gluedPrefixStems,Qn as gzipWireText,ln as hasDefaultAggPrefix,pe as hasUnsegmentedScript,On as hostAggHint,Vn as ingest,Pn as isAggregationAllowed,L as isBlankLike,Ge as isCityTableLoaded,Me as isDeterministicRefusal,Ke as isGeoPointAmbiguity,En as isIdentifierName,je as isJoinGeoKind,Zn as isNdjsonContentType,Ee as isOrdinalFriendlyName,qn as keyedSigner,Le as localMidnightDateColumns,we as localMidnightToUtcDay,T as looksLikeCountryColumn,Re as matchNameToken,vn as measureCadence,kn as measureSeriesCompleteness,Xn as messageSignature,tn as monthLookupFor,pn as nameLooksIntensiveRate,dn as nameLooksPositional,fe as nameWords,Fe as normalizeCountry,ke as normalizeLocalMidnightDates,nn as normalizeMonthKey,I as normalizePlaceName,Be as normalizeZip5,Ae as parseDateStable,it as parseGenerateResponse,Wn as parseNumberText,st as parseQualifyResponse,at as parseReviewVerdict,Mn as parseTemporalPoint,Hn as payloadPreview,Ln as pickSeriesColumn,Jn as readGenerateStream,de as readName,f as readWireField,Oe as registerCityTable,Ze as registerIso3Regions,y as resolveAdmin1,We as resolveGeoPoint,ce as resolveLanguage,tt as resolvePointRoles,_e as safeDistinctValuesToShip,wn as seriesKeyVerdict,Sn as shareOfTotalIsHonest,un as stripHostAggPrefix,Je as summarizeCountryRegions,Xe as summarizeGeoExtent,le as supportedLanguage,Qe as toGeoIso,ge as unsegmentedRuns,Ne as wholeDayFrame,Ie as wholeDayIso,Yn as wireResponseFromFetch,Ce as wordEndsWith,$ as zipMatchPct,k as zipPrefixCandidates,ze as zipToPrefix3};
|
|
2
|
+
import{a as Un,b as Hn}from"./chunk-UQU75XXR.mjs";import{a as Qn,b as jn,c as qn,d as Xn,e as f,f as Zn,g as Yn,h as Jn}from"./chunk-BIC73LQV.mjs";import{a as Vn,b as Bn,c as Wn,d as Kn,e as $n}from"./chunk-PK6KRKNE.mjs";import{A as vn,B as wn,C as Nn,D as An,E as In,F as Ln,G as kn,H as En,I as _n,J as Fn,K as Dn,L as On,M as Gn,O as zn,a as Xe,b as Ze,c as Ye,d as Je,e as rn,f as on,g as sn,h as an,i as un,j as ln,k as cn,l as mn,m as fn,n as dn,o as pn,p as gn,q as yn,r as Cn,s as hn,t as Sn,u as Pn,v as Rn,w as xn,x as bn,y as Mn,z as Tn}from"./chunk-ZVHCLXKO.mjs";import{a as en}from"./chunk-QEH7WTLB.mjs";import{a as nn,b as tn}from"./chunk-2LR73DNS.mjs";import{a as j,b as q,c as He,d as Qe,e as je,f as qe}from"./chunk-C5I73OM2.mjs";import{a as A,f as I,g as P,h as L,i as O,j as De,k as Oe,l as Q,m as y,n as Ge,o as ze,p as Ve,q as k,r as Be,s as We,t as Ke,u as $e,v as G,w as Ue}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as Ee,b as _e,c as Fe}from"./chunk-35Z7JCND.mjs";import{A as ke,a as ae,b as ue,c as le,d as ce,e as me,f as fe,g as de,h as pe,i as ge,j as ye,k as Ce,l as he,m as Se,n as Pe,o as Re,p as xe,r as be,s as Me,t as Te,u as ve,v as we,w as Ne,x as Ae,y as Ie,z as Le}from"./chunk-ILHBRGIO.mjs";var z=2,Y=400;function B(n){return!!I(n)}function T(n){let e=new Set;for(let t of n){if(t==null)continue;let i=A(String(t));if(!L(i)&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function M(n){let e=T(n);if(e.length===0||W(n)<95)return!1;let t=e.filter(c=>B(c)&&!y(c)).length,i=e.filter(c=>!B(c)&&!!y(c)).length;return t>=1&&t>=i}function X(n,e){if(!y(n))return!1;let t=I(n);return t?e==="world"?!0:Q.has(t):!1}function W(n){let e=T(n);if(e.length===0)return 0;let t=0;for(let i of e)B(i)&&t++;return Math.round(t/e.length*1e3)/10}function E(n){let e=T(n);if(e.length===0)return 0;let t=0;for(let i of e)y(i)&&t++;return Math.round(t/e.length*1e3)/10}function $(n){let e=new Set;for(let t of n){if(t==null)continue;let i=String(t).trim();if(!L(A(i))&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function K(n){let e=$(n);if(e.length===0)return 0;let t=0;for(let i of e)k(i).length>0&&t++;return Math.round(t/e.length*1e3)/10}function Z(n,e){return q(e,j)?!0:$(n).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function et(n,e){let t=T(n);if(t.length===0)return 0;let i=0;for(let c of t)G(c,e)&&i++;return Math.round(i/t.length*1e3)/10}function V(n,e){let t=0;for(let i of T(n))e(i)&&t++;return t}function nt(n,e){let t=0;for(let i of $(n))e(i)&&t++;return t}function tt(n,e,t,i,c){let a=[],s=[],o={},C={},x=new Set(n),d=r=>e.map(u=>u[r]);for(let r of["city","country"]){let u=t?.[r];u&&x.has(u)&&(o[r]=u)}let oe=new Set(c??n);for(let r of["lat","lon"]){let u=t?.[r];u&&oe.has(u)&&(o[r]=u)}let h=t?.zip;if(h&&x.has(h)){let r=d(h),u=K(r);u<95?s.push(`zip=${h} (only ${u}% of values read as ZIPs)`):Z(r,h)?o.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&&x.has(g)){let r=d(g),u=T(r);u.length>0&&u.every(m=>X(m,i))?s.push(`state=${g} (every value is "CA", which is both Canada and California)`):M(r)?(s.push(`state=${g} (every value is a country, not a state)`),o.country||(o.country=g)):E(r)<95?s.push(`state=${g} (only ${E(r)}% of values are states/provinces)`):o.state=g}let S=new Set(Object.values(o).filter(Boolean)),w=n.filter(r=>!S.has(r)&&!r.startsWith("__"));if(!o.state){let r=null;for(let u of w){let m=d(u);if(M(m))continue;let p=E(m);if(p<95)continue;let D=V(m,N=>!!y(N)),se=V(m,N=>!!y(N)&&!X(N,i));D<z&&se<1||(!r||p>r.pct)&&(r={name:u,pct:p})}r&&(o.state=r.name,S.add(r.name),a.push(`state=${r.name} (${r.pct}% states/provinces)`))}if(!o.zip)for(let r of w){if(S.has(r))continue;let u=d(r),m=K(u);if(!(m<95)&&Z(u,r)&&!(nt(u,p=>k(p).length>0)<z)){o.zip=r,S.add(r),a.push(`zip=${r} (${m}% ZIP codes)`);break}}let b=o.country;if(!b||!M(d(b))){let r=null;for(let u of w){if(S.has(u)||!M(d(u)))continue;let m=W(d(u));(!r||m>r.pct)&&(r={name:u,pct:m})}r&&(b&&(s.push(`country=${b} (only ${W(d(b))}% of values are country identifiers; using ${r.name} instead)`),C.country=b),o.country=r.name,S.add(r.name),a.push(`country=${r.name}`))}if(!o.city){let r=null;for(let u of w){if(S.has(u))continue;let m=d(u),p=et(m,i);p<O||V(m,D=>G(D,i))<z||(!r||p>r.pct)&&(r={name:u,pct:p})}r&&(o.city=r.name,a.push(`city=${r.name} (${r.pct}% known cities)`))}let U=o.country?d(o.country):[],_=!!o.country&&M(U),ie=_?new Set(U.map(r=>I(r==null?null:String(r))).filter(Boolean)).size:0,H=_&&ie>=2,F=!!(o.lat&&o.lon)&&e.some(r=>{let u=+String(r[o.lat]??"").trim(),m=+String(r[o.lon]??"").trim();return isFinite(u)&&isFinite(m)&&u>=-90&&u<=90&&m>=-180&&m<=180&&String(r[o.lat]??"").trim()!==""&&String(r[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!F&&s.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!H&&!(o.city||o.state||o.zip||F)&&s.push(_?`country=${o.country} (every row resolves to the same country - nothing to place apart)`:`country=${o.country} (values are not country identifiers)`),{bind:!!(o.city||o.state||o.zip||H||F)?o:null,backfilled:a,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}function J(n,e){let t=e?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(n)||n<=t?0:Math.round(n-t)}function rt(n,e,t){let i=J(n,e);if(i===null||i<=0)return null;let c=typeof e?.freemiumColumnCapPivot=="number"?e.freemiumColumnCapPivot:4,a=i>c?e?.freemiumColumnCapMessageMany:e?.freemiumColumnCapMessageFew;if(typeof a!="string"||a.trim().length===0)return null;let s=a.split("{n}").join(String(i)).split("{fields}").join(i===1?"field":"fields"),o=ee(t);return o.length===0?s:s+" "+o.join(" ")}function ee(n){if(!n||n.length===0)return[];let e=[],t=new Map,i=new Map;for(let a of n){let s=typeof a?.dateGroupId=="string"?a.dateGroupId.trim():"";if(s!==""&&(t.has(s)||(e.push(s),t.set(s,0)),a.isDatePart===!0&&t.set(s,t.get(s)+1),a.isReassembledDate===!0&&!i.has(s))){let o=typeof a.sourceField=="string"?a.sourceField.trim():"",C=typeof a.name=="string"?a.name.trim():"",x=o!==""?o:C;x!==""&&i.set(s,x)}}let c=[];for(let a of e){let s=i.get(a),o=t.get(a)??0;!s||o===0||c.push(`'${s}' is a date hierarchy and counts as ${o+1} fields - bind the date itself instead of its hierarchy.`)}return c}var l=n=>n==null?"":String(n),R=n=>n===!0,ne=n=>{if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null},ot=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function te(n,e){let t={};for(let[i,c]of ot){let a=l(f(n,e+c));a&&(t[i]=a)}return t}function it(n){let e=a=>f(n,a),t=e("retryAfterSeconds"),i=te(n,"point"),c=te(n,"destPoint");return Object.keys(c).length&&(i.dest=c),{errorMessage:l(e("errorMessage")),code:l(e("code")),language:l(e("language")),version:Number(e("version")??0),codeSummary:l(e("codeSummary")),chartName:l(e("chartName")??e("chartType")),finalChartName:l(e("finalChartName")),warningMessage:l(e("warningMessage")),outputHash:l(e("outputHash")),validatorToken:l(e("validatorToken")),editCodeKey:l(e("editCodeKey")),signedLLMRequestID:l(e("signedLLMRequestID")),userReply:l(e("userReply")),userReplyOutcome:l(e("userReplyOutcome")),improvementSuggestion:l(e("improvementSuggestion")),geoColumn:l(e("geoColumn")),geoKind:l(e("geoKind")),geoPointCols:Object.keys(i).length?i:null,creditBalanceBefore:ne(e("creditBalanceBefore")),creditCost:ne(e("creditCost")),isServiceError:R(e("isServiceError")),isRateLimited:R(e("isRateLimited")),isRefusal:R(e("isRefusal")),isVersionNotFound:R(e("isVersionNotFound")),isGenerationCancelled:R(e("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:l(e("servedCorrelationId"))}}var re=n=>n==null?void 0:Number(n),v=n=>l(n)||void 0;function st(n){let e=f(n,"charts"),t=f(n,"refused"),i=Array.isArray(e)?e.map(a=>{let s=C=>f(a,C),o=s("recommended");return{name:l(s("chartTypeName")??s("name")),description:l(s("description")??s("chartDesc")),rank:re(s("rank")),score:re(s("score")),renderer:v(s("renderer")),language:v(s("language")),isPreview:R(s("isPreview")),recommended:typeof o=="boolean"?o:void 0,viaProjection:v(s("viaProjection")),viaProjectionKey:v(s("viaProjectionKey")),detailNote:v(s("detailNote"))}}).filter(a=>a.name):null,c=Array.isArray(t)?t.map(a=>({name:l(f(a,"chartTypeName")??f(a,"name")),reason:l(f(a,"reason")),isVeto:R(f(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:l(f(n,"errorMessage")),charts:i,refused:c,noFitSummary:l(f(n,"noFitSummary"))}}function at(n){return!n||typeof n!="object"?null:{status:String(f(n,"status")??""),verdictReason:f(n,"verdictReason")??null,instruction:f(n,"instruction")??null,fix:f(n,"fix")??null,errorMessage:f(n,"errorMessage")??null}}function ut(n){let{width:e,height:t}=n.measure();return{request:{height:t,width:e},hints:{viewportWidth:e,viewportHeight:t}}}function lt(n){let e=0;for(let t of n){if(t.isMeasure)continue;let i=t.distinctCount;typeof i=="number"&&i>e&&(e=i)}return e}export{O as CITY_ROLE_MATCH_PCT,ye as COMPOUND_MIN_STEM,bn as DEFAULT_GAP_FACTOR,ve as DEFAULT_TEMPERATURE,Me as GET_RANDOM,he as GLUED_STEM_MIN,on as INTENSIVE_SUFFIX_TOKENS,rn as INTENSIVE_WORD_TOKENS,zn as IndexedText,Mn as MAX_RUN_BOUNDS,an as POSITIONAL_SUFFIX_TOKENS,sn as POSITIONAL_WORD_TOKENS,Un as PREVIEW_OMITTED_FIELDS,P as ROLE_MATCH_PCT,wn as SERIES_COMPLETENESS_MAX_LISTED,Nn as SERIES_COMPLETENESS_MIN_FILL,An as SERIES_KEY_MAX_DISTINCT,be as SIMPLE_STRING_HASH,xe as STR,Pe as SUBSTRING_MIN,ae as SUPPORTED_LANGUAGES,ue as SUPPORTED_LANGUAGE_CODES,E as admin1MatchPct,yn as allowedAggregations,qe as buildGeoIsoColumn,Ke as buildGeoPointColumns,Ue as cityMatchPct,$e as cityTagsFor,On as classifyAdditivity,gn as classifyForAggregation,Gn as classifyNumericValueNature,Fn as classifyTemporal,mn as codeNeedsLegacyAggNames,Pn as codeReadsColumn,Rn as codeReadsColumnsByRoleOrPosition,cn as collapseRepeatedAggPrefix,xn as columnsTheCodeReads,Ye as countryRegion,Vn as decimalSeparatorOf,Cn as defaultAggregation,Bn as detectDecimalSeparator,en as detectFormatSignature,He as detectGeo,Fe as detectOrdinalDomain,_n as detectTextDatePattern,jn as encodePayload,Kn as engineTypeForSqlType,fn as englishImplicitAggNames,me as foldName,rt as freemiumColumnCapRefusal,J as freemiumColumnsOverCap,ee as freemiumDateHierarchyClauses,Se as gluedPrefixStems,Qn as gzipWireText,ln as hasDefaultAggPrefix,pe as hasUnsegmentedScript,Dn as hostAggHint,$n as ingest,hn as isAggregationAllowed,L as isBlankLike,Oe as isCityTableLoaded,Te as isDeterministicRefusal,Be as isGeoPointAmbiguity,En as isIdentifierName,je as isJoinGeoKind,Zn as isNdjsonContentType,Ee as isOrdinalFriendlyName,qn as keyedSigner,Le as localMidnightDateColumns,Ie as localMidnightToUtcDay,M as looksLikeCountryColumn,Re as matchNameToken,lt as maxNonMeasureCardinality,vn as measureCadence,kn as measureSeriesCompleteness,Xn as messageSignature,tn as monthLookupFor,pn as nameLooksIntensiveRate,dn as nameLooksPositional,fe as nameWords,Ge as normalizeCountry,ke as normalizeLocalMidnightDates,nn as normalizeMonthKey,A as normalizePlaceName,Ve as normalizeZip5,we as parseDateStable,it as parseGenerateResponse,Wn as parseNumberText,st as parseQualifyResponse,at as parseReviewVerdict,Tn as parseTemporalPoint,Hn as payloadPreview,Ln as pickSeriesColumn,Jn as readGenerateStream,de as readName,f as readWireField,De as registerCityTable,Ze as registerIso3Regions,y as resolveAdmin1,We as resolveGeoPoint,ce as resolveLanguage,tt as resolvePointRoles,_e as safeDistinctValuesToShip,In as seriesKeyVerdict,Sn as shareOfTotalIsHonest,un as stripHostAggPrefix,Je as summarizeCountryRegions,Xe as summarizeGeoExtent,le as supportedLanguage,Qe as toGeoIso,ge as unsegmentedRuns,ut as viewportFields,Ne as wholeDayFrame,Ae as wholeDayIso,Yn as wireResponseFromFetch,Ce as wordEndsWith,K as zipMatchPct,k as zipPrefixCandidates,ze as zipToPrefix3};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -44,3 +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 } from "./wireBuild";
|
|
48
|
+
export type { ViewportFields } from "./wireBuild";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ViewportSource } from "./host/services";
|
|
2
|
+
/** The two places a generate request states its drawing area, in the order they travel. */
|
|
3
|
+
export interface ViewportFields {
|
|
4
|
+
/** The request's own `height` and `width`. */
|
|
5
|
+
request: {
|
|
6
|
+
height: number;
|
|
7
|
+
width: number;
|
|
8
|
+
};
|
|
9
|
+
/** The client hints' `viewportWidth` and `viewportHeight`. */
|
|
10
|
+
hints: {
|
|
11
|
+
viewportWidth: number;
|
|
12
|
+
viewportHeight: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* THE VIEWPORT A REQUEST IS SIZED FOR: one measurement, stated twice.
|
|
17
|
+
*
|
|
18
|
+
* A generate request carries its drawing area in two places - the request's `width`/`height` and
|
|
19
|
+
* the client hints' `viewportWidth`/`viewportHeight` - and the server reads each in a different
|
|
20
|
+
* place (the chart gates on one side, the prompt's size guidance on the other). If they disagree,
|
|
21
|
+
* the server's two readers are told two different sizes for the same chart. So the source is
|
|
22
|
+
* measured ONCE per call and both halves come from that one answer.
|
|
23
|
+
*
|
|
24
|
+
* The numbers are the source's, unchanged: a host that rounds, clamps or substitutes a stated size
|
|
25
|
+
* for a measured one does it in its source, where it knows why.
|
|
26
|
+
*/
|
|
27
|
+
export declare function viewportFields(source: ViewportSource): ViewportFields;
|
|
28
|
+
/**
|
|
29
|
+
* THE LARGEST CATEGORY COUNT AMONG THE DIMENSIONS - the client hints' `maxNonMeasureCardinality`.
|
|
30
|
+
*
|
|
31
|
+
* The server reads it for its label-density and many-series advice: how many distinct values a chart
|
|
32
|
+
* may have to lay out along one axis or in one legend. Every host sends it by one rule: the largest `distinctCount`
|
|
33
|
+
* among the columns that are not measures, 0 when there is none. A count that is not a number is not
|
|
34
|
+
* a count and is skipped.
|
|
35
|
+
*/
|
|
36
|
+
export declare function maxNonMeasureCardinality(columns: readonly {
|
|
37
|
+
isMeasure?: boolean | null;
|
|
38
|
+
distinctCount?: number | null;
|
|
39
|
+
}[]): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.15",
|
|
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",
|