@bicharts/shape-core 0.6.135 → 0.6.136
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/chunk-ZOS36CGD.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/ingest.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-TZFHDUVE.mjs +0 -2
package/dist/ingest.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{c as a,d as b,e as c}from"./chunk-
|
|
2
|
+
import{c as a,d as b,e as c}from"./chunk-ZOS36CGD.mjs";import"./chunk-UHEXA4HI.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-TZ74QIKA.mjs";import"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-3ZAS32F5.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.136",
|
|
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",
|
package/dist/chunk-TZFHDUVE.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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{R as N,Z as R,f as L}from"./chunk-UHEXA4HI.mjs";import{a as h,c as A,d as x,e as I}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import k from"papaparse";var O=["#N/A","#NV","#N/D","#N/D!","#N/B","#\u041D/\u0414","#I/T","#PUUTTUU!","#SAKNAS!","#HI\xC1NYZIK","#NEN\xCD_K_DISPOZICI","#YOK","#GETTING_DATA"],j=new Set(O.map(e=>e.toUpperCase())),$=/^#[\p{Lu}\p{Nd}_/.¡¿]{1,24}[!?]$/u;function w(e){if(typeof e!="string")return!1;let o=e.trim();return o.length<2||o[0]!=="#"?!1:j.has(o.toUpperCase())||$.test(o)}var M=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function q(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let m of e){if(m==null)continue;if(typeof m=="number"){l++,a++,Number.isInteger(m)&&r++;continue}if(m instanceof Date){l++,i++;continue}if(typeof m=="boolean"){l++;continue}let c=String(m).trim();if(c!==""){if(l++,P.test(h(c))){r++,a++;continue}if(I(c,o)){a++;continue}if((v.test(c)||V.test(c))&&!isNaN(Date.parse(c))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function F(e,o){let n=r=>!!r&&o.some((a,i)=>a&&w(r[i]));return e.some(n)?e.map(r=>n(r)?r.map((a,i)=>o[i]&&w(a)?null:a):r):e}function U(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=h(a);return P.test(i)?parseInt(i,10):null}case"Decimal":return x(a,n);case"DateTime":return r?r.read(a):C(a);default:return a}}function G(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*W(e,o){for(let n of e)yield n?.[o]}function p(e,o,n){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let r=e.length;o=F(o,e.map(t=>t.dataType===void 0));let a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>A(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(W(o,s),{locale:n.locale??"en"}):null),m=e.map((t,s)=>t.dataType??q(a[s],i[s],l[s]!==null)),c=new Set((n.measures??[]).map(t=>t.toLowerCase())),D=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),_=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),S=e.map((t,s)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((m[s]==="Integer"||m[s]==="Decimal")&&!N(t.name));c.has(u)&&(f=!0),D.has(u)&&(f=!1);let E={name:t.name,dataType:m[s],isMeasure:f};return f&&_.has(u)&&(E.discourageAggregationAcrossGroups=!0),E}),d=new R;d.dedupRows=n.dedup!==!1,d.tellApartNames=n.tellApartNames!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(S),d.declareDimensions(S.filter((t,s)=>D.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,f)=>U(s?.[f],m[f],i[f],l[f])),t)}let g=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),T=new Map(g.map(t=>[t.name,t]));e.forEach(t=>{let s=T.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});let y=t=>{let s=T.get(t);if(s)return[s];let u=t.toLowerCase();return g.filter(f=>f.name.toLowerCase()===u)};for(let[t,s]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=s;for(let[t,s]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=s;for(let t of n.groupBy??[])for(let s of y(t))s.isGrouping=!0;return{columns:g,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function b(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function B(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let m of Object.keys(l))r.has(m)||(r.add(m),n.push(m))}return n}function K(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return k.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,m=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let c=i.data;c.length===1&&c[0]===""&&m.replace(/[\r\n]/g,"")===""||n.push(c)}}),!n.length&&!r.length&&r.push(...k.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function ee(e,o={}){switch(e.kind){case"csv":{let n=K(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return p(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return p(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return p(e.columns,b(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:B(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return p(r,b(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=G(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return p(n,b(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{O as a,w as b,G as c,K as d,ee as e};
|