@bicharts/shape-core 0.5.112 → 0.5.113
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/freemiumCaps.d.ts +56 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models.d.ts +4 -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
|
|
2
|
+
import{a as pt,b as dt}from"./chunk-UQU75XXR.mjs";import{a as ft,b as mt}from"./chunk-QVD2YGH2.mjs";import{A as ot,B as it,C as rt,D as st,E as at,F as lt,G as ut,H as ct,a as Ie,b as _e,c as Le,d as Ne,e as Ee,f as De,g as Fe,h as Ge,i as ze,j as $e,k as Be,l as Ke,m as He,n as Ue,o as Ve,p as We,q as qe,r as Ze,s as je,t as Xe,u as Ye,v as Je,w as Qe,x as et,y as tt,z as nt}from"./chunk-RS7LNZD7.mjs";import{a as ke}from"./chunk-QEH7WTLB.mjs";import{a as Oe,b as we}from"./chunk-2LR73DNS.mjs";import{a as U,b as V,c as Te,d as Me,e as be,f as ve}from"./chunk-OZEOA6ZE.mjs";import{a as S,f as T,g as y,h as M,i as O,j as de,k as ge,l as H,m as p,n as ye,o as Ce,p as he,q as b,r as Pe,s as xe,t as Ae,u as Re,v as w,w as Se}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as fe,b as me,c as pe}from"./chunk-N3ZYRMZJ.mjs";import{a as Q,b as ee,d as te,e as ne,f as oe,g as ie,h as re,i as se,j as ae,k as le,l as ue,m as ce}from"./chunk-FUTSF2X5.mjs";var E=2,Z=400;function F(i){return!!T(i)}function P(i){let n=new Set;for(let t of i){if(t==null)continue;let s=S(String(t));if(!M(s)&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function h(i){let n=P(i);if(n.length===0||G(i)<95)return!1;let t=n.filter(l=>F(l)&&!p(l)).length,s=n.filter(l=>!F(l)&&!!p(l)).length;return t>=1&&t>=s}function W(i,n){if(!p(i))return!1;let t=T(i);return t?n==="world"?!0:H.has(t):!1}function G(i){let n=P(i);if(n.length===0)return 0;let t=0;for(let s of n)F(s)&&t++;return Math.round(t/n.length*1e3)/10}function v(i){let n=P(i);if(n.length===0)return 0;let t=0;for(let s of n)p(s)&&t++;return Math.round(t/n.length*1e3)/10}function $(i){let n=new Set;for(let t of i){if(t==null)continue;let s=String(t).trim();if(!M(S(s))&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function z(i){let n=$(i);if(n.length===0)return 0;let t=0;for(let s of n)b(s).length>0&&t++;return Math.round(t/n.length*1e3)/10}function q(i,n){return V(n,U)?!0:$(i).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function gt(i,n){let t=P(i);if(t.length===0)return 0;let s=0;for(let l of t)w(l,n)&&s++;return Math.round(s/t.length*1e3)/10}function D(i,n){let t=0;for(let s of P(i))n(s)&&t++;return t}function yt(i,n){let t=0;for(let s of $(i))n(s)&&t++;return t}function Ct(i,n,t,s,l){let x=[],c=[],o={},I={},_=new Set(i),u=e=>n.map(r=>r[e]);for(let e of["city","country"]){let r=t?.[e];r&&_.has(r)&&(o[e]=r)}let X=new Set(l??i);for(let e of["lat","lon"]){let r=t?.[e];r&&X.has(r)&&(o[e]=r)}let d=t?.zip;if(d&&_.has(d)){let e=u(d),r=z(e);r<95?c.push(`zip=${d} (only ${r}% of values read as ZIPs)`):q(e,d)?o.zip=d:c.push(`zip=${d} (all values are 3-4 digits with nothing to say they are postal)`)}let m=t?.state;if(m&&_.has(m)){let e=u(m),r=P(e);r.length>0&&r.every(a=>W(a,s))?c.push(`state=${m} (every value is "CA", which is both Canada and California)`):h(e)?(c.push(`state=${m} (every value is a country, not a state)`),o.country||(o.country=m)):v(e)<95?c.push(`state=${m} (only ${v(e)}% of values are states/provinces)`):o.state=m}let g=new Set(Object.values(o).filter(Boolean)),A=i.filter(e=>!g.has(e)&&!e.startsWith("__"));if(!o.state){let e=null;for(let r of A){let a=u(r);if(h(a))continue;let f=v(a);if(f<95)continue;let k=D(a,R=>!!p(R)),J=D(a,R=>!!p(R)&&!W(R,s));k<E&&J<1||(!e||f>e.pct)&&(e={name:r,pct:f})}e&&(o.state=e.name,g.add(e.name),x.push(`state=${e.name} (${e.pct}% states/provinces)`))}if(!o.zip)for(let e of A){if(g.has(e))continue;let r=u(e),a=z(r);if(!(a<95)&&q(r,e)&&!(yt(r,f=>b(f).length>0)<E)){o.zip=e,g.add(e),x.push(`zip=${e} (${a}% ZIP codes)`);break}}let C=o.country;if(!C||!h(u(C))){let e=null;for(let r of A){if(g.has(r)||!h(u(r)))continue;let a=G(u(r));(!e||a>e.pct)&&(e={name:r,pct:a})}e&&(C&&(c.push(`country=${C} (only ${G(u(C))}% of values are country identifiers; using ${e.name} instead)`),I.country=C),o.country=e.name,g.add(e.name),x.push(`country=${e.name}`))}if(!o.city){let e=null;for(let r of A){if(g.has(r))continue;let a=u(r),f=gt(a,s);f<O||D(a,k=>w(k,s))<E||(!e||f>e.pct)&&(e={name:r,pct:f})}e&&(o.city=e.name,x.push(`city=${e.name} (${e.pct}% known cities)`))}let B=o.country?u(o.country):[],L=!!o.country&&h(B),Y=L?new Set(B.map(e=>T(e==null?null:String(e))).filter(Boolean)).size:0,K=L&&Y>=2,N=!!(o.lat&&o.lon)&&n.some(e=>{let r=+String(e[o.lat]??"").trim(),a=+String(e[o.lon]??"").trim();return isFinite(r)&&isFinite(a)&&r>=-90&&r<=90&&a>=-180&&a<=180&&String(e[o.lat]??"").trim()!==""&&String(e[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!N&&c.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!K&&!(o.city||o.state||o.zip||N)&&c.push(L?`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||K||N)?o:null,backfilled:x,refused:c,...Object.keys(I).length?{labelFallback:I}:{}}}function j(i,n){let t=n?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(i)||i<=t?0:Math.round(i-t)}function ht(i,n){let t=j(i,n);if(t===null||t<=0)return null;let s=typeof n?.freemiumColumnCapPivot=="number"?n.freemiumColumnCapPivot:4,l=t>s?n?.freemiumColumnCapMessageMany:n?.freemiumColumnCapMessageFew;return typeof l!="string"||l.trim().length===0?null:l.split("{n}").join(String(t)).split("{fields}").join(t===1?"field":"fields")}export{O as CITY_ROLE_MATCH_PCT,et as DEFAULT_GAP_FACTOR,ie as DEFAULT_TEMPERATURE,ne as GET_RANDOM,De as INTENSIVE_SUFFIX_TOKENS,Ee as INTENSIVE_WORD_TOKENS,ct as IndexedText,tt as MAX_RUN_BOUNDS,Ge as POSITIONAL_SUFFIX_TOKENS,Fe as POSITIONAL_WORD_TOKENS,pt as PREVIEW_OMITTED_FIELDS,y as ROLE_MATCH_PCT,te as SIMPLE_STRING_HASH,ee as STR,v as admin1MatchPct,qe as allowedAggregations,ve as buildGeoIsoColumn,Ae as buildGeoPointColumns,Se as cityMatchPct,Re as cityTagsFor,lt as classifyAdditivity,We as classifyForAggregation,ut as classifyNumericValueNature,st as classifyTemporal,Ke as codeNeedsLegacyAggNames,Ye as codeReadsColumn,Je as codeReadsColumnsByRoleOrPosition,Be as collapseRepeatedAggPrefix,Qe as columnsTheCodeReads,Le as countryRegion,Ze as defaultAggregation,ke as detectFormatSignature,Te as detectGeo,pe as detectOrdinalDomain,rt as detectTextDatePattern,ft as engineTypeForSqlType,He as englishImplicitAggNames,ht as freemiumColumnCapRefusal,j as freemiumColumnsOverCap,$e as hasDefaultAggPrefix,at as hostAggHint,mt as ingest,je as isAggregationAllowed,M as isBlankLike,ge as isCityTableLoaded,oe as isDeterministicRefusal,Pe as isGeoPointAmbiguity,it as isIdentifierName,be as isJoinGeoKind,fe as isOrdinalFriendlyName,ue as localMidnightDateColumns,le as localMidnightToUtcDay,h as looksLikeCountryColumn,ot as measureCadence,we as monthLookupFor,Ve as nameLooksIntensiveRate,Ue as nameLooksPositional,Q as nameWords,ye as normalizeCountry,ce as normalizeLocalMidnightDates,Oe as normalizeMonthKey,S as normalizePlaceName,he as normalizeZip5,re as parseDateStable,nt as parseTemporalPoint,dt as payloadPreview,de as registerCityTable,_e as registerIso3Regions,p as resolveAdmin1,xe as resolveGeoPoint,Ct as resolvePointRoles,me as safeDistinctValuesToShip,Xe as shareOfTotalIsHonest,ze as stripHostAggPrefix,Ne as summarizeCountryRegions,Ie as summarizeGeoExtent,Me as toGeoIso,se as wholeDayFrame,ae as wholeDayIso,z as zipMatchPct,b as zipPrefixCandidates,Ce as zipToPrefix3};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freemium entitlement walls a host can ANTICIPATE, in the server's own words.
|
|
3
|
+
*
|
|
4
|
+
* ITEM 634 (2026-09-17), from the prod 2956-2962 review.
|
|
5
|
+
*
|
|
6
|
+
* A first-time freemium reader behind a corporate proxy bound twenty fields against a cap of
|
|
7
|
+
* twelve. The server did everything right: it refused at the routing boundary in 31 ms, charged
|
|
8
|
+
* nothing, handed the rate-limit slot back, and composed a sentence naming exactly how many fields
|
|
9
|
+
* to drop. The response never came back through the proxy, so what the reader actually read was
|
|
10
|
+
* "We couldn't reach the charting service - it may be offline, or blocked on this network", and
|
|
11
|
+
* they left inside a second.
|
|
12
|
+
*
|
|
13
|
+
* The question never needed the wire. The bound column count and the freemium state are both in
|
|
14
|
+
* the host's hand before the request is built.
|
|
15
|
+
*
|
|
16
|
+
* TWO RULES THIS MODULE EXISTS TO KEEP:
|
|
17
|
+
*
|
|
18
|
+
* 1. ANTICIPATE, NEVER ENFORCE. The server's check does not move and stays the only gate that
|
|
19
|
+
* decides anything. A host that skips this, or is built from a patched bundle, or calls the
|
|
20
|
+
* API directly, is refused exactly as before. That is the USERTEXT lesson read the other way
|
|
21
|
+
* round: a tier boundary is never *enforced* on a client.
|
|
22
|
+
*
|
|
23
|
+
* 2. ONE AUTHOR OF THE WORDING. The sentence is not written here. The server ships its own
|
|
24
|
+
* templates on the licence-status response with `{n}` and `{fields}` left unfilled - it does
|
|
25
|
+
* not know the reader's count at status time - and this module only substitutes. An operator
|
|
26
|
+
* override of the server's message therefore reaches every host for free, and a host that
|
|
27
|
+
* re-words the refusal locally has reintroduced the drift this was built to remove.
|
|
28
|
+
*
|
|
29
|
+
* Absent fields (an older server, or a licensed caller) mean "cannot be anticipated", and every
|
|
30
|
+
* function here answers null so the host behaves exactly as it did before the field existed.
|
|
31
|
+
* There is no version test anywhere: the capability IS the presence of the field.
|
|
32
|
+
*/
|
|
33
|
+
import { GetLicenseStatusResult } from "./models";
|
|
34
|
+
/** What a host needs to answer the question, narrowed from the full status object so a caller can
|
|
35
|
+
* pass a partial - the add-in and the React demo hold their own reduced status shapes. */
|
|
36
|
+
export type FreemiumColumnCapStatus = Pick<GetLicenseStatusResult, "freemiumMaxShapeColumns" | "freemiumColumnCapMessageFew" | "freemiumColumnCapMessageMany" | "freemiumColumnCapPivot">;
|
|
37
|
+
/**
|
|
38
|
+
* Is this binding over the freemium column cap, and by how many?
|
|
39
|
+
*
|
|
40
|
+
* `shapeColumnCount` is counted in SHAPE space - the same space the server counts - which includes
|
|
41
|
+
* the `__rowIdx__` column a host injects for selection threading. That is exactly why every
|
|
42
|
+
* message states the DIFFERENCE and never the cap: the cap is one more than the fields a reader
|
|
43
|
+
* can see, and quoting it invites them to trim to precisely that and be refused again.
|
|
44
|
+
*
|
|
45
|
+
* Returns 0 when within the cap, and null when the server did not send one.
|
|
46
|
+
*/
|
|
47
|
+
export declare function freemiumColumnsOverCap(shapeColumnCount: number, status: FreemiumColumnCapStatus | null | undefined): number | null;
|
|
48
|
+
/**
|
|
49
|
+
* The refusal a reader over the cap should read, or null when there is nothing to say - within the
|
|
50
|
+
* cap, not freemium, or a server that sent no templates.
|
|
51
|
+
*
|
|
52
|
+
* The plural is chosen here rather than by the server for the one reason the server cannot: it
|
|
53
|
+
* depends on the reader's count. It is English-only, like every other plural in this codebase, and
|
|
54
|
+
* belongs to item 543's catalogue work rather than to this one.
|
|
55
|
+
*/
|
|
56
|
+
export declare function freemiumColumnCapRefusal(shapeColumnCount: number, status: FreemiumColumnCapStatus | null | undefined): string | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -28,3 +28,5 @@ export type { DataSource, IngestOptions, IngestResult, ColumnDescriptor, SqlColu
|
|
|
28
28
|
export { payloadPreview, PREVIEW_OMITTED_FIELDS } from "./payloadPreview";
|
|
29
29
|
export type { PayloadPreviewOptions } from "./payloadPreview";
|
|
30
30
|
export { codeReadsColumn, codeReadsColumnsByRoleOrPosition, columnsTheCodeReads } from "./codeColumnReads";
|
|
31
|
+
export { freemiumColumnsOverCap, freemiumColumnCapRefusal } from "./freemiumCaps";
|
|
32
|
+
export type { FreemiumColumnCapStatus } from "./freemiumCaps";
|
package/dist/types/models.d.ts
CHANGED
|
@@ -332,6 +332,10 @@ export type GetLicenseStatusResult = {
|
|
|
332
332
|
freemiumWarnAtPercent?: number;
|
|
333
333
|
freemiumExhausted?: boolean;
|
|
334
334
|
freemiumStatusMessage?: string;
|
|
335
|
+
freemiumMaxShapeColumns?: number;
|
|
336
|
+
freemiumColumnCapMessageFew?: string;
|
|
337
|
+
freemiumColumnCapMessageMany?: string;
|
|
338
|
+
freemiumColumnCapPivot?: number;
|
|
335
339
|
modelCostMultipliers?: Record<string, number>;
|
|
336
340
|
modelDescriptions?: Record<string, string>;
|
|
337
341
|
modelDisplayNames?: Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.113",
|
|
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",
|