@bicharts/shape-core 0.6.34 → 0.6.36
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-5KAS4CFP.mjs +4 -0
- package/dist/index.mjs +1 -1
- package/dist/testing.mjs +5 -4
- package/dist/types/fetchTransport.d.ts +19 -0
- package/dist/types/index.d.ts +10 -3
- package/dist/types/messageCodes.d.ts +28 -0
- package/dist/types/models.d.ts +13 -0
- package/dist/types/telemetry.d.ts +7 -0
- package/dist/types/telemetryClient.d.ts +58 -0
- package/dist/types/testing/index.d.ts +15 -1
- package/dist/types/wireParse.d.ts +29 -0
- package/dist/types/wireStream.d.ts +8 -3
- package/package.json +1 -1
- package/dist/chunk-JF3BJI7F.mjs +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
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{u as c}from"./chunk-NFSQ4O5R.mjs";import{gzip as h}from"pako";var w=e=>h(e);function P(e){return S(w(JSON.stringify(e))).replace(/\//g,".")}function S(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function T(e){if(typeof e!="string"||e==="")throw new TypeError("keyedSigner needs the host's signing key");return{sign:t=>String(c(t+e))}}function W(e,t){let r=t.sign(e);if(typeof r!="string"||r.trim()==="")throw new TypeError("the host's signer returned a blank signature");return r}function u(e,t){if(e==null||typeof e!="object")return;let r=e,n=r[t];return n??r[t.charAt(0).toUpperCase()+t.slice(1)]}function x(e){return String(e??"").toLowerCase().includes("ndjson")}function C(e){let t=null;try{t=e.headers?.get?.("content-type")??null}catch{t=null}return{status:typeof e.status=="number"?e.status:0,contentType:t,body:e.body??null,text:()=>e.text()}}function m(e,t,r){let n=e.trim();if(!n)return{result:null,typed:!1,parsed:!1};let i;try{i=JSON.parse(n)}catch{return{result:null,typed:!1,parsed:!1}}return f(i,t,r)}function f(e,t,r){if(!e||typeof e!="object"||Array.isArray(e))return{result:null,typed:!1,parsed:!0};let n=u(e,"type");if(n!=null){if(n==="progress"){let s=String(u(e,"stage")??"").trim(),o=String(u(e,"stageId")??"").trim();return s&&t?.(s,o||void 0),{result:null,typed:!0,parsed:!0}}if(n==="result"){let s=u(e,"result");return{result:s&&typeof s=="object"?s:null,typed:!0,parsed:!0}}return{result:null,typed:!0,parsed:!0}}return r?{result:u(e,"code")!==void 0||u(e,"errorMessage")!==void 0?e:null,typed:!1,parsed:!0}:{result:e,typed:!1,parsed:!0}}var a=class{constructor(t){this.onStage=t}onStage;result=null;anyParsed=!1;take(t){let r=m(t,this.onStage,!0);r.parsed&&(this.anyParsed=!0),r.result&&(r.typed||this.result===null)&&(this.result=r.result)}};function d(){return new Error("the generate response ended without a result")}async function R(e,t){let r=e.body;if(!r||typeof r.getReader!="function")return p(await e.text(),t,null);let n=r.getReader(),i=new TextDecoder,s=new a(t),o="";try{for(;;){let{done:y,value:g}=await n.read();if(y)break;o+=i.decode(g,{stream:!0});let l;for(;(l=o.indexOf(`
|
|
3
|
+
`))>=0;)s.take(o.slice(0,l)),o=o.slice(l+1)}}finally{try{n.releaseLock?.()}catch{}}if(o+=i.decode(),s.take(o),!s.result)throw d();return s.result}function p(e,t,r){let n=new a(t);for(let i of e.split(`
|
|
4
|
+
`))n.take(i);if(n.result)return n.result;throw!n.anyParsed&&r?r:d()}async function k(e,t){let r=await e.text(),n;try{n=JSON.parse(r)}catch(s){return p(r,t,s)}if(!n||typeof n!="object"||Array.isArray(n))throw new SyntaxError("the generate response was JSON but not a result object");let i=f(n,t,!1);if(i.result)return i.result;throw d()}async function v(e,t){return x(e.contentType)?R(e,t):k(e,t)}export{w as a,P as b,T as c,W as d,u as e,x as f,C as g,v as h};
|
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 rt,b as ot}from"./chunk-UQU75XXR.mjs";import{a as it,b as at,c as st,d as lt,e as f,f as ut,g as ct,h as dt}from"./chunk-JF3BJI7F.mjs";import{a as Zn,b as Jn,c as et,d as nt,e as tt}from"./chunk-FNEHWEWX.mjs";import{A as Dn,B as Gn,C as qn,D as zn,E as Kn,F as Un,G as Bn,H as jn,I as Wn,J as $n,K as Hn,L as Qn,M as Yn,O as Xn,a as un,b as cn,c as dn,d as mn,e as yn,f as hn,g as Cn,h as bn,i as Rn,j as Sn,k as vn,l as xn,m as En,n as Ln,o as Pn,p as Nn,q as An,r as Tn,s as _n,t as In,u as Mn,v as Fn,w as wn,x as kn,y as Vn,z as On}from"./chunk-KKSQBV76.mjs";import{a as fn}from"./chunk-QEH7WTLB.mjs";import{a as pn,b as gn}from"./chunk-2LR73DNS.mjs";import{a as Z,b as J,c as on,d as an,e as sn,f as ln}from"./chunk-6TVBXT4G.mjs";import{a as _,f as I,g as S,h as M,i as q,j as He,k as Qe,l as X,m as h,n as Ye,o as Xe,p as Ze,q as F,r as Je,s as en,t as nn,u as tn,v as z,w as rn}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as je,b as We,c as $e}from"./chunk-6Q3MQ2MK.mjs";import{A as ze,B as Ke,C as Ue,D as Be,a as Ce,b as be,c as Re,d as Se,e as ve,f as D,g as xe,h as Ee,i as Le,j as Pe,k as Ne,l as Ae,m as Te,n as _e,o as Ie,p as Me,q as Fe,r as we,s as ke,u as G,v as Ve,w as Oe,x as De,y as Ge,z as qe}from"./chunk-NFSQ4O5R.mjs";var K=2,te=400;function B(e){return!!I(e)}function P(e){let n=new Set;for(let r of e){if(r==null)continue;let o=_(String(r));if(!M(o)&&!n.has(o)&&(n.add(o),n.size>=te))break}return Array.from(n)}function L(e){let n=P(e);if(n.length===0||j(e)<95)return!1;let r=n.filter(u=>B(u)&&!h(u)).length,o=n.filter(u=>!B(u)&&!!h(u)).length;return r>=1&&r>=o}function ee(e,n){if(!h(e))return!1;let r=I(e);return r?n==="world"?!0:X.has(r):!1}function j(e){let n=P(e);if(n.length===0)return 0;let r=0;for(let o of n)B(o)&&r++;return Math.round(r/n.length*1e3)/10}function w(e){let n=P(e);if(n.length===0)return 0;let r=0;for(let o of n)h(o)&&r++;return Math.round(r/n.length*1e3)/10}function $(e){let n=new Set;for(let r of e){if(r==null)continue;let o=String(r).trim();if(!M(_(o))&&!n.has(o)&&(n.add(o),n.size>=te))break}return Array.from(n)}function W(e){let n=$(e);if(n.length===0)return 0;let r=0;for(let o of n)F(o).length>0&&r++;return Math.round(r/n.length*1e3)/10}function ne(e,n){return J(n,Z)?!0:$(e).some(r=>/^\d{5}(-\d{4})?$/.test(r.replace(/\.0+$/,"")))}function mt(e,n){let r=P(e);if(r.length===0)return 0;let o=0;for(let u of r)z(u,n)&&o++;return Math.round(o/r.length*1e3)/10}function U(e,n){let r=0;for(let o of P(e))n(o)&&r++;return r}function ft(e,n){let r=0;for(let o of $(e))n(o)&&r++;return r}function pt(e,n,r,o,u){let l=[],s=[],a={},C={},x=new Set(e),p=i=>n.map(c=>c[i]);for(let i of["city","country"]){let c=r?.[i];c&&x.has(c)&&(a[i]=c)}let ge=new Set(u??e);for(let i of["lat","lon"]){let c=r?.[i];c&&ge.has(c)&&(a[i]=c)}let b=r?.zip;if(b&&x.has(b)){let i=p(b),c=W(i);c<95?s.push(`zip=${b} (only ${c}% of values read as ZIPs)`):ne(i,b)?a.zip=b:s.push(`zip=${b} (all values are 3-4 digits with nothing to say they are postal)`)}let y=r?.state;if(y&&x.has(y)){let i=p(y),c=P(i);c.length>0&&c.every(m=>ee(m,o))?s.push(`state=${y} (every value is "CA", which is both Canada and California)`):L(i)?(s.push(`state=${y} (every value is a country, not a state)`),a.country||(a.country=y)):w(i)<95?s.push(`state=${y} (only ${w(i)}% of values are states/provinces)`):a.state=y}let R=new Set(Object.values(a).filter(Boolean)),A=e.filter(i=>!R.has(i)&&!i.startsWith("__"));if(!a.state){let i=null;for(let c of A){let m=p(c);if(L(m))continue;let g=w(m);if(g<95)continue;let O=U(m,T=>!!h(T)),he=U(m,T=>!!h(T)&&!ee(T,o));O<K&&he<1||(!i||g>i.pct)&&(i={name:c,pct:g})}i&&(a.state=i.name,R.add(i.name),l.push(`state=${i.name} (${i.pct}% states/provinces)`))}if(!a.zip)for(let i of A){if(R.has(i))continue;let c=p(i),m=W(c);if(!(m<95)&&ne(c,i)&&!(ft(c,g=>F(g).length>0)<K)){a.zip=i,R.add(i),l.push(`zip=${i} (${m}% ZIP codes)`);break}}let E=a.country;if(!E||!L(p(E))){let i=null;for(let c of A){if(R.has(c)||!L(p(c)))continue;let m=j(p(c));(!i||m>i.pct)&&(i={name:c,pct:m})}i&&(E&&(s.push(`country=${E} (only ${j(p(E))}% of values are country identifiers; using ${i.name} instead)`),C.country=E),a.country=i.name,R.add(i.name),l.push(`country=${i.name}`))}if(!a.city){let i=null;for(let c of A){if(R.has(c))continue;let m=p(c),g=mt(m,o);g<q||U(m,O=>z(O,o))<K||(!i||g>i.pct)&&(i={name:c,pct:g})}i&&(a.city=i.name,l.push(`city=${i.name} (${i.pct}% known cities)`))}let Q=a.country?p(a.country):[],k=!!a.country&&L(Q),ye=k?new Set(Q.map(i=>I(i==null?null:String(i))).filter(Boolean)).size:0,Y=k&&ye>=2,V=!!(a.lat&&a.lon)&&n.some(i=>{let c=+String(i[a.lat]??"").trim(),m=+String(i[a.lon]??"").trim();return isFinite(c)&&isFinite(m)&&c>=-90&&c<=90&&m>=-180&&m<=180&&String(i[a.lat]??"").trim()!==""&&String(i[a.lon]??"").trim()!==""});return a.lat&&a.lon&&!V&&s.push(`lat/lon=${a.lat}/${a.lon} (no row holds a usable coordinate pair)`),a.country&&!Y&&!(a.city||a.state||a.zip||V)&&s.push(k?`country=${a.country} (every row resolves to the same country - nothing to place apart)`:`country=${a.country} (values are not country identifiers)`),{bind:!!(a.city||a.state||a.zip||Y||V)?a:null,backfilled:l,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}var t=(e,...n)=>({part:e,langs:Object.freeze(n)}),H=Object.freeze({jaar:t("year","nl"),kwartaal:t("quarter","nl"),maand:t("month","nl"),dag:t("day","nl","sv","da","nb"),jahr:t("year","de"),quartal:t("quarter","de"),monat:t("month","de"),tag:t("day","de"),ann\u00E9e:t("year","fr"),mois:t("month","fr"),jour:t("day","fr"),trimestre:t("quarter","fr","es","pt","it"),a\u00F1o:t("year","es"),mes:t("month","es"),d\u00EDa:t("day","es"),ano:t("year","pt"),m\u00EAs:t("month","pt"),dia:t("day","pt"),anno:t("year","it"),mese:t("month","it"),giorno:t("day","it"),\u0433\u043E\u0434:t("year","ru"),\u043C\u0435\u0441\u044F\u0446:t("month","ru"),\u0440\u0456\u043A:t("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:t("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:t("quarter","ru","uk"),\u0434\u0435\u043D\u044C:t("day","ru","uk"),rok:t("year","pl","cs","sk"),kwarta\u0142:t("quarter","pl"),miesi\u0105c:t("month","pl"),dzie\u0144:t("day","pl"),\u010Dtvrtlet\u00ED:t("quarter","cs"),m\u011Bs\u00EDc:t("month","cs"),den:t("day","cs"),\u0161tvr\u0165rok:t("quarter","sk"),mesiac:t("month","sk"),de\u0148:t("day","sk"),\u00E5r:t("year","sv","da","nb"),kvartal:t("quarter","sv","da","nb"),m\u00E5nad:t("month","sv"),m\u00E5ned:t("month","da","nb"),vuosi:t("year","fi"),vuosinelj\u00E4nnes:t("quarter","fi"),kuukausi:t("month","fi"),p\u00E4iv\u00E4:t("day","fi"),\u00E9v:t("year","hu"),negyed\u00E9v:t("quarter","hu"),h\u00F3nap:t("month","hu"),nap:t("day","hu"),y\u0131l:t("year","tr"),\u00E7eyrek:t("quarter","tr"),ay:t("month","tr"),g\u00FCn:t("day","tr"),\u03AD\u03C4\u03BF\u03C2:t("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:t("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:t("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:t("day","el"),an:t("year","ro"),trimestru:t("quarter","ro"),lun\u0103:t("month","ro"),zi:t("day","ro"),godina:t("year","hr"),tromjese\u010Dje:t("quarter","hr"),mjesec:t("month","hr"),dan:t("day","hr"),\u5E74:t("year","ja","zh"),\u56DB\u534A\u671F:t("quarter","ja"),\u5B63\u5EA6:t("quarter","zh"),\u6708:t("month","ja","zh"),\u65E5:t("day","ja","zh"),\uC5F0\uB3C4:t("year","ko"),\uBD84\uAE30:t("quarter","ko"),\uC6D4:t("month","ko"),\uC77C:t("day","ko"),tahun:t("year","id"),kuartal:t("quarter","id"),triwulan:t("quarter","id"),bulan:t("month","id"),hari:t("day","id"),n\u0103m:t("year","vi"),qu\u00FD:t("quarter","vi"),th\u00E1ng:t("month","vi"),ng\u00E0y:t("day","vi"),\u0E1B\u0E35:t("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:t("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:t("month","th"),\u0E27\u0E31\u0E19:t("day","th"),\u0627\u0644\u0633\u0646\u0629:t("year","ar"),\u0633\u0646\u0629:t("year","ar"),\u0627\u0644\u0639\u0627\u0645:t("year","ar"),\u0639\u0627\u0645:t("year","ar"),\u0627\u0644\u0631\u0628\u0639:t("quarter","ar"),\u0631\u0628\u0639:t("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":t("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:t("month","ar"),\u0634\u0647\u0631:t("month","ar"),\u0627\u0644\u064A\u0648\u0645:t("day","ar"),\u064A\u0648\u0645:t("day","ar"),\u05E9\u05E0\u05D4:t("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:t("quarter","he"),\u05D7\u05D5\u05D3\u05E9:t("month","he"),\u05D9\u05D5\u05DD:t("day","he"),\u0935\u0930\u094D\u0937:t("year","hi"),\u0938\u093E\u0932:t("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:t("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:t("month","hi"),\u092E\u093E\u0939:t("month","hi"),\u0926\u093F\u0928:t("day","hi"),\u0633\u0627\u0644:t("year","fa"),\u0645\u0627\u0647:t("month","fa"),\u0631\u0648\u0632:t("day","fa")}),gt=Object.freeze(Array.from(new Set(Object.values(H).flatMap(e=>e.langs)))),re=Object.freeze(["fa","ar","he","th"]),oe=1900,ie=2100;function yt(e,n){let r=[],o=D(n);try{o&&r.push(e.toLocaleLowerCase(o.intl))}catch{}let u=e.toLowerCase();return r.includes(u)||r.push(u),r}function ht(e,n){let r=String(e??"").trim().normalize("NFC");if(!r)return null;for(let o of yt(r,n)){let u=H[o];if(u&&u.langs.includes(n))return u.part}return null}function Ct(e,n){return re.includes(e)?typeof n=="number"&&Number.isFinite(n)&&n>=oe&&n<=ie:!0}function ae(e,n){let r=n?.freemiumMaxShapeColumns;return typeof r!="number"||!isFinite(r)||r<1?null:!isFinite(e)||e<=r?0:Math.round(e-r)}function bt(e,n,r){let o=ae(e,n);if(o===null||o<=0)return null;let u=typeof n?.freemiumColumnCapPivot=="number"?n.freemiumColumnCapPivot:4,l=o>u?n?.freemiumColumnCapMessageMany:n?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let s=l.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),a=se(r);return a.length===0?s:s+" "+a.join(" ")}function se(e){if(!e||e.length===0)return[];let n=[],r=new Map,o=new Map;for(let l of e){let s=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(s!==""&&(r.has(s)||(n.push(s),r.set(s,0)),l.isDatePart===!0&&r.set(s,r.get(s)+1),l.isReassembledDate===!0&&!o.has(s))){let a=typeof l.sourceField=="string"?l.sourceField.trim():"",C=typeof l.name=="string"?l.name.trim():"",x=a!==""?a:C;x!==""&&o.set(s,x)}}let u=[];for(let l of n){let s=o.get(l),a=r.get(l)??0;!s||a===0||u.push(`'${s}' is a date hierarchy and counts as ${a+1} fields - bind the date itself instead of its hierarchy.`)}return u}var d=e=>e==null?"":String(e),v=e=>e===!0,le=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},Rt=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function ue(e,n){let r={};for(let[o,u]of Rt){let l=d(f(e,n+u));l&&(r[o]=l)}return r}function St(e){let n=a=>f(e,a),r=n("retryAfterSeconds"),o=n("overrideThumbnailUpload"),u=n("forceThumbnailUpload"),l=ue(e,"point"),s=ue(e,"destPoint");return Object.keys(s).length&&(l.dest=s),{errorMessage:d(n("errorMessage")),code:d(n("code")),language:d(n("language")),version:Number(n("version")??0),codeSummary:d(n("codeSummary")),chartName:d(n("chartName")??n("chartType")),finalChartName:d(n("finalChartName")),warningMessage:d(n("warningMessage")),outputHash:d(n("outputHash")),validatorToken:d(n("validatorToken")),editCodeKey:d(n("editCodeKey")),signedLLMRequestID:d(n("signedLLMRequestID")),userReply:d(n("userReply")),userReplyOutcome:d(n("userReplyOutcome")),improvementSuggestion:d(n("improvementSuggestion")),geoColumn:d(n("geoColumn")),geoKind:d(n("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:le(n("creditBalanceBefore")),creditCost:le(n("creditCost")),isServiceError:v(n("isServiceError")),isRateLimited:v(n("isRateLimited")),isRefusal:v(n("isRefusal")),isVersionNotFound:v(n("isVersionNotFound")),isGenerationCancelled:v(n("isGenerationCancelled")),retryAfterSeconds:typeof r=="number"&&Number.isFinite(r)?r:null,servedCorrelationId:d(n("servedCorrelationId")),...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof u=="boolean"?{forceThumbnailUpload:u}:{}}}var ce=e=>e==null?void 0:Number(e),N=e=>d(e)||void 0;function vt(e){let n=f(e,"charts"),r=f(e,"refused"),o=Array.isArray(n)?n.map(l=>{let s=C=>f(l,C),a=s("recommended");return{name:d(s("chartTypeName")??s("name")),description:d(s("description")??s("chartDesc")),rank:ce(s("rank")),score:ce(s("score")),renderer:N(s("renderer")),language:N(s("language")),isPreview:v(s("isPreview")),recommended:typeof a=="boolean"?a:void 0,viaProjection:N(s("viaProjection")),viaProjectionKey:N(s("viaProjectionKey")),detailNote:N(s("detailNote"))}}).filter(l=>l.name):null,u=Array.isArray(r)?r.map(l=>({name:d(f(l,"chartTypeName")??f(l,"name")),reason:d(f(l,"reason")),isVeto:v(f(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:d(f(e,"errorMessage")),charts:o,refused:u,noFitSummary:d(f(e,"noFitSummary"))}}function xt(e){return!e||typeof e!="object"?null:{status:String(f(e,"status")??""),verdictReason:f(e,"verdictReason")??null,instruction:f(e,"instruction")??null,fix:f(e,"fix")??null,errorMessage:f(e,"errorMessage")??null}}function Et(e){let n=e.linkNonce?(e.linkNonce()??"").trim():null,r=n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:r.licenseKey,licensee:r.licensee,secretKey:r.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:n}}function Lt(e){let{width:n,height:r}=e.measure();return{request:{height:r,width:n},hints:{viewportWidth:n,viewportHeight:r}}}function Pt(e){let n=0;for(let r of e){if(r.isMeasure)continue;let o=r.distinctCount;typeof o=="number"&&o>n&&(n=o)}return n}function de(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 r=(n??0)>0?n:null,o=(e.codeVersion??0)>0?e.codeVersion:null,u=r??o??n;return{version:u,fetchOnly:u!=null&&u>0?!0:void 0}}function Nt(e){let n=e.fetchCorrelationId!=null,o=n||e.recoveryFetchVersion!=null?!1:e.genNew,u=de({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 At(e){let n=r=>e.renderers.has(r);return{supportsD3:n("D3"),supportsPlotly:n("PLOTLY"),supportsVega:n("VEGA")}}function Tt(e){let n=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??n,maxTries:n}}function _t(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function me(e,n){return e!=null&&n!=null&&e!==n}function It(e,n){return e?me(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 Mt=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function fe(e){let n=String(e??"").trim().toLowerCase();return Mt[n]??n}function pe(e){let n="";for(let r of e)n+=JSON.stringify([String(r.name??""),r.isMeasure?"M":"D",fe(r.dataType)]);return n}function Ft(e){return G(pe(e))}var wt=2,kt=3,Vt=4,Ot=64,Dt=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict"});function Gt(e){return!!e&&!e.includes("|")&&!e.includes(",")}function qt(e,n,r,o){let u=`${e},${n}|${r}`;return o?`${u}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:u}export{q as CITY_ROLE_MATCH_PCT,Dt as CLIENT_EVENT_KINDS,Te as COMPOUND_MIN_STEM,ie as DATE_LEVEL_GREGORIAN_YEAR_MAX,oe as DATE_LEVEL_GREGORIAN_YEAR_MIN,gt as DATE_LEVEL_LANGUAGES,H as DATE_LEVEL_NAMES,re as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,kn as DEFAULT_GAP_FACTOR,De as DEFAULT_TEMPERATURE,Ve as GET_RANDOM,Ie as GLUED_STEM_MIN,hn as INTENSIVE_SUFFIX_TOKENS,yn as INTENSIVE_WORD_TOKENS,Xn as IndexedText,Vn as MAX_RUN_BOUNDS,bn as POSITIONAL_SUFFIX_TOKENS,Cn as POSITIONAL_WORD_TOKENS,rt as PREVIEW_OMITTED_FIELDS,S as ROLE_MATCH_PCT,Gn as SERIES_COMPLETENESS_MAX_LISTED,qn as SERIES_COMPLETENESS_MIN_FILL,zn as SERIES_KEY_MAX_DISTINCT,Vt as SEV_ERROR,wt as SEV_INFO,Ot as SEV_USER_PRESENTED,kt as SEV_WARNING,G as SIMPLE_STRING_HASH,ke as STR,Fe as SUBSTRING_MIN,Ce as SUPPORTED_LANGUAGES,be as SUPPORTED_LANGUAGE_CODES,ve as VOCABULARY_LANGUAGE_CODES,Se as VOCABULARY_ONLY_LANGUAGES,w as admin1MatchPct,An as allowedAggregations,ln as buildGeoIsoColumn,nn as buildGeoPointColumns,At as capabilityFields,rn as cityMatchPct,tn as cityTagsFor,Qn as classifyAdditivity,Nn as classifyForAggregation,Yn as classifyNumericValueNature,$n as classifyTemporal,xn as codeNeedsLegacyAggNames,Mn as codeReadsColumn,Fn as codeReadsColumnsByRoleOrPosition,vn as collapseRepeatedAggPrefix,wn as columnsTheCodeReads,dn as countryRegion,Et as credentialFields,ht as dateLevelPart,Ct as dateLevelYearAdmits,Zn as decimalSeparatorOf,Tn as defaultAggregation,Jn as detectDecimalSeparator,fn as detectFormatSignature,on as detectGeo,$e as detectOrdinalDomain,Wn as detectTextDatePattern,at as encodePayload,nt as engineTypeForSqlType,En as englishImplicitAggNames,qt as eventLogLine,Nt as fetchFields,Ee as foldName,bt as freemiumColumnCapRefusal,ae as freemiumColumnsOverCap,se as freemiumDateHierarchyClauses,Me as gluedPrefixStems,it as gzipWireText,Sn as hasDefaultAggPrefix,Ne as hasUnsegmentedScript,Hn as hostAggHint,tt as ingest,_n as isAggregationAllowed,M as isBlankLike,Qe as isCityTableLoaded,Oe as isDeterministicRefusal,Gt as isEventLogCode,Je as isGeoPointAmbiguity,jn as isIdentifierName,sn as isJoinGeoKind,ut as isNdjsonContentType,je as isOrdinalFriendlyName,st as keyedSigner,_t as leafCardinalityField,Ue as localMidnightDateColumns,Ke as localMidnightToUtcDay,L as looksLikeCountryColumn,we as matchNameToken,Pt as maxNonMeasureCardinality,Dn as measureCadence,Bn as measureSeriesCompleteness,lt as messageSignature,gn as monthLookupFor,Pn as nameLooksIntensiveRate,Ln as nameLooksPositional,Le as nameWords,Ye as normalizeCountry,Be as normalizeLocalMidnightDates,pn as normalizeMonthKey,_ as normalizePlaceName,Ze as normalizeZip5,It as offeredShortlistFor,Ge as parseDateStable,St as parseGenerateResponse,et as parseNumberText,vt as parseQualifyResponse,xt as parseReviewVerdict,On as parseTemporalPoint,ot as payloadPreview,Un as pickSeriesColumn,dt as readGenerateStream,Pe as readName,f as readWireField,He as registerCityTable,cn as registerIso3Regions,h as resolveAdmin1,de as resolveFetchVersion,en as resolveGeoPoint,xe as resolveLanguage,pt as resolvePointRoles,Tt as retryFields,We as safeDistinctValuesToShip,pe as schemaIdentity,Ft as schemaIdentityKey,fe as schemaTypeFamily,Kn as seriesKeyVerdict,In as shareOfTotalIsHonest,me as shortlistIsStale,Rn as stripHostAggPrefix,mn as summarizeCountryRegions,un as summarizeGeoExtent,Re as supportedLanguage,an as toGeoIso,Ae as unsegmentedRuns,Lt as viewportFields,D as vocabularyLanguage,qe as wholeDayFrame,ze as wholeDayIso,ct as wireResponseFromFetch,_e as wordEndsWith,W as zipMatchPct,F as zipPrefixCandidates,Xe as zipToPrefix3};
|
|
2
|
+
import{a as un,b as cn}from"./chunk-UQU75XXR.mjs";import{a as dn,b as j,c as mn,d as B,e as m,f as fn,g as H,h as pn}from"./chunk-5KAS4CFP.mjs";import{a as rn,b as on,c as sn,d as an,e as ln}from"./chunk-FNEHWEWX.mjs";import{A as Kt,B as Wt,C as $t,D as jt,E as Bt,F as Ht,G as Yt,H as Qt,I as Xt,J as Zt,K as Jt,L as en,M as tn,O as nn,a as pt,b as gt,c as yt,d as ht,e as Tt,f as St,g as Rt,h as xt,i as vt,j as Pt,k as Lt,l as Mt,m as _t,n as wt,o as Nt,p as At,q as It,r as Ft,s as Ot,t as kt,u as Vt,v as Dt,w as Gt,x as Ut,y as zt,z as qt}from"./chunk-KKSQBV76.mjs";import{a as Ct}from"./chunk-QEH7WTLB.mjs";import{a as bt,b as Et}from"./chunk-2LR73DNS.mjs";import{a as oe,b as ie,c as ct,d as dt,e as mt,f as ft}from"./chunk-6TVBXT4G.mjs";import{a as k,f as V,g as M,h as D,i as W,j as et,k as tt,l as re,m as L,n as nt,o as rt,p as ot,q as G,r as it,s as st,t as at,u as lt,v as $,w as ut}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as Xe,b as Ze,c as Je}from"./chunk-6Q3MQ2MK.mjs";import{A as Be,B as He,C as Ye,D as Qe,a as xe,b as ve,c as Pe,d as Le,e as Me,f as q,g as _e,h as we,i as Ne,j as Ae,k as Ie,l as Fe,m as Oe,n as ke,o as Ve,p as De,q as Ge,r as Ue,s as ze,u as K,v as qe,w as Ke,x as We,y as $e,z as je}from"./chunk-NFSQ4O5R.mjs";var Y=2,le=400;function X(t){return!!V(t)}function A(t){let e=new Set;for(let r of t){if(r==null)continue;let o=k(String(r));if(!D(o)&&!e.has(o)&&(e.add(o),e.size>=le))break}return Array.from(e)}function N(t){let e=A(t);if(e.length===0||Z(t)<95)return!1;let r=e.filter(u=>X(u)&&!L(u)).length,o=e.filter(u=>!X(u)&&!!L(u)).length;return r>=1&&r>=o}function se(t,e){if(!L(t))return!1;let r=V(t);return r?e==="world"?!0:re.has(r):!1}function Z(t){let e=A(t);if(e.length===0)return 0;let r=0;for(let o of e)X(o)&&r++;return Math.round(r/e.length*1e3)/10}function U(t){let e=A(t);if(e.length===0)return 0;let r=0;for(let o of e)L(o)&&r++;return Math.round(r/e.length*1e3)/10}function ee(t){let e=new Set;for(let r of t){if(r==null)continue;let o=String(r).trim();if(!D(k(o))&&!e.has(o)&&(e.add(o),e.size>=le))break}return Array.from(e)}function J(t){let e=ee(t);if(e.length===0)return 0;let r=0;for(let o of e)G(o).length>0&&r++;return Math.round(r/e.length*1e3)/10}function ae(t,e){return ie(e,oe)?!0:ee(t).some(r=>/^\d{5}(-\d{4})?$/.test(r.replace(/\.0+$/,"")))}function gn(t,e){let r=A(t);if(r.length===0)return 0;let o=0;for(let u of r)$(u,e)&&o++;return Math.round(o/r.length*1e3)/10}function Q(t,e){let r=0;for(let o of A(t))e(o)&&r++;return r}function yn(t,e){let r=0;for(let o of ee(t))e(o)&&r++;return r}function hn(t,e,r,o,u){let l=[],a=[],i={},C={},T=new Set(t),b=s=>e.map(c=>c[s]);for(let s of["city","country"]){let c=r?.[s];c&&T.has(c)&&(i[s]=c)}let R=new Set(u??t);for(let s of["lat","lon"]){let c=r?.[s];c&&R.has(c)&&(i[s]=c)}let y=r?.zip;if(y&&T.has(y)){let s=b(y),c=J(s);c<95?a.push(`zip=${y} (only ${c}% of values read as ZIPs)`):ae(s,y)?i.zip=y:a.push(`zip=${y} (all values are 3-4 digits with nothing to say they are postal)`)}let p=r?.state;if(p&&T.has(p)){let s=b(p),c=A(s);c.length>0&&c.every(g=>se(g,o))?a.push(`state=${p} (every value is "CA", which is both Canada and California)`):N(s)?(a.push(`state=${p} (every value is a country, not a state)`),i.country||(i.country=p)):U(s)<95?a.push(`state=${p} (only ${U(s)}% of values are states/provinces)`):i.state=p}let f=new Set(Object.values(i).filter(Boolean)),h=t.filter(s=>!f.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let c of h){let g=b(c);if(N(g))continue;let v=U(g);if(v<95)continue;let z=Q(g,O=>!!L(O)),Re=Q(g,O=>!!L(O)&&!se(O,o));z<Y&&Re<1||(!s||v>s.pct)&&(s={name:c,pct:v})}s&&(i.state=s.name,f.add(s.name),l.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of h){if(f.has(s))continue;let c=b(s),g=J(c);if(!(g<95)&&ae(c,s)&&!(yn(c,v=>G(v).length>0)<Y)){i.zip=s,f.add(s),l.push(`zip=${s} (${g}% ZIP codes)`);break}}let E=i.country;if(!E||!N(b(E))){let s=null;for(let c of h){if(f.has(c)||!N(b(c)))continue;let g=Z(b(c));(!s||g>s.pct)&&(s={name:c,pct:g})}s&&(E&&(a.push(`country=${E} (only ${Z(b(E))}% of values are country identifiers; using ${s.name} instead)`),C.country=E),i.country=s.name,f.add(s.name),l.push(`country=${s.name}`))}if(!i.city){let s=null;for(let c of h){if(f.has(c))continue;let g=b(c),v=gn(g,o);v<W||Q(g,z=>$(z,o))<Y||(!s||v>s.pct)&&(s={name:c,pct:v})}s&&(i.city=s.name,l.push(`city=${s.name} (${s.pct}% known cities)`))}let x=i.country?b(i.country):[],w=!!i.country&&N(x),F=w?new Set(x.map(s=>V(s==null?null:String(s))).filter(Boolean)).size:0,S=w&&F>=2,P=!!(i.lat&&i.lon)&&e.some(s=>{let c=+String(s[i.lat]??"").trim(),g=+String(s[i.lon]??"").trim();return isFinite(c)&&isFinite(g)&&c>=-90&&c<=90&&g>=-180&&g<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!P&&a.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!S&&!(i.city||i.state||i.zip||P)&&a.push(w?`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||S||P)?i:null,backfilled:l,refused:a,...Object.keys(C).length?{labelFallback:C}:{}}}var n=(t,...e)=>({part:t,langs:Object.freeze(e)}),te=Object.freeze({jaar:n("year","nl"),kwartaal:n("quarter","nl"),maand:n("month","nl"),dag:n("day","nl","sv","da","nb"),jahr:n("year","de"),quartal:n("quarter","de"),monat:n("month","de"),tag:n("day","de"),ann\u00E9e:n("year","fr"),mois:n("month","fr"),jour:n("day","fr"),trimestre:n("quarter","fr","es","pt","it"),a\u00F1o:n("year","es"),mes:n("month","es"),d\u00EDa:n("day","es"),ano:n("year","pt"),m\u00EAs:n("month","pt"),dia:n("day","pt"),anno:n("year","it"),mese:n("month","it"),giorno:n("day","it"),\u0433\u043E\u0434:n("year","ru"),\u043C\u0435\u0441\u044F\u0446:n("month","ru"),\u0440\u0456\u043A:n("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:n("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:n("quarter","ru","uk"),\u0434\u0435\u043D\u044C:n("day","ru","uk"),rok:n("year","pl","cs","sk"),kwarta\u0142:n("quarter","pl"),miesi\u0105c:n("month","pl"),dzie\u0144:n("day","pl"),\u010Dtvrtlet\u00ED:n("quarter","cs"),m\u011Bs\u00EDc:n("month","cs"),den:n("day","cs"),\u0161tvr\u0165rok:n("quarter","sk"),mesiac:n("month","sk"),de\u0148:n("day","sk"),\u00E5r:n("year","sv","da","nb"),kvartal:n("quarter","sv","da","nb"),m\u00E5nad:n("month","sv"),m\u00E5ned:n("month","da","nb"),vuosi:n("year","fi"),vuosinelj\u00E4nnes:n("quarter","fi"),kuukausi:n("month","fi"),p\u00E4iv\u00E4:n("day","fi"),\u00E9v:n("year","hu"),negyed\u00E9v:n("quarter","hu"),h\u00F3nap:n("month","hu"),nap:n("day","hu"),y\u0131l:n("year","tr"),\u00E7eyrek:n("quarter","tr"),ay:n("month","tr"),g\u00FCn:n("day","tr"),\u03AD\u03C4\u03BF\u03C2:n("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:n("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:n("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:n("day","el"),an:n("year","ro"),trimestru:n("quarter","ro"),lun\u0103:n("month","ro"),zi:n("day","ro"),godina:n("year","hr"),tromjese\u010Dje:n("quarter","hr"),mjesec:n("month","hr"),dan:n("day","hr"),\u5E74:n("year","ja","zh"),\u56DB\u534A\u671F:n("quarter","ja"),\u5B63\u5EA6:n("quarter","zh"),\u6708:n("month","ja","zh"),\u65E5:n("day","ja","zh"),\uC5F0\uB3C4:n("year","ko"),\uBD84\uAE30:n("quarter","ko"),\uC6D4:n("month","ko"),\uC77C:n("day","ko"),tahun:n("year","id"),kuartal:n("quarter","id"),triwulan:n("quarter","id"),bulan:n("month","id"),hari:n("day","id"),n\u0103m:n("year","vi"),qu\u00FD:n("quarter","vi"),th\u00E1ng:n("month","vi"),ng\u00E0y:n("day","vi"),\u0E1B\u0E35:n("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:n("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:n("month","th"),\u0E27\u0E31\u0E19:n("day","th"),\u0627\u0644\u0633\u0646\u0629:n("year","ar"),\u0633\u0646\u0629:n("year","ar"),\u0627\u0644\u0639\u0627\u0645:n("year","ar"),\u0639\u0627\u0645:n("year","ar"),\u0627\u0644\u0631\u0628\u0639:n("quarter","ar"),\u0631\u0628\u0639:n("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":n("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:n("month","ar"),\u0634\u0647\u0631:n("month","ar"),\u0627\u0644\u064A\u0648\u0645:n("day","ar"),\u064A\u0648\u0645:n("day","ar"),\u05E9\u05E0\u05D4:n("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:n("quarter","he"),\u05D7\u05D5\u05D3\u05E9:n("month","he"),\u05D9\u05D5\u05DD:n("day","he"),\u0935\u0930\u094D\u0937:n("year","hi"),\u0938\u093E\u0932:n("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:n("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:n("month","hi"),\u092E\u093E\u0939:n("month","hi"),\u0926\u093F\u0928:n("day","hi"),\u0633\u0627\u0644:n("year","fa"),\u0645\u0627\u0647:n("month","fa"),\u0631\u0648\u0632:n("day","fa")}),Cn=Object.freeze(Array.from(new Set(Object.values(te).flatMap(t=>t.langs)))),ue=Object.freeze(["fa","ar","he","th"]),ce=1900,de=2100;function bn(t,e){let r=[],o=q(e);try{o&&r.push(t.toLocaleLowerCase(o.intl))}catch{}let u=t.toLowerCase();return r.includes(u)||r.push(u),r}function En(t,e){let r=String(t??"").trim().normalize("NFC");if(!r)return null;for(let o of bn(r,e)){let u=te[o];if(u&&u.langs.includes(e))return u.part}return null}function Tn(t,e){return ue.includes(t)?typeof e=="number"&&Number.isFinite(e)&&e>=ce&&e<=de:!0}function me(t,e){let r=e?.freemiumMaxShapeColumns;return typeof r!="number"||!isFinite(r)||r<1?null:!isFinite(t)||t<=r?0:Math.round(t-r)}function Sn(t,e,r){let o=me(t,e);if(o===null||o<=0)return null;let u=typeof e?.freemiumColumnCapPivot=="number"?e.freemiumColumnCapPivot:4,l=o>u?e?.freemiumColumnCapMessageMany:e?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let a=l.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=fe(r);return i.length===0?a:a+" "+i.join(" ")}function fe(t){if(!t||t.length===0)return[];let e=[],r=new Map,o=new Map;for(let l of t){let a=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(a!==""&&(r.has(a)||(e.push(a),r.set(a,0)),l.isDatePart===!0&&r.set(a,r.get(a)+1),l.isReassembledDate===!0&&!o.has(a))){let i=typeof l.sourceField=="string"?l.sourceField.trim():"",C=typeof l.name=="string"?l.name.trim():"",T=i!==""?i:C;T!==""&&o.set(a,T)}}let u=[];for(let l of e){let a=o.get(l),i=r.get(l)??0;!a||i===0||u.push(`'${a}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return u}var d=t=>t==null?"":String(t),_=t=>t===!0,pe=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"&&t.trim()!==""){let e=Number(t);return Number.isFinite(e)?e:null}return null},Rn=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function ge(t,e){let r={};for(let[o,u]of Rn){let l=d(m(t,e+u));l&&(r[o]=l)}return r}function xn(t){return Array.isArray(t)?t.map(e=>({code:d(m(e,"code")),severity:d(m(e,"severity")),text:d(m(e,"text"))})).filter(e=>e.text!==""):[]}function vn(t){let e=C=>m(t,C),r=e("retryAfterSeconds"),o=e("overrideThumbnailUpload"),u=e("forceThumbnailUpload"),l=ge(t,"point"),a=ge(t,"destPoint");Object.keys(a).length&&(l.dest=a);let i=e("retryable");return{errorMessage:d(e("errorMessage")),errorCode:d(e("errorCode")),refusalCode:d(e("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:xn(e("notices")),freemiumStatusCode:d(e("freemiumStatusCode")),code:d(e("code")),language:d(e("language")),version:Number(e("version")??0),codeSummary:d(e("codeSummary")),chartName:d(e("chartName")??e("chartType")),finalChartName:d(e("finalChartName")),warningMessage:d(e("warningMessage")),outputHash:d(e("outputHash")),validatorToken:d(e("validatorToken")),editCodeKey:d(e("editCodeKey")),signedLLMRequestID:d(e("signedLLMRequestID")),userReply:d(e("userReply")),userReplyOutcome:d(e("userReplyOutcome")),improvementSuggestion:d(e("improvementSuggestion")),geoColumn:d(e("geoColumn")),geoKind:d(e("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:pe(e("creditBalanceBefore")),creditCost:pe(e("creditCost")),isServiceError:_(e("isServiceError")),isRateLimited:_(e("isRateLimited")),isRefusal:_(e("isRefusal")),isVersionNotFound:_(e("isVersionNotFound")),isGenerationCancelled:_(e("isGenerationCancelled")),retryAfterSeconds:typeof r=="number"&&Number.isFinite(r)?r:null,servedCorrelationId:d(e("servedCorrelationId")),...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof u=="boolean"?{forceThumbnailUpload:u}:{}}}var ye=t=>t==null?void 0:Number(t),I=t=>d(t)||void 0;function Pn(t){let e=m(t,"charts"),r=m(t,"refused"),o=Array.isArray(e)?e.map(l=>{let a=C=>m(l,C),i=a("recommended");return{name:d(a("chartTypeName")??a("name")),description:d(a("description")??a("chartDesc")),rank:ye(a("rank")),score:ye(a("score")),renderer:I(a("renderer")),language:I(a("language")),isPreview:_(a("isPreview")),recommended:typeof i=="boolean"?i:void 0,viaProjection:I(a("viaProjection")),viaProjectionKey:I(a("viaProjectionKey")),detailNote:I(a("detailNote"))}}).filter(l=>l.name):null,u=Array.isArray(r)?r.map(l=>({name:d(m(l,"chartTypeName")??m(l,"name")),reason:d(m(l,"reason")),reasonCode:d(m(l,"reasonCode")),isVeto:_(m(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:d(m(t,"errorMessage")),errorCode:d(m(t,"errorCode")),charts:o,refused:u,noFitSummary:d(m(t,"noFitSummary"))}}function Ln(t){return!t||typeof t!="object"?null:{status:String(m(t,"status")??""),verdictReason:m(t,"verdictReason")??null,instruction:m(t,"instruction")??null,fix:m(t,"fix")??null,errorMessage:m(t,"errorMessage")??null,errorCode:m(t,"errorCode")??null}}var he=["working","analyze","generate","refine","review"];function Mn(t,e){let r=String(t??"").trim().toLowerCase();if(he.includes(r))return r;let o=String(e??"").toLowerCase();return o.includes("analyz")?"analyze":o.includes("generat")?"generate":o.includes("refin")?"refine":o.includes("review")?"review":null}var _n="FREEMIUM_ATTEMPT_SPENT",wn="CLIENT_SECRET_MISMATCH",Nn="FREEMIUM_COLUMN_CAP";function An(t){let e=t?.retryable;return typeof e=="boolean"?e:null}function In(t){let e=t.linkNonce?(t.linkNonce()??"").trim():null,r=e?{licensee:"",licenseKey:"",secretKey:""}:t.triple();return{request:{licenseKey:r.licenseKey,licensee:r.licensee,secretKey:r.secretKey,freemiumKey:t.freemiumKey?.()??""},linkNonce:e}}function Fn(t){let{width:e,height:r}=t.measure();return{request:{height:r,width:e},hints:{viewportWidth:e,viewportHeight:r}}}function On(t){let e=0;for(let r of t){if(r.isMeasure)continue;let o=r.distinctCount;typeof o=="number"&&o>e&&(e=o)}return e}function Ce(t){if(t.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(t.recoveryFetchVersion!=null)return{version:t.recoveryFetchVersion,fetchOnly:!0};let e=t.settingVersion??null;if(t.genNew)return{version:e,fetchOnly:void 0};let r=(e??0)>0?e:null,o=(t.codeVersion??0)>0?t.codeVersion:null,u=r??o??e;return{version:u,fetchOnly:u!=null&&u>0?!0:void 0}}function kn(t){let e=t.fetchCorrelationId!=null,o=e||t.recoveryFetchVersion!=null?!1:t.genNew,u=Ce({genNew:o,recoveryFetchVersion:t.recoveryFetchVersion,recoveryFetchByCorrelation:e,settingVersion:t.settingVersion,codeVersion:t.codeVersion});return{genNew:o,version:u.version,fetchOnly:u.fetchOnly,fetchCorrelationId:t.fetchCorrelationId??void 0}}function Vn(t){let e=r=>t.renderers.has(r);return{supportsD3:e("D3"),supportsPlotly:e("PLOTLY"),supportsVega:e("VEGA")}}function Dn(t){let e=t.cap!=null&&t.budget>t.cap?t.cap:t.budget;return{triesLeft:t.triesLeft??e,maxTries:e}}function Gn(t){return t&&t>0?{leafCardinality:Math.round(t)}:{}}function be(t,e){return t!=null&&e!=null&&t!==e}function Un(t,e){return t?be(e.capturedFor,e.now)?{shortlist:void 0,stale:!0}:{shortlist:{...t,ageMs:e.atMs>0?Math.max(0,Math.round(e.nowMs-e.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var zn=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Ee(t){let e=String(t??"").trim().toLowerCase();return zn[e]??e}function Te(t){let e="";for(let r of t)e+=JSON.stringify([String(r.name??""),r.isMeasure?"M":"D",Ee(r.dataType)]);return e}function qn(t){return K(Te(t))}var Kn=2,Wn=3,$n=4,jn=64,Bn=8e3,Hn=6e4,Yn=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict"});function Qn(t){return!!t&&!t.includes("|")&&!t.includes(",")}function ne(t,e,r,o){let u=`${t},${e}|${r}`;return o?`${u}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:u}function Xn(t,e){let r=t;if(!r||!r.signer||typeof r.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!r.transport||typeof r.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!r.clock||typeof r.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!e||typeof e.baseUrl!="string"&&typeof e.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof e.baseUrl=="string"&&e.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof e.clientVersion!="string"||e.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof e.timeoutMs!="number"||!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:o,transport:u,clock:l}=r,a=e.apiPath??"/api",i=e.timeoutMs,C=()=>typeof e.baseUrl=="function"?e.baseUrl():e.baseUrl,T=R=>{try{e.onFailure?.(R)}catch{}},b=async(R,y,p,f)=>{let h;try{let E=await u.post(y,p,f,{timeoutMs:i});h=E.status;try{E.body?.cancel().catch(()=>{})}catch{}}catch(E){T({channel:R,stage:"post",status:null,error:E});return}(h<200||h>299)&&T({channel:R,stage:"status",status:h,error:null})};return{async sendClientMessage(R){let y,p,f;try{y=`${C()}${a}/LogClientMsg/?nocache=${l.now()}`,p=j(R),f=B(p,o)}catch(h){T({channel:"client-message",stage:"build",status:null,error:h});return}await b("client-message",y,p,{"Content-Type":"text/plain","X-Signature":f})},async countEvent(R,y,p){let f,h;try{f=`${C()}${a}/eventlog`,h=ne(R,e.clientVersion,y,p)}catch(E){T({channel:"event-count",stage:"build",status:null,error:E});return}await b("event-count",f,h,{"Content-Type":"text/plain"})}}}function Se(t){return Object.assign(new Error(`The request did not finish within ${t} ms.`),{name:"TimeoutError"})}function Zn(t,e={}){if(typeof t!="function")throw new TypeError("fetchTransport needs the host's fetch");let r=t,o=e.credentials??"omit";return{async post(u,l,a,i){let C=i.timeoutMs,T=new AbortController,b=!1,R=setTimeout(()=>{b=!0,T.abort(Se(C))},C),y=()=>T.abort(i.signal?.reason);i.signal&&(i.signal.aborted?y():i.signal.addEventListener("abort",y,{once:!0}));let p=!1,f=()=>{p||(p=!0,clearTimeout(R),i.signal?.removeEventListener("abort",y))},h=S=>b?Se(C):S,E;try{E=await r(u,{method:"POST",body:l,headers:a,credentials:o,signal:T.signal})}catch(S){throw f(),h(S)}let x=H(E);if(!x.body)return{status:x.status,contentType:x.contentType,body:null,text:async()=>{try{return await x.text()}catch(S){throw h(S)}finally{f()}}};let w=x.body.getReader(),F=new ReadableStream({async pull(S){try{let P=await w.read();if(P.done){f(),S.close();return}S.enqueue(P.value)}catch(P){f(),S.error(h(P))}},cancel(S){return f(),w.cancel(S)}});return{status:x.status,contentType:x.contentType,body:F,text:()=>new Response(F).text()}}}}export{W as CITY_ROLE_MATCH_PCT,Yn as CLIENT_EVENT_KINDS,wn as CLIENT_SECRET_MISMATCH,Oe as COMPOUND_MIN_STEM,de as DATE_LEVEL_GREGORIAN_YEAR_MAX,ce as DATE_LEVEL_GREGORIAN_YEAR_MIN,Cn as DATE_LEVEL_LANGUAGES,te as DATE_LEVEL_NAMES,ue as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,Ut as DEFAULT_GAP_FACTOR,We as DEFAULT_TEMPERATURE,_n as FREEMIUM_ATTEMPT_SPENT,Nn as FREEMIUM_COLUMN_CAP,qe as GET_RANDOM,Ve as GLUED_STEM_MIN,St as INTENSIVE_SUFFIX_TOKENS,Tt as INTENSIVE_WORD_TOKENS,nn as IndexedText,zt as MAX_RUN_BOUNDS,xt as POSITIONAL_SUFFIX_TOKENS,Rt as POSITIONAL_WORD_TOKENS,un as PREVIEW_OMITTED_FIELDS,he as PROGRESS_STAGE_IDS,M as ROLE_MATCH_PCT,Wt as SERIES_COMPLETENESS_MAX_LISTED,$t as SERIES_COMPLETENESS_MIN_FILL,jt as SERIES_KEY_MAX_DISTINCT,$n as SEV_ERROR,Kn as SEV_INFO,jn as SEV_USER_PRESENTED,Wn as SEV_WARNING,K as SIMPLE_STRING_HASH,ze as STR,Ge as SUBSTRING_MIN,xe as SUPPORTED_LANGUAGES,ve as SUPPORTED_LANGUAGE_CODES,Hn as TELEMETRY_TIMEOUT_DEV_MS,Bn as TELEMETRY_TIMEOUT_MS,Me as VOCABULARY_LANGUAGE_CODES,Le as VOCABULARY_ONLY_LANGUAGES,U as admin1MatchPct,It as allowedAggregations,An as answerIsRetryable,ft as buildGeoIsoColumn,at as buildGeoPointColumns,Vn as capabilityFields,ut as cityMatchPct,lt as cityTagsFor,en as classifyAdditivity,At as classifyForAggregation,tn as classifyNumericValueNature,Zt as classifyTemporal,Mt as codeNeedsLegacyAggNames,Vt as codeReadsColumn,Dt as codeReadsColumnsByRoleOrPosition,Lt as collapseRepeatedAggPrefix,Gt as columnsTheCodeReads,yt as countryRegion,Xn as createTelemetryClient,In as credentialFields,En as dateLevelPart,Tn as dateLevelYearAdmits,rn as decimalSeparatorOf,Ft as defaultAggregation,on as detectDecimalSeparator,Ct as detectFormatSignature,ct as detectGeo,Je as detectOrdinalDomain,Xt as detectTextDatePattern,j as encodePayload,an as engineTypeForSqlType,_t as englishImplicitAggNames,ne as eventLogLine,kn as fetchFields,Zn as fetchTransport,we as foldName,Sn as freemiumColumnCapRefusal,me as freemiumColumnsOverCap,fe as freemiumDateHierarchyClauses,De as gluedPrefixStems,dn as gzipWireText,Pt as hasDefaultAggPrefix,Ie as hasUnsegmentedScript,Jt as hostAggHint,ln as ingest,Ot as isAggregationAllowed,D as isBlankLike,tt as isCityTableLoaded,Ke as isDeterministicRefusal,Qn as isEventLogCode,it as isGeoPointAmbiguity,Qt as isIdentifierName,mt as isJoinGeoKind,fn as isNdjsonContentType,Xe as isOrdinalFriendlyName,mn as keyedSigner,Gn as leafCardinalityField,Ye as localMidnightDateColumns,He as localMidnightToUtcDay,N as looksLikeCountryColumn,Ue as matchNameToken,On as maxNonMeasureCardinality,Kt as measureCadence,Yt as measureSeriesCompleteness,B as messageSignature,Et as monthLookupFor,Nt as nameLooksIntensiveRate,wt as nameLooksPositional,Ne as nameWords,nt as normalizeCountry,Qe as normalizeLocalMidnightDates,bt as normalizeMonthKey,k as normalizePlaceName,ot as normalizeZip5,Un as offeredShortlistFor,$e as parseDateStable,vn as parseGenerateResponse,sn as parseNumberText,Pn as parseQualifyResponse,Ln as parseReviewVerdict,qt as parseTemporalPoint,cn as payloadPreview,Ht as pickSeriesColumn,Mn as progressStageOf,pn as readGenerateStream,Ae as readName,m as readWireField,et as registerCityTable,gt as registerIso3Regions,L as resolveAdmin1,Ce as resolveFetchVersion,st as resolveGeoPoint,_e as resolveLanguage,hn as resolvePointRoles,Dn as retryFields,Ze as safeDistinctValuesToShip,Te as schemaIdentity,qn as schemaIdentityKey,Ee as schemaTypeFamily,Bt as seriesKeyVerdict,kt as shareOfTotalIsHonest,be as shortlistIsStale,vt as stripHostAggPrefix,ht as summarizeCountryRegions,pt as summarizeGeoExtent,Pe as supportedLanguage,dt as toGeoIso,Fe as unsegmentedRuns,Fn as viewportFields,q as vocabularyLanguage,je as wholeDayFrame,Be as wholeDayIso,H as wireResponseFromFetch,ke as wordEndsWith,J as zipMatchPct,G as zipPrefixCandidates,rt as zipToPrefix3};
|
package/dist/testing.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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{f as
|
|
3
|
-
- ${
|
|
4
|
-
- `)}`),this.name="ConformanceError",this.contract=e,this.failures=
|
|
2
|
+
import{f as A,h as g}from"./chunk-5KAS4CFP.mjs";import"./chunk-NFSQ4O5R.mjs";var S=class extends Error{contract;failures;constructor(e,s){super(`${e} conformance failed:
|
|
3
|
+
- ${s.join(`
|
|
4
|
+
- `)}`),this.name="ConformanceError",this.contract=e,this.failures=s}},m=class{constructor(e){this.contract=e}contract;failures=[];check(e,s){e||this.failures.push(s)}fail(e){this.failures.push(e)}throwIfFailed(){if(this.failures.length)throw new S(this.contract,this.failures.slice())}},$="H4sIAAAAAAAAA6tWyk0tSs5ITUxRslIqS8wpTVWqBQBL0RbkEwAAAA==",R="H4sIAAAAAAAAA6tWSkksSVSyUsrMyyrKz1OqBQBVrD9YEAAAAA==";function u(n){return n instanceof Error?`${n.name}: ${n.message}`:String(n)}function x(n){let e=new m("WireSigner");(!n||typeof n.sign!="function")&&(e.fail("the signer has no sign() method"),e.throwIfFailed());let s,d,l;try{s=n.sign($),d=n.sign($),l=n.sign(R)}catch(a){e.fail(`sign() threw on an ordinary encoded body: ${u(a)}`),e.throwIfFailed()}e.check(typeof s=="string",`sign() returned ${typeof s}, not a string`),e.check(typeof s!="string"||s.trim()!=="","sign() returned a blank signature"),e.check(s===d,"sign() is not deterministic: the same body signed twice gave two signatures"),e.check(s!==l,"sign() gave two different bodies the same signature"),e.throwIfFailed()}async function q(n){let e=new m("WireResponse"),s=new TextEncoder,d=[`{"type":"progress","stage":"Reading your data"}
|
|
5
5
|
`,`{"type":"result","result":{"code":"x","version":2}}
|
|
6
|
-
`],
|
|
6
|
+
`],l=(a,r=!1)=>new ReadableStream({start(t){for(let o of a)t.enqueue(o);r?t.error(Object.assign(new Error("the connection dropped"),{name:"AbortError"})):t.close()}});try{let a=n(new Response(l(d.map(o=>s.encode(o))),{status:200,headers:{"Content-Type":"application/x-ndjson; charset=utf-8"}}));e.check(a.status===200,`a streamed 200 reported status ${a.status}`),e.check(A(a.contentType),`a streamed response reported content type ${JSON.stringify(a.contentType)}`);let r=[],t=await g(a,o=>r.push(o));e.check(t?.code==="x"&&t?.version===2,"the stream's result line did not come back as the result"),e.check(r.join("|")==="Reading your data",`progress stages read as ${JSON.stringify(r)}`)}catch(a){e.fail(`reading an NDJSON stream threw: ${u(a)}`)}try{let a=n(new Response('{"code":"y","errorMessage":""}',{status:200,headers:{"Content-Type":"application/json"}}));e.check(!A(a.contentType),"a JSON response reported an NDJSON content type");let r=await g(a);e.check(r?.code==="y","a buffered JSON body did not come back as the result")}catch(a){e.fail(`reading a buffered JSON body threw: ${u(a)}`)}try{let a=n(new Response(l([s.encode(d[0])],!0),{status:200,headers:{"Content-Type":"application/x-ndjson"}})),r=null;try{await g(a)}catch(t){r=t}e.check(!!r,"a body that errored part-way was read as a success"),e.check(!r||r.name==="AbortError",`a body that errored part-way surfaced as ${r?.name}: ${r?.message}, not the body's own error`)}catch(a){e.fail(`adapting a response whose body errors threw before it was read: ${u(a)}`)}try{let a=n(new Response(null,{status:204}));e.check(a.status===204,`a 204 reported status ${a.status}`);let r=await a.text();e.check(r==="",`a 204's text() returned ${JSON.stringify(r)}`)}catch(a){e.fail(`a 204 with no body threw: ${u(a)}`)}e.throwIfFailed()}async function T(n,e){let s=n instanceof Request?n:new Request(String(n),e),d=e?.signal??s.signal??null;return{url:s.url,method:s.method,headers:s.headers,body:await s.text(),signal:d}}var k=()=>Object.assign(new Error("The operation was aborted."),{name:"AbortError"});async function w(n,e){let s,d=new Promise(l=>{s=setTimeout(()=>l({settled:!1}),e)});try{return await Promise.race([n.then(l=>({settled:!0,ok:!0,value:l}),l=>({settled:!0,ok:!1,error:l})),d])}finally{s&&clearTimeout(s)}}async function I(n){let e=new m("WireTransport"),s="https://service.example/api/route/?nocache=1",d="H4sIAAAAAAAAA6tWyk0tSs5ITUxRslIqS8wpTVWqBQBL0RbkEwAAAA==",l={"Content-Type":"text/plain","X-Signature":"12345"},a=40,r=1e3;try{let t=null,o=n(async(c,h)=>(t=await T(c,h),new Response('{"ok":true}',{status:200,headers:{"Content-Type":"application/json"}}))),i=await w(o.post(s,d,l,{timeoutMs:5e3}),r);if(!i.settled)e.fail("an ordinary post never settled");else if(i.ok===!1)e.fail(`an ordinary post rejected: ${u(i.error)}`);else{let c=t;e.check(!!c,"the adapter never called the fetch it was given"),c&&(e.check(c.url===s,`the request went to ${c.url}, not the URL it was given`),e.check(c.method==="POST",`the request was a ${c.method}, not a POST`),e.check(c.body===d,"the body did not reach the network as given"),e.check(c.headers.get("content-type")==="text/plain",`Content-Type reached the network as ${c.headers.get("content-type")}`),e.check(c.headers.get("x-signature")==="12345","a header the caller set did not reach the network")),e.check(i.value.status===200,`a 200 reported status ${i.value.status}`),e.check(A(i.value.contentType)===!1&&/json/.test(String(i.value.contentType)),`the response's content type read as ${JSON.stringify(i.value.contentType)}`),e.check(await i.value.text()==='{"ok":true}',"text() did not return the body")}}catch(t){e.fail(`an ordinary post threw: ${u(t)}`)}for(let t of[400,500,503])try{let o=n(async()=>new Response('{"message":"why"}',{status:t,headers:{"Content-Type":"application/json"}})),i=await w(o.post(s,d,l,{timeoutMs:5e3}),r);i.settled?i.ok===!1?e.fail(`an HTTP ${t} rejected (${u(i.error)}) - a status is an answer, not a transport failure`):(e.check(i.value.status===t,`an HTTP ${t} reported status ${i.value.status}`),e.check(await i.value.text()==='{"message":"why"}',`an HTTP ${t}'s body could not be read`)):e.fail(`an HTTP ${t} never settled`)}catch(o){e.fail(`an HTTP ${t} threw: ${u(o)}`)}try{let t=n(async()=>new Response(null,{status:204})),o=await w(t.post(s,d,l,{timeoutMs:5e3}),r);!o.settled||!o.ok?e.fail("a 204 did not resolve"):e.check(o.value.status===204,`a 204 reported status ${o.value.status}`)}catch(t){e.fail(`a 204 threw: ${u(t)}`)}try{let t=n(async()=>{throw new TypeError("Failed to fetch")}),o=await w(t.post(s,d,l,{timeoutMs:5e3}),r);e.check(o.settled&&!o.ok,"a failed connection did not reject")}catch(t){e.fail(`a failed connection threw synchronously: ${u(t)}`)}try{let t=null,o=n((h,f)=>new Promise((b,p)=>{T(h,f).then(y=>{t=y.signal,y.signal&&(y.signal.aborted?p(k()):y.signal.addEventListener("abort",()=>p(k()),{once:!0}))})})),i=await w(o.post(s,d,l,{timeoutMs:a}),r);e.check(i.settled&&!i.ok,`no answer inside a ${a} ms deadline did not reject within ${r} ms`);let c=t;e.check(!!c&&c.aborted,"the deadline passed but the request was not aborted - the socket would stay open")}catch(t){e.fail(`the deadline check threw synchronously: ${u(t)}`)}try{let t=null,o=new TextEncoder,i=n(async(h,f)=>{let b=await T(h,f);t=b.signal;let p,y=new ReadableStream({start(v){p=v}});return p.enqueue(o.encode(`{"type":"progress","stage":"Reading your data"}
|
|
7
|
+
`)),b.signal?.addEventListener("abort",()=>{try{p.error(k())}catch{}},{once:!0}),new Response(y,{status:200,headers:{"Content-Type":"application/x-ndjson"}})}),c=await w(i.post(s,d,l,{timeoutMs:a}),r);if(!c.settled||c.ok===!1)e.fail("headers that arrived in time did not resolve the post");else{let h=await w(g(c.value),r);e.check(h.settled&&h.ok===!1,`a body that stalled after its headers was still being read ${r} ms after a ${a} ms deadline`);let f=t;e.check(!!f&&f.aborted,"the deadline passed mid-body but the request was not aborted - the socket would stay open")}}catch(t){e.fail(`the body-deadline check threw synchronously: ${u(t)}`)}try{let t=new AbortController,i=n((h,f)=>new Promise((b,p)=>{T(h,f).then(y=>{y.signal&&(y.signal.aborted?p(k()):y.signal.addEventListener("abort",()=>p(k()),{once:!0}))})})).post(s,d,l,{timeoutMs:5e3,signal:t.signal});setTimeout(()=>t.abort(),10);let c=await w(i,r);e.check(c.settled&&!c.ok,"aborting the caller's signal did not reject the post")}catch(t){e.fail(`the caller-signal check threw synchronously: ${u(t)}`)}e.throwIfFailed()}export{S as ConformanceError,q as assertWireResponseConformance,x as assertWireSignerConformance,I as assertWireTransportConformance};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WireTransport } from "./host/services";
|
|
2
|
+
/** A platform fetch, or anything shaped like one. Called as a plain function. */
|
|
3
|
+
export type FetchFunction = (input: string, init?: any) => Promise<{
|
|
4
|
+
status?: number;
|
|
5
|
+
headers?: {
|
|
6
|
+
get(name: string): string | null;
|
|
7
|
+
} | null;
|
|
8
|
+
body?: ReadableStream<Uint8Array> | null;
|
|
9
|
+
text(): Promise<string>;
|
|
10
|
+
}>;
|
|
11
|
+
export interface FetchTransportOptions {
|
|
12
|
+
/** The credentials mode every request carries. Default "omit". */
|
|
13
|
+
credentials?: "omit" | "same-origin" | "include";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A WireTransport over `fetchFn`. Every request is a POST; each call's `timeoutMs` covers the headers
|
|
17
|
+
* and the body; the caller's `signal`, when given, cancels as well.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchTransport(fetchFn: FetchFunction, options?: FetchTransportOptions): WireTransport;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { SeriesCompleteness, SeriesCoverage, SeriesKeyCandidate, SeriesKeyV
|
|
|
9
9
|
export { classifyForAggregation, allowedAggregations, defaultAggregation, isAggregationAllowed, shareOfTotalIsHonest, nameLooksIntensiveRate, nameLooksPositional, stripHostAggPrefix, hasDefaultAggPrefix, collapseRepeatedAggPrefix, codeNeedsLegacyAggNames, englishImplicitAggNames, INTENSIVE_WORD_TOKENS, INTENSIVE_SUFFIX_TOKENS, POSITIONAL_WORD_TOKENS, POSITIONAL_SUFFIX_TOKENS, } from "./aggregation";
|
|
10
10
|
export type { AggKind, AggAdditivity, AggBasis, AggNature, AggregationClass, AggregationColumn, } from "./aggregation";
|
|
11
11
|
export type { LLMColumnWithValue } from "./models";
|
|
12
|
-
export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHints, LLMRequestCode, LLMQualifyResult, LLMRequestCodeResult, GetLicenseStatusResult, } from "./models";
|
|
12
|
+
export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHints, LLMRequestCode, LLMQualifyResult, LLMRequestCodeResult, LLMResultNotice, GetLicenseStatusResult, } from "./models";
|
|
13
13
|
export { ROLE_MATCH_PCT, CITY_ROLE_MATCH_PCT, isBlankLike } from "./matchQuality";
|
|
14
14
|
export { detectOrdinalDomain, safeDistinctValuesToShip, isOrdinalFriendlyName } from "./ordinalDetector";
|
|
15
15
|
export { detectFormatSignature } from "./formatDetector";
|
|
@@ -44,11 +44,18 @@ export type { WireSigner, WireTransport, WireResponse, CredentialTriple, Credent
|
|
|
44
44
|
export { encodePayload, gzipWireText, keyedSigner, messageSignature, readWireField } from "./wire";
|
|
45
45
|
export type { GzipText } from "./wire";
|
|
46
46
|
export { readGenerateStream, isNdjsonContentType, wireResponseFromFetch } from "./wireStream";
|
|
47
|
+
export type { OnStage } from "./wireStream";
|
|
47
48
|
export { parseGenerateResponse, parseQualifyResponse, parseReviewVerdict } from "./wireParse";
|
|
48
|
-
export type { ParsedGenerateResponse, ParsedQualifyResponse, ParsedQualifyChart, ParsedQualifyRefusal, ParsedReviewVerdict, WirePointBinding, WirePointColumns, } from "./wireParse";
|
|
49
|
+
export type { ParsedGenerateResponse, ParsedQualifyResponse, ParsedQualifyChart, ParsedQualifyRefusal, ParsedReviewVerdict, ParsedNotice, WirePointBinding, WirePointColumns, } from "./wireParse";
|
|
50
|
+
export { PROGRESS_STAGE_IDS, progressStageOf, FREEMIUM_ATTEMPT_SPENT, CLIENT_SECRET_MISMATCH, FREEMIUM_COLUMN_CAP, answerIsRetryable, } from "./messageCodes";
|
|
51
|
+
export type { ProgressStageId } from "./messageCodes";
|
|
49
52
|
export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, shortlistIsStale, offeredShortlistFor, } from "./wireBuild";
|
|
50
53
|
export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, } from "./wireBuild";
|
|
51
54
|
export { schemaIdentity, schemaIdentityKey, schemaTypeFamily } from "./schemaIdentity";
|
|
52
55
|
export type { SchemaIdentityColumn } from "./schemaIdentity";
|
|
53
|
-
export { SEV_INFO, SEV_WARNING, SEV_ERROR, SEV_USER_PRESENTED, CLIENT_EVENT_KINDS, isEventLogCode, eventLogLine, } from "./telemetry";
|
|
56
|
+
export { SEV_INFO, SEV_WARNING, SEV_ERROR, SEV_USER_PRESENTED, CLIENT_EVENT_KINDS, isEventLogCode, eventLogLine, TELEMETRY_TIMEOUT_MS, TELEMETRY_TIMEOUT_DEV_MS, } from "./telemetry";
|
|
54
57
|
export type { ClientMessage } from "./telemetry";
|
|
58
|
+
export { createTelemetryClient } from "./telemetryClient";
|
|
59
|
+
export type { TelemetryClient, TelemetryServices, TelemetryEnv, TelemetryFailure, TelemetryChannel } from "./telemetryClient";
|
|
60
|
+
export { fetchTransport } from "./fetchTransport";
|
|
61
|
+
export type { FetchFunction, FetchTransportOptions } from "./fetchTransport";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The progress stages a generation reports, as the stream's `stageId`. `working` is the stage
|
|
2
|
+
* before the first milestone. */
|
|
3
|
+
export declare const PROGRESS_STAGE_IDS: readonly ["working", "analyze", "generate", "refine", "review"];
|
|
4
|
+
export type ProgressStageId = typeof PROGRESS_STAGE_IDS[number];
|
|
5
|
+
/**
|
|
6
|
+
* Which stage a progress line reports: its `stageId` when the server sent a known one, otherwise -
|
|
7
|
+
* an older server, which sends only the English label - the label read the way hosts always read it
|
|
8
|
+
* (`analyz`, `generat`, `refin`, `review`). null when neither says: a host then shows the label as
|
|
9
|
+
* it is. A known code always wins over the label, whatever language the label is in.
|
|
10
|
+
*/
|
|
11
|
+
export declare function progressStageOf(stageId: string | null | undefined, stageLabel: string | null | undefined): ProgressStageId | null;
|
|
12
|
+
/** The freemium state that claims the attempt produced NO chart - the one message a chart already
|
|
13
|
+
* on screen contradicts. Every other freemium state (the limit reached, a warning) stays true with
|
|
14
|
+
* a chart painted. */
|
|
15
|
+
export declare const FREEMIUM_ATTEMPT_SPENT = "FREEMIUM_ATTEMPT_SPENT";
|
|
16
|
+
/** The licence answer for an account whose Client Secret Key is missing or does not match - the
|
|
17
|
+
* one a host answers by dropping a stale saved secret. */
|
|
18
|
+
export declare const CLIENT_SECRET_MISMATCH = "CLIENT_SECRET_MISMATCH";
|
|
19
|
+
/** The free tier's field cap: a wall that spent nothing (the historical `refusalCode`, kept). */
|
|
20
|
+
export declare const FREEMIUM_COLUMN_CAP = "FREEMIUM_COLUMN_CAP";
|
|
21
|
+
/**
|
|
22
|
+
* May the same request, sent again, answer differently? The server's `retryable` flag when it sent
|
|
23
|
+
* one; null when it did not (a success, or a server older than the flag) - the host then decides as
|
|
24
|
+
* it did before. Never read from the message text.
|
|
25
|
+
*/
|
|
26
|
+
export declare function answerIsRetryable(answer: {
|
|
27
|
+
retryable?: boolean | null;
|
|
28
|
+
} | null | undefined): boolean | null;
|
package/dist/types/models.d.ts
CHANGED
|
@@ -262,6 +262,7 @@ export type LLMOfferedShortlist = {
|
|
|
262
262
|
};
|
|
263
263
|
export type LLMQualifyResult = {
|
|
264
264
|
errorMessage?: string;
|
|
265
|
+
errorCode?: string;
|
|
265
266
|
charts?: {
|
|
266
267
|
name?: string;
|
|
267
268
|
description?: string;
|
|
@@ -285,6 +286,7 @@ export type LLMQualifyResult = {
|
|
|
285
286
|
refused?: {
|
|
286
287
|
name?: string;
|
|
287
288
|
reason?: string;
|
|
289
|
+
reasonCode?: string;
|
|
288
290
|
isVeto?: boolean;
|
|
289
291
|
}[];
|
|
290
292
|
noFitSummary?: string;
|
|
@@ -298,6 +300,9 @@ export type LLMRequestCodeResult = {
|
|
|
298
300
|
isServiceError: boolean;
|
|
299
301
|
isRefusal?: boolean;
|
|
300
302
|
refusalCode?: string;
|
|
303
|
+
errorCode?: string;
|
|
304
|
+
retryable?: boolean;
|
|
305
|
+
notices?: LLMResultNotice[];
|
|
301
306
|
isRateLimited?: boolean;
|
|
302
307
|
retryAfterSeconds?: number;
|
|
303
308
|
isVersionNotFound?: boolean;
|
|
@@ -318,6 +323,7 @@ export type LLMRequestCodeResult = {
|
|
|
318
323
|
freemiumPercentUsedRaw?: number;
|
|
319
324
|
freemiumExhausted?: boolean;
|
|
320
325
|
freemiumStatusMessage?: string;
|
|
326
|
+
freemiumStatusCode?: string;
|
|
321
327
|
userReply?: string;
|
|
322
328
|
userReplyOutcome?: string;
|
|
323
329
|
improvementSuggestion?: string;
|
|
@@ -337,8 +343,15 @@ export type LLMRequestCodeResult = {
|
|
|
337
343
|
destPointLonColumn?: string;
|
|
338
344
|
destPointCountryColumn?: string;
|
|
339
345
|
};
|
|
346
|
+
export type LLMResultNotice = {
|
|
347
|
+
code?: string;
|
|
348
|
+
severity?: string;
|
|
349
|
+
text?: string;
|
|
350
|
+
};
|
|
340
351
|
export type GetLicenseStatusResult = {
|
|
341
352
|
errorMessage: string;
|
|
353
|
+
errorCode?: string;
|
|
354
|
+
freemiumStatusCode?: string;
|
|
342
355
|
canContinue: boolean;
|
|
343
356
|
creditsLeft?: number;
|
|
344
357
|
warnCredits: boolean;
|
|
@@ -4,6 +4,13 @@ export declare const SEV_WARNING = 3;
|
|
|
4
4
|
export declare const SEV_ERROR = 4;
|
|
5
5
|
/** A bit OR-ed onto a level: the reader SAW this (an error on screen, a warning in a banner). */
|
|
6
6
|
export declare const SEV_USER_PRESENTED = 64;
|
|
7
|
+
/**
|
|
8
|
+
* How long one telemetry post may take, on both channels, before it is abandoned: nothing waits on a
|
|
9
|
+
* telemetry post, so the deadline only bounds how long a hung one holds its connection. A host talking
|
|
10
|
+
* to a development server (a tunnel that can be slow to wake) uses the longer one.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TELEMETRY_TIMEOUT_MS = 8000;
|
|
13
|
+
export declare const TELEMETRY_TIMEOUT_DEV_MS = 60000;
|
|
7
14
|
/**
|
|
8
15
|
* The fields of a client message, by the service's names. Every field is optional; a host sends what
|
|
9
16
|
* it knows. The service derives a failure from a non-empty StackTrace, so a failure must carry one.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Clock, WireSigner, WireTransport } from "./host/services";
|
|
2
|
+
import type { ClientMessage } from "./telemetry";
|
|
3
|
+
/** The services a telemetry client needs - the wire-level subset every host that sends requests has. */
|
|
4
|
+
export interface TelemetryServices {
|
|
5
|
+
signer: WireSigner;
|
|
6
|
+
transport: WireTransport;
|
|
7
|
+
clock: Clock;
|
|
8
|
+
}
|
|
9
|
+
/** Which channel a post went to. */
|
|
10
|
+
export type TelemetryChannel = "client-message" | "event-count";
|
|
11
|
+
/**
|
|
12
|
+
* A post that did not land. `stage` says where it stopped: `build` (the row could not be encoded or
|
|
13
|
+
* signed), `post` (the transport rejected: no connection, the deadline, an abort) or `status` (the
|
|
14
|
+
* service answered, with a status outside 2xx). `status` is the HTTP status for a `status` failure and
|
|
15
|
+
* null otherwise; `error` is what was thrown for `build` and `post`, and null for `status`.
|
|
16
|
+
*/
|
|
17
|
+
export interface TelemetryFailure {
|
|
18
|
+
channel: TelemetryChannel;
|
|
19
|
+
stage: "build" | "post" | "status";
|
|
20
|
+
status: number | null;
|
|
21
|
+
error: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface TelemetryEnv {
|
|
24
|
+
/**
|
|
25
|
+
* The service's origin, with no trailing slash: "https://example.com". A function is read at every
|
|
26
|
+
* post, for a host whose target can change after the client is built.
|
|
27
|
+
*/
|
|
28
|
+
baseUrl: string | (() => string);
|
|
29
|
+
/** The API prefix between the origin and the route. Default "/api". */
|
|
30
|
+
apiPath?: string;
|
|
31
|
+
/** The version every event-count line carries. */
|
|
32
|
+
clientVersion: string;
|
|
33
|
+
/** The deadline for one post, in milliseconds. Both channels use it. */
|
|
34
|
+
timeoutMs: number;
|
|
35
|
+
/** Told of a post that did not land. Never required; a throw inside it is swallowed. */
|
|
36
|
+
onFailure?: ((failure: TelemetryFailure) => void) | null;
|
|
37
|
+
}
|
|
38
|
+
export interface TelemetryClient {
|
|
39
|
+
/**
|
|
40
|
+
* Encode, sign and post one client message, as written - the row's key order is the envelope's.
|
|
41
|
+
* The URL carries a `nocache` stamp from the clock. Resolves when the post settles; never rejects.
|
|
42
|
+
*/
|
|
43
|
+
sendClientMessage(message: ClientMessage): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Post one event-count line, unsigned and as plain text: `eventLogLine(code, clientVersion,
|
|
46
|
+
* clientId, magnitude)`. The code is sent as given - a host that did not write the code itself
|
|
47
|
+
* checks it with `isEventLogCode` first. Resolves when the post settles; never rejects.
|
|
48
|
+
*/
|
|
49
|
+
countEvent(code: string, clientId: string, magnitude?: {
|
|
50
|
+
count: number;
|
|
51
|
+
nonce: string;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build a telemetry client over the host's services. A missing service or an unusable setting is a
|
|
56
|
+
* TypeError here, at construction, never a fallback at the first post.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createTelemetryClient(services: TelemetryServices, env: TelemetryEnv): TelemetryClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WireSigner, WireResponse } from "../host/services";
|
|
1
|
+
import type { WireSigner, WireResponse, WireTransport } from "../host/services";
|
|
2
2
|
/** Thrown by every conformance check. `failures` names each property the adapter broke. */
|
|
3
3
|
export declare class ConformanceError extends Error {
|
|
4
4
|
readonly contract: string;
|
|
@@ -19,3 +19,17 @@ export declare function assertWireSignerConformance(signer: WireSigner): void;
|
|
|
19
19
|
* client's response. Needs a global `Response` (browsers; Node 18 and later).
|
|
20
20
|
*/
|
|
21
21
|
export declare function assertWireResponseConformance(adapt: (res: Response) => WireResponse): Promise<void>;
|
|
22
|
+
/** The platform fetch's signature, as a transport adapter takes it. */
|
|
23
|
+
export type FetchLike = (input: any, init?: any) => Promise<Response>;
|
|
24
|
+
/**
|
|
25
|
+
* A host's WireTransport, built over a fetch the check supplies: `make(fetch)` returns the host's
|
|
26
|
+
* adapter wired to that fetch, so a host whose adapter wraps some other client passes the function
|
|
27
|
+
* that wires that client to the given fetch. Driven through what every transport meets: an ordinary
|
|
28
|
+
* post (url, method, body and headers reach the network as given), an HTTP error (RESOLVES with its
|
|
29
|
+
* status, and its body is still readable - a 4xx body carries the server's own explanation), a 204,
|
|
30
|
+
* a network failure (rejects), no answer inside the deadline (rejects, and the request is aborted so
|
|
31
|
+
* the socket drops), a body that stalls after headers that came in time (the deadline covers the
|
|
32
|
+
* whole exchange, so the read ends in an error), and a caller's signal (rejects when it aborts). Uses
|
|
33
|
+
* real timers and a deadline of a few tens of milliseconds.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertWireTransportConformance(make: (fetch: FetchLike) => WireTransport): Promise<void>;
|
|
@@ -11,10 +11,31 @@ export interface WirePointColumns {
|
|
|
11
11
|
export interface WirePointBinding extends WirePointColumns {
|
|
12
12
|
dest?: WirePointColumns;
|
|
13
13
|
}
|
|
14
|
+
/** One sentence of the composed warning, with the code that names it. */
|
|
15
|
+
export interface ParsedNotice {
|
|
16
|
+
/** Stable, kebab-case ("summed-rate", "pick-substituted", ...); "" when the server sent none. */
|
|
17
|
+
code: string;
|
|
18
|
+
/** "blocked" | "substituted" | "data" | "advisory", or "" when absent. */
|
|
19
|
+
severity: string;
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
14
22
|
/** A generate result's fields, typed. */
|
|
15
23
|
export interface ParsedGenerateResponse {
|
|
16
24
|
/** The server's own words when it declined. "" on a success. */
|
|
17
25
|
errorMessage: string;
|
|
26
|
+
/** WHICH message errorMessage is, as a stable code; "" on a success and from an older server.
|
|
27
|
+
* Decide by this, never by the sentence (messageCodes.ts). */
|
|
28
|
+
errorCode: string;
|
|
29
|
+
/** Which refusal, when the server declined before any model ran; "" otherwise. */
|
|
30
|
+
refusalCode: string;
|
|
31
|
+
/** Whether the same request sent again can answer differently: true or false when the server
|
|
32
|
+
* said, null when it did not (a success, or an older server - decide as before). */
|
|
33
|
+
retryable: boolean | null;
|
|
34
|
+
/** The composed warning, sentence by sentence; [] when there is none or the server is older.
|
|
35
|
+
* Joining the texts in order gives warningMessage. */
|
|
36
|
+
notices: ParsedNotice[];
|
|
37
|
+
/** Which freemium state freemiumStatusMessage states; "" when absent. */
|
|
38
|
+
freemiumStatusCode: string;
|
|
18
39
|
code: string;
|
|
19
40
|
language: string;
|
|
20
41
|
/** 0 when absent. */
|
|
@@ -95,6 +116,9 @@ export interface ParsedQualifyRefusal {
|
|
|
95
116
|
name: string;
|
|
96
117
|
/** A sentence naming one requirement the data fails; "" when the server could not name it. */
|
|
97
118
|
reason: string;
|
|
119
|
+
/** Which gate wrote the reason, as a stable code; "" when there is no reason or the server is
|
|
120
|
+
* older. A host may word a code it knows itself; the sentence is the fallback. */
|
|
121
|
+
reasonCode: string;
|
|
98
122
|
/**
|
|
99
123
|
* True only when the server said so: a required channel is absent and no rebinding supplies
|
|
100
124
|
* it. Absent, null or anything but true reads as a preference an explicit pick may override -
|
|
@@ -105,6 +129,8 @@ export interface ParsedQualifyRefusal {
|
|
|
105
129
|
/** A qualify answer's fields, typed. */
|
|
106
130
|
export interface ParsedQualifyResponse {
|
|
107
131
|
errorMessage: string;
|
|
132
|
+
/** Which message errorMessage is; "" on success and from an older server. */
|
|
133
|
+
errorCode: string;
|
|
108
134
|
/** In the server's order - it IS the ranking. null when the body carried no list at all. */
|
|
109
135
|
charts: ParsedQualifyChart[] | null;
|
|
110
136
|
refused: ParsedQualifyRefusal[];
|
|
@@ -126,6 +152,9 @@ export interface ParsedReviewVerdict {
|
|
|
126
152
|
*/
|
|
127
153
|
fix: unknown;
|
|
128
154
|
errorMessage: string | null;
|
|
155
|
+
/** Which message errorMessage is (a REVIEW_* or licence code); null when absent. A fix's own
|
|
156
|
+
* code is on the fix. */
|
|
157
|
+
errorCode: string | null;
|
|
129
158
|
}
|
|
130
159
|
/** A vision-review body -> its verdict. null for a null or non-object body. */
|
|
131
160
|
export declare function parseReviewVerdict(data: unknown): ParsedReviewVerdict | null;
|
|
@@ -15,9 +15,14 @@ export declare function wireResponseFromFetch(res: {
|
|
|
15
15
|
body?: ReadableStream<Uint8Array> | null;
|
|
16
16
|
text(): Promise<string>;
|
|
17
17
|
}): WireResponse;
|
|
18
|
+
/** A progress line: the stage's display text (never empty) and its code, undefined from an older
|
|
19
|
+
* server. */
|
|
20
|
+
export type OnStage = (stage: string, stageId?: string) => void;
|
|
18
21
|
/**
|
|
19
22
|
* The generate result a response carries, whether it streamed or not. `onStage` receives each
|
|
20
|
-
*
|
|
21
|
-
* the
|
|
23
|
+
* progress line as it arrives: the stage label (display text) and, from a server that sends one,
|
|
24
|
+
* its `stageId` - the code a host picks its own waiting lines by (see `progressStageOf`), never the
|
|
25
|
+
* label. A line with no label is skipped, as it always was. Throws when there is no result (see the rules at the top
|
|
26
|
+
* of this file for which error means what).
|
|
22
27
|
*/
|
|
23
|
-
export declare function readGenerateStream(res: WireResponse, onStage?:
|
|
28
|
+
export declare function readGenerateStream(res: WireResponse, onStage?: OnStage): Promise<Record<string, any>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.36",
|
|
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-JF3BJI7F.mjs
DELETED
|
@@ -1,4 +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{u as c}from"./chunk-NFSQ4O5R.mjs";import{gzip as h}from"pako";var w=e=>h(e);function P(e){return x(w(JSON.stringify(e))).replace(/\//g,".")}function x(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function T(e){if(typeof e!="string"||e==="")throw new TypeError("keyedSigner needs the host's signing key");return{sign:t=>String(c(t+e))}}function W(e,t){let n=t.sign(e);if(typeof n!="string"||n.trim()==="")throw new TypeError("the host's signer returned a blank signature");return n}function u(e,t){if(e==null||typeof e!="object")return;let n=e,r=n[t];return r??n[t.charAt(0).toUpperCase()+t.slice(1)]}function m(e){return String(e??"").toLowerCase().includes("ndjson")}function C(e){let t=null;try{t=e.headers?.get?.("content-type")??null}catch{t=null}return{status:typeof e.status=="number"?e.status:0,contentType:t,body:e.body??null,text:()=>e.text()}}function S(e,t,n){let r=e.trim();if(!r)return{result:null,typed:!1,parsed:!1};let i;try{i=JSON.parse(r)}catch{return{result:null,typed:!1,parsed:!1}}return f(i,t,n)}function f(e,t,n){if(!e||typeof e!="object"||Array.isArray(e))return{result:null,typed:!1,parsed:!0};let r=u(e,"type");if(r!=null){if(r==="progress"){let s=String(u(e,"stage")??"").trim();return s&&t?.(s),{result:null,typed:!0,parsed:!0}}if(r==="result"){let s=u(e,"result");return{result:s&&typeof s=="object"?s:null,typed:!0,parsed:!0}}return{result:null,typed:!0,parsed:!0}}return n?{result:u(e,"code")!==void 0||u(e,"errorMessage")!==void 0?e:null,typed:!1,parsed:!0}:{result:e,typed:!1,parsed:!0}}var a=class{constructor(t){this.onStage=t}onStage;result=null;anyParsed=!1;take(t){let n=S(t,this.onStage,!0);n.parsed&&(this.anyParsed=!0),n.result&&(n.typed||this.result===null)&&(this.result=n.result)}};function d(){return new Error("the generate response ended without a result")}async function R(e,t){let n=e.body;if(!n||typeof n.getReader!="function")return p(await e.text(),t,null);let r=n.getReader(),i=new TextDecoder,s=new a(t),o="";try{for(;;){let{done:y,value:g}=await r.read();if(y)break;o+=i.decode(g,{stream:!0});let l;for(;(l=o.indexOf(`
|
|
3
|
-
`))>=0;)s.take(o.slice(0,l)),o=o.slice(l+1)}}finally{try{r.releaseLock?.()}catch{}}if(o+=i.decode(),s.take(o),!s.result)throw d();return s.result}function p(e,t,n){let r=new a(t);for(let i of e.split(`
|
|
4
|
-
`))r.take(i);if(r.result)return r.result;throw!r.anyParsed&&n?n:d()}async function b(e,t){let n=await e.text(),r;try{r=JSON.parse(n)}catch(s){return p(n,t,s)}if(!r||typeof r!="object"||Array.isArray(r))throw new SyntaxError("the generate response was JSON but not a result object");let i=f(r,t,!1);if(i.result)return i.result;throw d()}async function N(e,t){return m(e.contentType)?R(e,t):b(e,t)}export{w as a,P as b,T as c,W as d,u as e,m as f,C as g,N as h};
|