@opengis/bi 1.0.19 → 1.0.21

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.
@@ -1,4 +1,4 @@
1
- import { _ as l, c, i as h, t as p, h as d } from "./import-file-BJjgK8Hl.js";
1
+ import { _ as l, c, i as h, t as p, h as d } from "./import-file-C8BY90-b.js";
2
2
  import { openBlock as u, createElementBlock as m } from "vue";
3
3
  const D = {
4
4
  name: "VsCalendar",
@@ -1,4 +1,4 @@
1
- import { _ as o, c, a as h, b as l, d as n, i as d } from "./import-file-BJjgK8Hl.js";
1
+ import { _ as o, c, a as h, b as l, d as n, i as d } from "./import-file-C8BY90-b.js";
2
2
  import { openBlock as p, createElementBlock as u } from "vue";
3
3
  const m = {
4
4
  name: "VsFunnelBar",
@@ -1,4 +1,4 @@
1
- import { _ as u, c as m, a as d, i as f, t as x, e as y, g as c, d as D } from "./import-file-BJjgK8Hl.js";
1
+ import { _ as u, c as m, a as d, i as f, t as x, e as y, g as c, d as D } from "./import-file-C8BY90-b.js";
2
2
  import { openBlock as _, createElementBlock as g } from "vue";
3
3
  const w = {
4
4
  name: "VsHeatmap",
@@ -1,5 +1,5 @@
1
- import { l as g, m as M } from "./map-component-mixin-BDeshFZi.js";
2
- import { _ as w, c as y } from "./import-file-BJjgK8Hl.js";
1
+ import { l as g, m as M } from "./map-component-mixin-CFtShPun.js";
2
+ import { _ as w, c as y } from "./import-file-C8BY90-b.js";
3
3
  import { resolveComponent as i, openBlock as u, createElementBlock as _, createElementVNode as r, createBlock as V, createCommentVNode as v, createVNode as d } from "vue";
4
4
  const x = {
5
5
  mixins: [y, g, M],
@@ -1,5 +1,5 @@
1
- import { l as w, m as V, p as _ } from "./map-component-mixin-BDeshFZi.js";
2
- import { _ as v, c as C } from "./import-file-BJjgK8Hl.js";
1
+ import { l as w, m as V, p as _ } from "./map-component-mixin-CFtShPun.js";
2
+ import { _ as v, c as C } from "./import-file-C8BY90-b.js";
3
3
  import { resolveComponent as a, openBlock as h, createElementBlock as $, createVNode as s, createElementVNode as u, createBlock as x, createCommentVNode as L } from "vue";
4
4
  const k = {
5
5
  mixins: [C, w, V],
@@ -1,4 +1,4 @@
1
- import { _ as c, c as o, f as n } from "./import-file-BJjgK8Hl.js";
1
+ import { _ as c, c as o, f as n } from "./import-file-C8BY90-b.js";
2
2
  import { openBlock as i, createElementBlock as m, toDisplayString as s } from "vue";
3
3
  const u = {
4
4
  name: "VsNumber",
@@ -1,7 +1,7 @@
1
1
  var ge = Object.defineProperty;
2
2
  var ke = (c, e, t) => e in c ? ge(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
3
  var k = (c, e, t) => ke(c, typeof e != "symbol" ? e + "" : e, t);
4
- import { _ as de, c as xe } from "./import-file-BJjgK8Hl.js";
4
+ import { _ as de, c as xe } from "./import-file-C8BY90-b.js";
5
5
  import { openBlock as V, createElementBlock as J, createCommentVNode as be } from "vue";
6
6
  function Q() {
7
7
  return {
@@ -289,7 +289,7 @@ ${p}` : p;
289
289
  `, 1)[0], x = !p.trim(), d = 0;
290
290
  if (this.options.pedantic ? (d = 2, a = p.trimStart()) : x ? d = t[1].length + 1 : (d = t[2].search(/[^ ]/), d = d > 4 ? 1 : d, a = p.slice(d), d += t[1].length), x && /^[ \t]*$/.test(g) && (h += g + `
291
291
  `, e = e.substring(g.length + 1), o = !0), !o) {
292
- const Z = new RegExp(`^ {0,${Math.min(3, d - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), W = new RegExp(`^ {0,${Math.min(3, d - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), X = new RegExp(`^ {0,${Math.min(3, d - 1)}}(?:\`\`\`|~~~)`), G = new RegExp(`^ {0,${Math.min(3, d - 1)}}#`), fe = new RegExp(`^ {0,${Math.min(3, d - 1)}}<[a-z].*>`, "i");
292
+ const Z = new RegExp(`^ {0,${Math.min(3, d - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), W = new RegExp(`^ {0,${Math.min(3, d - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), X = new RegExp(`^ {0,${Math.min(3, d - 1)}}(?:\`\`\`|~~~)`), G = new RegExp(`^ {0,${Math.min(3, d - 1)}}#`), fe = new RegExp(`^ {0,${Math.min(3, d - 1)}}<(?:[a-z].*>|!--)`, "i");
293
293
  for (; e; ) {
294
294
  const M = e.split(`
295
295
  `, 1)[0];
@@ -647,7 +647,7 @@ const Re = /^(?:[ \t]*(?:\n|$))+/, _e = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*
647
647
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
648
648
  paragraph: f(j).replace("hr", E).replace("heading", ` *#{1,6} *[^
649
649
  ]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
650
- }, ce = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Pe = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, he = /^( {2,}|\\)\n(?!\s*$)/, Ze = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, L = "\\p{P}\\p{S}", Me = f(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, L).getRegex(), De = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, Qe = f(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, L).getRegex(), je = f("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, L).getRegex(), Oe = f("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, L).getRegex(), He = f(/\\([punct])/, "gu").replace(/punct/g, L).getRegex(), Ne = f(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Ue = f(H).replace("(?:-->|$)", "-->").getRegex(), Fe = f("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Ue).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), B = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, We = f(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", B).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), pe = f(/^!?\[(label)\]\[(ref)\]/).replace("label", B).replace("ref", O).getRegex(), ue = f(/^!?\[(ref)\](?:\[\])?/).replace("ref", O).getRegex(), Xe = f("reflink|nolink(?!\\()", "g").replace("reflink", pe).replace("nolink", ue).getRegex(), U = {
650
+ }, ce = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Pe = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, he = /^( {2,}|\\)\n(?!\s*$)/, Ze = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, L = "\\p{P}\\p{S}", Me = f(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, L).getRegex(), De = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, Qe = f(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, L).getRegex(), je = f("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, L).getRegex(), Oe = f("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, L).getRegex(), He = f(/\\([punct])/, "gu").replace(/punct/g, L).getRegex(), Ne = f(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), Ue = f(H).replace("(?:-->|$)", "-->").getRegex(), Fe = f("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Ue).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), B = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, We = f(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", B).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), pe = f(/^!?\[(label)\]\[(ref)\]/).replace("label", B).replace("ref", O).getRegex(), ue = f(/^!?\[(ref)\](?:\[\])?/).replace("ref", O).getRegex(), Xe = f("reflink|nolink(?!\\()", "g").replace("reflink", pe).replace("nolink", ue).getRegex(), U = {
651
651
  _backpedal: I,
652
652
  // only used for GFM url
653
653
  anyPunctuation: He,
@@ -677,7 +677,7 @@ const Re = /^(?:[ \t]*(?:\n|$))+/, _e = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*
677
677
  escape: f(ce).replace("])", "~|])").getRegex(),
678
678
  url: f(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
679
679
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
680
- del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
680
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
681
681
  text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
682
682
  }, Ve = {
683
683
  ...D,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/bi",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "BI data visualization module",
5
5
  "main": "dist/bi.js",
6
6
  "browser": "dist/bi.umd.cjs",
@@ -50,7 +50,7 @@
50
50
  "@opengis/fastify-auth": "^1.0.50",
51
51
  "@opengis/fastify-file": "^1.0.32",
52
52
  "@opengis/fastify-table": "^1.1.93",
53
- "@opengis/v3-core": "^0.2.65",
53
+ "@opengis/v3-core": "^0.3.8",
54
54
  "@opengis/v3-filter": "^0.0.39",
55
55
  "@turf/turf": "^7.1.0",
56
56
  "@vueuse/core": "^11.1.0",
@@ -92,4 +92,4 @@
92
92
  "vitepress-sidebar": "^1.22.0",
93
93
  "vue-tsc": "^2.1.6"
94
94
  }
95
- }
95
+ }
@@ -91,6 +91,17 @@ export default async function dashboard({
91
91
  }
92
92
  }));
93
93
  }
94
+ const ranges = index?.filters?.filter((el) => el?.id && columns.map((el) => el?.name).includes(el?.id) && el?.type === 'Range');
95
+ if (ranges?.length) {
96
+ await Promise.all(ranges.map(async (el) => {
97
+ const rows = await pg.query(`select array[
98
+ percentile_cont(0) within group (order by ${el.id}), percentile_cont(0.25) within group (order by ${el.id}),
99
+ percentile_cont(0.5) within group (order by ${el.id}), percentile_cont(0.75) within group (order by ${el.id}),
100
+ percentile_cont(1.0) within group (order by ${el.id})
101
+ ] from ${index?.table_name || index?.table}`).then(el => el.rows?.[0]?.array || []);
102
+ Object.assign(el, { options: rows });
103
+ }));
104
+ }
94
105
 
95
106
  // console.log(fileData)
96
107
  const widgets = fileData
@@ -7,6 +7,7 @@ import {
7
7
  pgClients,
8
8
  getSelectVal,
9
9
  getFilterSQL,
10
+ getMeta,
10
11
  } from '@opengis/fastify-table/utils.js';
11
12
 
12
13
  import chartSQL from './util/chartSQL.js';
@@ -53,6 +54,19 @@ export default async function dataAPI({ query = {} }) {
53
54
  }).catch((err) => console.log(err));
54
55
  }
55
56
 
57
+ const { pk, columns = [], view } = await getMeta({ pg, table: data.table });
58
+
59
+ if (!view && !pk) {
60
+ return { message: `table not found: ${data.table} (${pg.options?.database})`, status: 404 };
61
+ }
62
+
63
+ const columnList = columns.map(col => col.name);
64
+ const groupbyColumnNotExists = groupby?.split?.(',')?.filter?.(el => !columnList.includes(el.trim()));
65
+
66
+ if (groupby && groupbyColumnNotExists?.length) {
67
+ return { message: `groupby column not found: ${groupbyColumnNotExists} (${data.table}/${pg.options?.database})`, status: 404 };
68
+ }
69
+
56
70
  // get group
57
71
  const groupData = groupby
58
72
  ? await pg
@@ -1,13 +1,12 @@
1
1
  import { dataUpdate } from '@opengis/fastify-table/utils.js';
2
2
 
3
- import { yamlSafe } from '../../../../utils.js';
3
+ import { getWidget, yamlSafe } from '../../../../utils.js';
4
4
 
5
5
  export default async function widgetEdit({ pg, body, params, }) {
6
6
  const { widget: widgetName, name: dashboardName } = params;
7
7
  const data = body.yml && !body.style ? yamlSafe.load(body.yml) : body;
8
8
 
9
- const tableName =
10
- data.data?.table || data?.table || data.table_name || body.table_name;
9
+
11
10
 
12
11
  if (!widgetName || !dashboardName) {
13
12
  return {
@@ -15,30 +14,33 @@ export default async function widgetEdit({ pg, body, params, }) {
15
14
  status: 400,
16
15
  };
17
16
  }
18
- debugger;
19
17
 
20
18
  const { widget_id: widgetId } = await pg.query(
21
19
  `select a.widget_id , b.dashboard_id from bi.widget a, bi.dashboard b
22
20
  where $2 in (a.widget_id, a.name) and $1 in (b.dashboard_id, b.name) order by 1,2`,
23
- [dashboardName, widgetName]
24
- ).then((res1) => res1.rows?.[0] || {});
21
+ [dashboardName, widgetName]).then(res1 => res1.rows?.[0] || {});
25
22
 
26
- if (!widgetId) {
23
+ // get Data
24
+ const templateData = await getWidget({ dashboard: dashboardName, widget: widgetName });
25
+ if (!templateData) {
27
26
  return { message: `widget not found ${widgetName}`, status: 404 };
28
27
  }
29
28
 
29
+ const widgetData = ['style', 'data', 'type', 'title', 'controls'].filter(el => data[el]).reduce((p, el) => ({ ...p, [el]: data[el] }), {});
30
+
31
+ //console.log(templateData)
32
+ // get table
33
+ const tableName = templateData.table || body.table || widgetData.data?.table;
30
34
  if (!tableName || !pg.pk?.[tableName]) {
31
- return { message: 'bad params: table', status: 400 };
35
+ return { message: 'bad params: table ' + tableName, status: 400 };
32
36
  }
33
37
 
38
+ if (body.yml) {
39
+ Object.assign(widgetData, { yml: body.yml })
40
+ }
34
41
 
35
-
36
- // const widgetData = { ...data, data };
37
-
38
- const widgetData = body.yml ? { yml: body.yml } : { style: data.style, data: { x: data.x, metrics: data.metrics }, controls: data.controls, type: data.type, title: data.title, table_name: data.table_name };
39
- // console.log(widgetId, widgetData)
40
- // if (body?.yml) Object.assign(widgetData, { yml: body.yml });
41
- console.log(widgetData)
42
+ Object.assign(widgetData, { table_name: tableName });
43
+ console.log(widgetData);
42
44
  const rows = await dataUpdate({
43
45
  table: 'bi.widget',
44
46
  id: widgetId,