@bicharts/shape-core 0.5.46 → 0.5.48
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/geoPointRoles.d.ts +15 -1
- 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
|
|
2
|
+
import{a as Ut,b as Zt}from"./chunk-5233JUKA.mjs";import{a as Rt,b as Nt,c as Ot,d as wt,e as Ft,f as $t,g as Dt,h as Kt,i as Bt,j as Ht,k as Vt}from"./chunk-LDC2C4WC.mjs";import{a as Et}from"./chunk-QEH7WTLB.mjs";import{a as kt,b as Mt}from"./chunk-2LR73DNS.mjs";import{a as Lt,b as zt,c as Gt}from"./chunk-NWDPA7DG.mjs";import{a as j,b as W,c as Tt,d as _t,e as Pt,f as It}from"./chunk-SAASSIJ7.mjs";import{a as S,f as T,g as y,h as _,i as k,j as pt,k as mt,l as q,m as g,n as yt,o as At,p as ht,q as P,r as vt,s as xt,t as Ct,u as bt,v as M,w as St}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as dt,b as ft,c as gt}from"./chunk-WBEROMBG.mjs";var X=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops"],Y=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops"],J=["latitude","longitude"],Q=["latitude","longitude"],tt=/^\s*(sum|count|count\s+distinct|distinct\s+count)\s+of\s+/i,qt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,jt=new RegExp("\\b("+X.join("|")+")\\b|("+Y.join("|")+")$","i"),Wt=new RegExp("\\b("+J.join("|")+")\\b|("+Q.join("|")+")$","i");function L(e){return e?String(e).replace(tt,"").trim():""}function et(e){return!!e&&tt.test(String(e))}function Xt(e){let t=L(e);return t.length===0?"":t.replace(qt," ")}function nt(e,t){return t?e.test(Xt(t))||e.test(L(t)):!1}function z(e){return nt(Wt,e)}function it(e){return nt(jt,e)||z(e)}var ot=/int|double|decimal|single|float|number|currency|money/i;function Yt(e){let t=String(e?.valueNature??"").trim().toLowerCase();return t==="categorical"?"Categorical":t==="ordinal"?"Ordinal":t==="continuous"||e?.isMeasure===!0||ot.test(String(e?.dataType??""))?"Continuous":"Categorical"}function Jt(e){return e?.isMeasure===!0||ot.test(String(e?.dataType??""))}function G(e){let t=e??{},i=Yt(t);if(i!=="Continuous")return{nature:i,additivity:"unknown",basis:"role",suppressed:!1};if(z(t.name))return{nature:i,additivity:"positional",basis:"name",suppressed:!0};let s=String(t.additivity??"").trim().toLowerCase();if(!(s==="additive"&&et(t.name))){if(s==="additive")return{nature:i,additivity:"additive",basis:"measured",suppressed:!1};if(s==="part_of_whole")return{nature:i,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(s==="intensive_rate")return{nature:i,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return t.discourageAggregationAcrossGroups===!0?{nature:i,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:it(t.name)?{nature:i,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:i,additivity:"additive",basis:"default",suppressed:!1}}function F(e){let t=G(e),i=e??{};if(t.nature==="Categorical")return["first","distinctcount","count"];if(t.nature==="Ordinal")return Jt(i)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(t.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Qt(e){return F(e)[0]}function te(e,t){return F(e).indexOf(t)>=0}function ee(e,t){if(t!=="sum"&&t!=="count")return!1;if(t==="count")return!0;let i=G(e);return i.additivity==="additive"||i.additivity==="part_of_whole"||i.additivity==="unknown"}var $=2,at=400;function K(e){return!!T(e)}function v(e){let t=new Set;for(let i of e){if(i==null)continue;let s=S(String(i));if(!_(s)&&!t.has(s)&&(t.add(s),t.size>=at))break}return Array.from(t)}function h(e){let t=v(e);if(t.length===0||B(e)<95)return!1;let i=t.filter(u=>K(u)&&!g(u)).length,s=t.filter(u=>!K(u)&&!!g(u)).length;return i>=1&&i>=s}function rt(e,t){if(!g(e))return!1;let i=T(e);return i?t==="world"?!0:q.has(i):!1}function B(e){let t=v(e);if(t.length===0)return 0;let i=0;for(let s of t)K(s)&&i++;return Math.round(i/t.length*1e3)/10}function I(e){let t=v(e);if(t.length===0)return 0;let i=0;for(let s of t)g(s)&&i++;return Math.round(i/t.length*1e3)/10}function V(e){let t=new Set;for(let i of e){if(i==null)continue;let s=String(i).trim();if(!_(S(s))&&!t.has(s)&&(t.add(s),t.size>=at))break}return Array.from(t)}function H(e){let t=V(e);if(t.length===0)return 0;let i=0;for(let s of t)P(s).length>0&&i++;return Math.round(i/t.length*1e3)/10}function st(e,t){return W(t,j)?!0:V(e).some(i=>/^\d{5}(-\d{4})?$/.test(i.replace(/\.0+$/,"")))}function ne(e,t){let i=v(e);if(i.length===0)return 0;let s=0;for(let u of i)M(u,t)&&s++;return Math.round(s/i.length*1e3)/10}function D(e,t){let i=0;for(let s of v(e))t(s)&&i++;return i}function ie(e,t){let i=0;for(let s of V(e))t(s)&&i++;return i}function oe(e,t,i,s,u){let x=[],c=[],o={},R={},N=new Set(e),l=n=>t.map(r=>r[n]);for(let n of["city","country"]){let r=i?.[n];r&&N.has(r)&&(o[n]=r)}let ut=new Set(u??e);for(let n of["lat","lon"]){let r=i?.[n];r&&ut.has(r)&&(o[n]=r)}let p=i?.zip;if(p&&N.has(p)){let n=l(p),r=H(n);r<95?c.push(`zip=${p} (only ${r}% of values read as ZIPs)`):st(n,p)?o.zip=p:c.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let f=i?.state;if(f&&N.has(f)){let n=l(f),r=v(n);r.length>0&&r.every(a=>rt(a,s))?c.push(`state=${f} (every value is "CA", which is both Canada and California)`):h(n)?(c.push(`state=${f} (every value is a country, not a state)`),o.country||(o.country=f)):I(n)<95?c.push(`state=${f} (only ${I(n)}% of values are states/provinces)`):o.state=f}let m=new Set(Object.values(o).filter(Boolean)),C=e.filter(n=>!m.has(n)&&!n.startsWith("__"));if(!o.state){let n=null;for(let r of C){let a=l(r);if(h(a))continue;let d=I(a);if(d<95)continue;let E=D(a,b=>!!g(b)),ct=D(a,b=>!!g(b)&&!rt(b,s));E<$&&ct<1||(!n||d>n.pct)&&(n={name:r,pct:d})}n&&(o.state=n.name,m.add(n.name),x.push(`state=${n.name} (${n.pct}% states/provinces)`))}if(!o.zip)for(let n of C){if(m.has(n))continue;let r=l(n),a=H(r);if(!(a<95)&&st(r,n)&&!(ie(r,d=>P(d).length>0)<$)){o.zip=n,m.add(n),x.push(`zip=${n} (${a}% ZIP codes)`);break}}let A=o.country;if(!A||!h(l(A))){let n=null;for(let r of C){if(m.has(r)||!h(l(r)))continue;let a=B(l(r));(!n||a>n.pct)&&(n={name:r,pct:a})}n&&(A&&(c.push(`country=${A} (only ${B(l(A))}% of values are country identifiers; using ${n.name} instead)`),R.country=A),o.country=n.name,m.add(n.name),x.push(`country=${n.name}`))}if(!o.city){let n=null;for(let r of C){if(m.has(r))continue;let a=l(r),d=ne(a,s);d<k||D(a,E=>M(E,s))<$||(!n||d>n.pct)&&(n={name:r,pct:d})}n&&(o.city=n.name,x.push(`city=${n.name} (${n.pct}% known cities)`))}let U=o.country?l(o.country):[],O=!!o.country&&h(U),lt=O?new Set(U.map(n=>T(n==null?null:String(n))).filter(Boolean)).size:0,Z=O&<>=2,w=!!(o.lat&&o.lon)&&t.some(n=>{let r=+String(n[o.lat]??"").trim(),a=+String(n[o.lon]??"").trim();return isFinite(r)&&isFinite(a)&&r>=-90&&r<=90&&a>=-180&&a<=180&&String(n[o.lat]??"").trim()!==""&&String(n[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!w&&c.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!Z&&!(o.city||o.state||o.zip||w)&&c.push(O?`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||Z||w)?o:null,backfilled:x,refused:c,...Object.keys(R).length?{labelFallback:R}:{}}}export{k as CITY_ROLE_MATCH_PCT,Gt as GET_RANDOM,Y as INTENSIVE_SUFFIX_TOKENS,X as INTENSIVE_WORD_TOKENS,Vt as IndexedText,Q as POSITIONAL_SUFFIX_TOKENS,J as POSITIONAL_WORD_TOKENS,y as ROLE_MATCH_PCT,zt as SIMPLE_STRING_HASH,Lt as STR,I as admin1MatchPct,F as allowedAggregations,It as buildGeoIsoColumn,Ct as buildGeoPointColumns,St as cityMatchPct,bt as cityTagsFor,Bt as classifyAdditivity,G as classifyForAggregation,Ht as classifyNumericValueNature,Dt as classifyTemporal,Ot as countryRegion,Qt as defaultAggregation,Et as detectFormatSignature,Tt as detectGeo,gt as detectOrdinalDomain,$t as detectTextDatePattern,Ut as engineTypeForSqlType,et as hasDefaultAggPrefix,Kt as hostAggHint,Zt as ingest,te as isAggregationAllowed,_ as isBlankLike,mt as isCityTableLoaded,vt as isGeoPointAmbiguity,Ft as isIdentifierName,Pt as isJoinGeoKind,dt as isOrdinalFriendlyName,h as looksLikeCountryColumn,Mt as monthLookupFor,it as nameLooksIntensiveRate,z as nameLooksPositional,yt as normalizeCountry,kt as normalizeMonthKey,S as normalizePlaceName,ht as normalizeZip5,pt as registerCityTable,Nt as registerIso3Regions,g as resolveAdmin1,xt as resolveGeoPoint,oe as resolvePointRoles,ft as safeDistinctValuesToShip,ee as shareOfTotalIsHonest,L as stripHostAggPrefix,wt as summarizeCountryRegions,Rt as summarizeGeoExtent,_t as toGeoIso,H as zipMatchPct,P as zipPrefixCandidates,At as zipToPrefix3};
|
|
@@ -78,4 +78,18 @@ export declare function zipMatchPct(values: Array<unknown>): number;
|
|
|
78
78
|
* a refusal drops that ONE role, leaving the rest of the binding intact, because
|
|
79
79
|
* geocoding from city alone still beats geocoding from nothing.
|
|
80
80
|
*/
|
|
81
|
-
export declare function resolvePointRoles(columns: string[], rows: Array<Record<string, any>>, hint: PointBind | null, mapKind?: GeoMapKind | null
|
|
81
|
+
export declare function resolvePointRoles(columns: string[], rows: Array<Record<string, any>>, hint: PointBind | null, mapKind?: GeoMapKind | null,
|
|
82
|
+
/** Columns the COORDINATE roles may be carried over from — the full set, measures included.
|
|
83
|
+
* Defaults to `columns`, so a caller that does not pass it behaves exactly as before.
|
|
84
|
+
*
|
|
85
|
+
* WHY THIS IS SEPARATE FROM `columns` (2026-09-02). `columns` must exclude measures, and the
|
|
86
|
+
* reason above is a good one: it protects the BACKFILL, where a store number would be
|
|
87
|
+
* adopted as the ZIP column on digit shape alone. But the same list also gated the
|
|
88
|
+
* carry-over of an EXPLICITLY HINTED lat/lon — and coordinates are always measures, so those
|
|
89
|
+
* two roles were unreachable by construction. Measured on a 21-city table with explicit
|
|
90
|
+
* Latitude/Longitude: `precisionCounts.latlon = 0`, every row geocoded from its city NAME,
|
|
91
|
+
* two rows refused outright for an ambiguous name while carrying exact coordinates, and the
|
|
92
|
+
* rest placed at the gazetteer's coordinates rather than the data's — so editing a Latitude
|
|
93
|
+
* cell moved no mark. Backfill still draws from `columns`; only the hinted coordinate roles
|
|
94
|
+
* read this, and `latLonCanPlace` below is what verifies them. */
|
|
95
|
+
coordinateColumns?: string[]): PointRoleResolution;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.48",
|
|
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",
|