@bino-bi/bn-template-engine 1.0.0-alpha.13 → 1.0.0-alpha.14

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.
@@ -3438,10 +3438,14 @@ const Dataset = class {
3438
3438
  }
3439
3439
  }
3440
3440
  /**
3441
- * Returns `true` if the text starts with `http://` or `https://`.
3441
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3442
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3443
+ * protocol-relative URL we treat as inline-mode escape).
3442
3444
  */
3443
3445
  isUrl(text) {
3444
- return text.startsWith("http://") || text.startsWith("https://");
3446
+ if (text.startsWith("http://") || text.startsWith("https://"))
3447
+ return true;
3448
+ return text.startsWith("/") && !text.startsWith("//");
3445
3449
  }
3446
3450
  /**
3447
3451
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -3493,7 +3497,7 @@ const Dataset = class {
3493
3497
  }
3494
3498
  }
3495
3499
  render() {
3496
- return index.h(index.Host, { key: 'fa02248ff99fc299f0ed7c7feae63063d071685a' });
3500
+ return index.h(index.Host, { key: 'fc620f662e5e23800416e0a43dcdf2df6a4859fc' });
3497
3501
  }
3498
3502
  get element() { return index.getElement(this); }
3499
3503
  static get watchers() { return {
@@ -3609,10 +3613,14 @@ const Datasource = class {
3609
3613
  }
3610
3614
  }
3611
3615
  /**
3612
- * Returns `true` if the text starts with `http://` or `https://`.
3616
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3617
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3618
+ * protocol-relative URL we treat as inline-mode escape).
3613
3619
  */
3614
3620
  isUrl(text) {
3615
- return text.startsWith("http://") || text.startsWith("https://");
3621
+ if (text.startsWith("http://") || text.startsWith("https://"))
3622
+ return true;
3623
+ return text.startsWith("/") && !text.startsWith("//");
3616
3624
  }
3617
3625
  /**
3618
3626
  * Fetches JSON from the given URL and stores the result.
@@ -3658,7 +3666,7 @@ const Datasource = class {
3658
3666
  }
3659
3667
  }
3660
3668
  render() {
3661
- return index.h(index.Host, { key: '4c79b32d893865fe7c62118d4186b8175294636f' });
3669
+ return index.h(index.Host, { key: '7690736d5996a63f5e2fbccd00876d560261185f' });
3662
3670
  }
3663
3671
  get element() { return index.getElement(this); }
3664
3672
  static get watchers() { return {
@@ -14,9 +14,10 @@ import { computeContentHash, decodeCompressedContent } from "../../utils/content
14
14
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
15
15
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
16
16
  * parsed body directly to the `datasets` store.
17
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
18
- * JSON from a remote endpoint and write it to the `datasets` store.
19
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
17
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
18
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
19
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
20
+ * to enable periodic re-fetching.
20
21
  */
21
22
  export class Dataset {
22
23
  constructor() {
@@ -213,10 +214,14 @@ export class Dataset {
213
214
  }
214
215
  }
215
216
  /**
216
- * Returns `true` if the text starts with `http://` or `https://`.
217
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
218
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
219
+ * protocol-relative URL we treat as inline-mode escape).
217
220
  */
218
221
  isUrl(text) {
219
- return text.startsWith("http://") || text.startsWith("https://");
222
+ if (text.startsWith("http://") || text.startsWith("https://"))
223
+ return true;
224
+ return text.startsWith("/") && !text.startsWith("//");
220
225
  }
221
226
  /**
222
227
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -268,7 +273,7 @@ export class Dataset {
268
273
  }
269
274
  }
270
275
  render() {
271
- return h(Host, { key: 'fa02248ff99fc299f0ed7c7feae63063d071685a' });
276
+ return h(Host, { key: 'fc620f662e5e23800416e0a43dcdf2df6a4859fc' });
272
277
  }
273
278
  static get is() { return "bn-dataset"; }
274
279
  static get originalStyleUrls() {
@@ -10,8 +10,8 @@ import { computeContentHash, decodeCompressedContent } from "../../utils/content
10
10
  * Data can be provided in three ways:
11
11
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
12
12
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
13
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
14
- * from a remote endpoint.
13
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
14
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
15
15
  *
16
16
  * In URL mode the component fetches JSON from the URL. Set the `interval`
17
17
  * prop (in seconds) to enable periodic re-fetching (polling).
@@ -118,10 +118,14 @@ export class Datasource {
118
118
  }
119
119
  }
120
120
  /**
121
- * Returns `true` if the text starts with `http://` or `https://`.
121
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
122
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
123
+ * protocol-relative URL we treat as inline-mode escape).
122
124
  */
123
125
  isUrl(text) {
124
- return text.startsWith("http://") || text.startsWith("https://");
126
+ if (text.startsWith("http://") || text.startsWith("https://"))
127
+ return true;
128
+ return text.startsWith("/") && !text.startsWith("//");
125
129
  }
126
130
  /**
127
131
  * Fetches JSON from the given URL and stores the result.
@@ -167,7 +171,7 @@ export class Datasource {
167
171
  }
168
172
  }
169
173
  render() {
170
- return h(Host, { key: '4c79b32d893865fe7c62118d4186b8175294636f' });
174
+ return h(Host, { key: '7690736d5996a63f5e2fbccd00876d560261185f' });
171
175
  }
172
176
  static get is() { return "bn-datasource"; }
173
177
  static get originalStyleUrls() {
@@ -1 +1 @@
1
- import{getElement as t,proxyCustomElement as s,HTMLElement as i,h as e,Host as n,transformTag as r}from"@stencil/core/internal/client";import{g as a,c as o}from"./context-protocol.js";import{r as l}from"./utils.js";import{w as h}from"./withBodyObserver.js";import{w as c,a as u}from"./withHasError.js";import{d,c as f}from"./contentDecoder.js";const p=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],m=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function y(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function g(t){const s=Array.from(t);return{distinctValues:s,count:s.length,hasData:s.length>0}}const v=s(class extends i{constructor(s){super(),!1!==s&&this.__registerHost(),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,c(this),this.errors=u(this),((s,i)=>{let e,n=[],r=[];const h=t=>{let s;try{s=e.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){s=[]}i()},c=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(e.db.subscribe(t,(()=>h(t)))),h(t))}))},u=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(t(s).getAttribute("datasources")||"").split(","),c())}))})),d=s.connectedCallback;s.connectedCallback=()=>{const i=t(s);e=a(i),r=(i.getAttribute("datasources")||"").split(","),c(),u.observe(i,{attributes:!0,attributeFilter:["datasources"]}),l(d,s)};const f=s.disconnectedCallback;s.disconnectedCallback=()=>{u.disconnect(),n.forEach((t=>t())),n=[],o(t(s)),l(f,s)}})(this,(()=>{this.executeQuery()})),h(this,(t=>{const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastBodyHash=null,this.fetchAndStore(s),void this.startPolling()}let i,e;if(null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null),!this.raw&&this.static)try{const s=d(t);i=s.hash,e=s.json}catch(s){return void console.error("Error decoding compressed dataset",s,(t+"").slice(0,200))}else i=f(t),e=t;i!==this.lastBodyHash&&(this.lastBodyHash=i,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=a(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let s;if(this.static){try{s=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),s=[]}t.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query){try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name];try{t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,s=[],void this.publish(s)}}try{s=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){return}}this.publish(s)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const s={};for(const t of m)s[t]=new Set;const i={};for(const t of p)i[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const a=Array.isArray(t)?t:[];for(let t=0;t<a.length;t++){const o=a[t];if(null==o)continue;for(const t of m){const i=o[t];null!=i&&""!==i&&s[t].add(i+"")}for(const t of p){const s=o[t];if(y(s)){const e=i[t];e.hasData=!0,(null===e.min||s<e.min)&&(e.min=s),(null===e.max||s>e.max)&&(e.max=s)}}const l=o.date;if(null!=l&&""!==l){const t=l+"";e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const o=p.map((t=>({key:t,hasData:i[t].hasData,min:i[t].min,max:i[t].max}))),l=o.filter((t=>t.hasData)).map((t=>t.key)),h=g(s.rowGroup),c=g(s.category),u=g(s.subCategory),d=g(s.columnGroup),f=g(s.columnSubGroup),v={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let b="category";return u.hasData?b="subCategory":c.hasData?b="category":h.hasData&&(b="rowGroup"),{rowCount:a.length,scenarios:o,availableScenarios:l,rowGroup:h,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:v,suggestedLevel:b,suggestedOrder:b,suggestedDateInterval:v.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;if(this.clearPolling(),(null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db)&&this.name){const t=this.stores.db.db;try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name],this.stores.db.notify(this.name)}}isUrl(t){return t.startsWith("http://")||t.startsWith("https://")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=a(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.stores.db.db.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null,this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-dataset: error fetching URL",s,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return e(n,{key:"fa02248ff99fc299f0ed7c7feae63063d071685a"})}get element(){return this}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}static get style(){return"bn-dataset{display:none}"}},[0,"bn-dataset",{name:[1],datasources:[1],static:[4],raw:[4],interval:[2]},void 0,{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}]),b=v,w=function(){"undefined"!=typeof customElements&&["bn-dataset"].forEach((t=>{"bn-dataset"===t&&(customElements.get(r(t))||customElements.define(r(t),v))}))};export{b as BnDataset,w as defineCustomElement}
1
+ import{getElement as t,proxyCustomElement as s,HTMLElement as i,h as e,Host as n,transformTag as r}from"@stencil/core/internal/client";import{g as a,c as o}from"./context-protocol.js";import{r as l}from"./utils.js";import{w as h}from"./withBodyObserver.js";import{w as c,a as u}from"./withHasError.js";import{d,c as f}from"./contentDecoder.js";const p=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],m=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function y(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function g(t){const s=Array.from(t);return{distinctValues:s,count:s.length,hasData:s.length>0}}const v=s(class extends i{constructor(s){super(),!1!==s&&this.__registerHost(),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,c(this),this.errors=u(this),((s,i)=>{let e,n=[],r=[];const h=t=>{let s;try{s=e.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){s=[]}i()},c=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(e.db.subscribe(t,(()=>h(t)))),h(t))}))},u=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(t(s).getAttribute("datasources")||"").split(","),c())}))})),d=s.connectedCallback;s.connectedCallback=()=>{const i=t(s);e=a(i),r=(i.getAttribute("datasources")||"").split(","),c(),u.observe(i,{attributes:!0,attributeFilter:["datasources"]}),l(d,s)};const f=s.disconnectedCallback;s.disconnectedCallback=()=>{u.disconnect(),n.forEach((t=>t())),n=[],o(t(s)),l(f,s)}})(this,(()=>{this.executeQuery()})),h(this,(t=>{const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastBodyHash=null,this.fetchAndStore(s),void this.startPolling()}let i,e;if(null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null),!this.raw&&this.static)try{const s=d(t);i=s.hash,e=s.json}catch(s){return void console.error("Error decoding compressed dataset",s,(t+"").slice(0,200))}else i=f(t),e=t;i!==this.lastBodyHash&&(this.lastBodyHash=i,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=a(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let s;if(this.static){try{s=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),s=[]}t.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query){try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name];try{t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,s=[],void this.publish(s)}}try{s=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){return}}this.publish(s)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const s={};for(const t of m)s[t]=new Set;const i={};for(const t of p)i[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const a=Array.isArray(t)?t:[];for(let t=0;t<a.length;t++){const o=a[t];if(null==o)continue;for(const t of m){const i=o[t];null!=i&&""!==i&&s[t].add(i+"")}for(const t of p){const s=o[t];if(y(s)){const e=i[t];e.hasData=!0,(null===e.min||s<e.min)&&(e.min=s),(null===e.max||s>e.max)&&(e.max=s)}}const l=o.date;if(null!=l&&""!==l){const t=l+"";e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const o=p.map((t=>({key:t,hasData:i[t].hasData,min:i[t].min,max:i[t].max}))),l=o.filter((t=>t.hasData)).map((t=>t.key)),h=g(s.rowGroup),c=g(s.category),u=g(s.subCategory),d=g(s.columnGroup),f=g(s.columnSubGroup),v={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let b="category";return u.hasData?b="subCategory":c.hasData?b="category":h.hasData&&(b="rowGroup"),{rowCount:a.length,scenarios:o,availableScenarios:l,rowGroup:h,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:v,suggestedLevel:b,suggestedOrder:b,suggestedDateInterval:v.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;if(this.clearPolling(),(null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db)&&this.name){const t=this.stores.db.db;try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name],this.stores.db.notify(this.name)}}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=a(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.stores.db.db.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null,this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-dataset: error fetching URL",s,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return e(n,{key:"fc620f662e5e23800416e0a43dcdf2df6a4859fc"})}get element(){return this}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}static get style(){return"bn-dataset{display:none}"}},[0,"bn-dataset",{name:[1],datasources:[1],static:[4],raw:[4],interval:[2]},void 0,{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}]),b=v,w=function(){"undefined"!=typeof customElements&&["bn-dataset"].forEach((t=>{"bn-dataset"===t&&(customElements.get(r(t))||customElements.define(r(t),v))}))};export{b as BnDataset,w as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as s,h as i,Host as e,transformTag as n}from"@stencil/core/internal/client";import{w as r}from"./withBodyObserver.js";import{g as h}from"./context-protocol.js";import{w as l,a as o}from"./withHasError.js";import{c as a,d as c}from"./contentDecoder.js";const u=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,l(this),this.errors=o(this),r(this,(t=>{this.stores||(this.stores=h(this.element));const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastHash=null,this.fetchAndStore(s),void this.startPolling()}null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null);try{let s,i;if(this.raw)s=a(t),i=t;else{const e=c(t);s=e.hash,i=e.json}if(s===this.lastHash)return;this.lastHash=s;const e=JSON.parse(i);this.publish(e)}catch(s){console.error("Error parsing datasource",s,(t+"").slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;this.clearPolling();const i=null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db;i&&this.name&&(null!=i.tables[this.name]&&delete i.tables[this.name],i.views&&null!=i.views[this.name]&&delete i.views[this.name],this.stores.db.notify(this.name))}isUrl(t){return t.startsWith("http://")||t.startsWith("https://")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=h(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-datasource: error fetching URL",s,t),this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(e,{key:"4c79b32d893865fe7c62118d4186b8175294636f"})}get element(){return this}static get watchers(){return{interval:[{onIntervalChange:0}]}}static get style(){return"bn-datasource{display:none}"}},[0,"bn-datasource",{name:[1],raw:[4],interval:[2]},void 0,{interval:[{onIntervalChange:0}]}]),d=u,v=function(){"undefined"!=typeof customElements&&["bn-datasource"].forEach((t=>{"bn-datasource"===t&&(customElements.get(n(t))||customElements.define(n(t),u))}))};export{d as BnDatasource,v as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as s,h as i,Host as e,transformTag as n}from"@stencil/core/internal/client";import{w as r}from"./withBodyObserver.js";import{g as h}from"./context-protocol.js";import{w as l,a as o}from"./withHasError.js";import{c as a,d as c}from"./contentDecoder.js";const u=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,l(this),this.errors=o(this),r(this,(t=>{this.stores||(this.stores=h(this.element));const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastHash=null,this.fetchAndStore(s),void this.startPolling()}null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null);try{let s,i;if(this.raw)s=a(t),i=t;else{const e=c(t);s=e.hash,i=e.json}if(s===this.lastHash)return;this.lastHash=s;const e=JSON.parse(i);this.publish(e)}catch(s){console.error("Error parsing datasource",s,(t+"").slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;this.clearPolling();const i=null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db;i&&this.name&&(null!=i.tables[this.name]&&delete i.tables[this.name],i.views&&null!=i.views[this.name]&&delete i.views[this.name],this.stores.db.notify(this.name))}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=h(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-datasource: error fetching URL",s,t),this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(e,{key:"7690736d5996a63f5e2fbccd00876d560261185f"})}get element(){return this}static get watchers(){return{interval:[{onIntervalChange:0}]}}static get style(){return"bn-datasource{display:none}"}},[0,"bn-datasource",{name:[1],raw:[4],interval:[2]},void 0,{interval:[{onIntervalChange:0}]}]),d=u,f=function(){"undefined"!=typeof customElements&&["bn-datasource"].forEach((t=>{"bn-datasource"===t&&(customElements.get(n(t))||customElements.define(n(t),u))}))};export{d as BnDatasource,f as defineCustomElement}
@@ -3436,10 +3436,14 @@ const Dataset = class {
3436
3436
  }
3437
3437
  }
3438
3438
  /**
3439
- * Returns `true` if the text starts with `http://` or `https://`.
3439
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3440
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3441
+ * protocol-relative URL we treat as inline-mode escape).
3440
3442
  */
3441
3443
  isUrl(text) {
3442
- return text.startsWith("http://") || text.startsWith("https://");
3444
+ if (text.startsWith("http://") || text.startsWith("https://"))
3445
+ return true;
3446
+ return text.startsWith("/") && !text.startsWith("//");
3443
3447
  }
3444
3448
  /**
3445
3449
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -3491,7 +3495,7 @@ const Dataset = class {
3491
3495
  }
3492
3496
  }
3493
3497
  render() {
3494
- return h(Host, { key: 'fa02248ff99fc299f0ed7c7feae63063d071685a' });
3498
+ return h(Host, { key: 'fc620f662e5e23800416e0a43dcdf2df6a4859fc' });
3495
3499
  }
3496
3500
  get element() { return getElement(this); }
3497
3501
  static get watchers() { return {
@@ -3607,10 +3611,14 @@ const Datasource = class {
3607
3611
  }
3608
3612
  }
3609
3613
  /**
3610
- * Returns `true` if the text starts with `http://` or `https://`.
3614
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3615
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3616
+ * protocol-relative URL we treat as inline-mode escape).
3611
3617
  */
3612
3618
  isUrl(text) {
3613
- return text.startsWith("http://") || text.startsWith("https://");
3619
+ if (text.startsWith("http://") || text.startsWith("https://"))
3620
+ return true;
3621
+ return text.startsWith("/") && !text.startsWith("//");
3614
3622
  }
3615
3623
  /**
3616
3624
  * Fetches JSON from the given URL and stores the result.
@@ -3656,7 +3664,7 @@ const Datasource = class {
3656
3664
  }
3657
3665
  }
3658
3666
  render() {
3659
- return h(Host, { key: '4c79b32d893865fe7c62118d4186b8175294636f' });
3667
+ return h(Host, { key: '7690736d5996a63f5e2fbccd00876d560261185f' });
3660
3668
  }
3661
3669
  get element() { return getElement(this); }
3662
3670
  static get watchers() { return {
@@ -6,9 +6,10 @@
6
6
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
7
7
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
8
8
  * parsed body directly to the `datasets` store.
9
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
10
- * JSON from a remote endpoint and write it to the `datasets` store.
11
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
9
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
10
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
11
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
12
+ * to enable periodic re-fetching.
12
13
  */
13
14
  export declare class Dataset {
14
15
  private element;
@@ -62,7 +63,9 @@ export declare class Dataset {
62
63
  onIntervalChange(): void;
63
64
  disconnectedCallback(): void;
64
65
  /**
65
- * Returns `true` if the text starts with `http://` or `https://`.
66
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
67
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
68
+ * protocol-relative URL we treat as inline-mode escape).
66
69
  */
67
70
  private isUrl;
68
71
  /**
@@ -4,8 +4,8 @@
4
4
  * Data can be provided in three ways:
5
5
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
6
6
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
7
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
8
- * from a remote endpoint.
7
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
8
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
9
9
  *
10
10
  * In URL mode the component fetches JSON from the URL. Set the `interval`
11
11
  * prop (in seconds) to enable periodic re-fetching (polling).
@@ -50,7 +50,9 @@ export declare class Datasource {
50
50
  onIntervalChange(): void;
51
51
  disconnectedCallback(): void;
52
52
  /**
53
- * Returns `true` if the text starts with `http://` or `https://`.
53
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
54
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
55
+ * protocol-relative URL we treat as inline-mode escape).
54
56
  */
55
57
  private isUrl;
56
58
  /**
@@ -295,9 +295,10 @@ export namespace Components {
295
295
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
296
296
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
297
297
  * parsed body directly to the `datasets` store.
298
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
299
- * JSON from a remote endpoint and write it to the `datasets` store.
300
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
298
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
299
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
300
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
301
+ * to enable periodic re-fetching.
301
302
  */
302
303
  interface BnDataset {
303
304
  /**
@@ -330,8 +331,8 @@ export namespace Components {
330
331
  * Data can be provided in three ways:
331
332
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
332
333
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
333
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
334
- * from a remote endpoint.
334
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
335
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
335
336
  * In URL mode the component fetches JSON from the URL. Set the `interval`
336
337
  * prop (in seconds) to enable periodic re-fetching (polling).
337
338
  * Other components (e.g. `bn-dataset`) reference the stored data by the
@@ -1387,9 +1388,10 @@ declare global {
1387
1388
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
1388
1389
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
1389
1390
  * parsed body directly to the `datasets` store.
1390
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
1391
- * JSON from a remote endpoint and write it to the `datasets` store.
1392
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
1391
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
1392
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
1393
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
1394
+ * to enable periodic re-fetching.
1393
1395
  */
1394
1396
  interface HTMLBnDatasetElement extends Components.BnDataset, HTMLStencilElement {
1395
1397
  }
@@ -1402,8 +1404,8 @@ declare global {
1402
1404
  * Data can be provided in three ways:
1403
1405
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
1404
1406
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
1405
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
1406
- * from a remote endpoint.
1407
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
1408
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
1407
1409
  * In URL mode the component fetches JSON from the URL. Set the `interval`
1408
1410
  * prop (in seconds) to enable periodic re-fetching (polling).
1409
1411
  * Other components (e.g. `bn-dataset`) reference the stored data by the
@@ -1878,9 +1880,10 @@ declare namespace LocalJSX {
1878
1880
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
1879
1881
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
1880
1882
  * parsed body directly to the `datasets` store.
1881
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
1882
- * JSON from a remote endpoint and write it to the `datasets` store.
1883
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
1883
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
1884
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
1885
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
1886
+ * to enable periodic re-fetching.
1884
1887
  */
1885
1888
  interface BnDataset {
1886
1889
  /**
@@ -1913,8 +1916,8 @@ declare namespace LocalJSX {
1913
1916
  * Data can be provided in three ways:
1914
1917
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
1915
1918
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
1916
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
1917
- * from a remote endpoint.
1919
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
1920
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
1918
1921
  * In URL mode the component fetches JSON from the URL. Set the `interval`
1919
1922
  * prop (in seconds) to enable periodic re-fetching (polling).
1920
1923
  * Other components (e.g. `bn-dataset`) reference the stored data by the
@@ -3249,9 +3252,10 @@ declare module "@stencil/core" {
3249
3252
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
3250
3253
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
3251
3254
  * parsed body directly to the `datasets` store.
3252
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
3253
- * JSON from a remote endpoint and write it to the `datasets` store.
3254
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
3255
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
3256
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
3257
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
3258
+ * to enable periodic re-fetching.
3255
3259
  */
3256
3260
  "bn-dataset": LocalJSX.IntrinsicElements["bn-dataset"] & JSXBase.HTMLAttributes<HTMLBnDatasetElement>;
3257
3261
  /**
@@ -3259,8 +3263,8 @@ declare module "@stencil/core" {
3259
3263
  * Data can be provided in three ways:
3260
3264
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
3261
3265
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
3262
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
3263
- * from a remote endpoint.
3266
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
3267
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
3264
3268
  * In URL mode the component fetches JSON from the URL. Set the `interval`
3265
3269
  * prop (in seconds) to enable periodic re-fetching (polling).
3266
3270
  * Other components (e.g. `bn-dataset`) reference the stored data by the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bino-bi/bn-template-engine",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.14",
4
4
  "description": "IBCS-compliant web components for business intelligence tables and charts",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",