@opengis/bi 1.2.29 → 1.2.30
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/bi.js +1 -1
- package/dist/bi.umd.cjs +75 -75
- package/dist/{import-file-C1s2X9Kt.js → import-file-B4o9p2_2.js} +2365 -1798
- package/dist/{vs-funnel-bar-BuV_pQBq.js → vs-funnel-bar-BOWwPnjW.js} +1 -1
- package/dist/{vs-list-uhEudqNr.js → vs-list-D8jGusRT.js} +1 -1
- package/dist/{vs-map-qs7P1yfP.js → vs-map-BGplOwpB.js} +2 -2
- package/dist/{vs-map-cluster-CeJxLtZx.js → vs-map-cluster-CHQJV2As.js} +2 -2
- package/dist/{vs-number-BNnFUzs3.js → vs-number-jPqxFQ6d.js} +1 -1
- package/dist/{vs-table-BEvWIkoj.js → vs-table-BDgIvJbY.js} +1 -1
- package/dist/{vs-text-CPMz7TWB.js → vs-text-DcHOffy9.js} +1 -1
- package/package.json +1 -1
- package/server/routes/dashboard/controllers/utils/yaml.js +11 -11
- package/server/routes/map/controllers/cluster.js +125 -125
- package/server/routes/map/controllers/clusterVtile.js +166 -166
- package/server/routes/map/controllers/geojson.js +127 -127
- package/server/routes/map/controllers/map.js +69 -69
- package/server/routes/map/controllers/utils/downloadClusterData.js +44 -44
- package/server/routes/map/controllers/vtile.js +183 -183
- package/utils.js +12 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as l, c as h, a as c, b as d, d as p } from "./import-file-
|
|
1
|
+
import { _ as l, c as h, a as c, b as d, d as p } from "./import-file-B4o9p2_2.js";
|
|
2
2
|
import { createElementBlock as u, openBlock as m } from "vue";
|
|
3
3
|
const o = typeof window < "u" ? window.echarts : null, f = {
|
|
4
4
|
name: "VsFunnelBar",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createBlock as b, openBlock as l, unref as L, mergeProps as v, createElementBlock as d, createElementVNode as c, withDirectives as F, toDisplayString as S, vShow as R, Fragment as P, renderList as V, normalizeClass as D, resolveComponent as A, createVNode as H } from "vue";
|
|
2
|
-
import { e as x, X as J, _ as w } from "./import-file-
|
|
2
|
+
import { e as x, X as J, _ as w } from "./import-file-B4o9p2_2.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as E, a as L, p as $, V as T, b as B, c as H, d as O, l as F, e as N } from "./vs-list-
|
|
2
|
-
import { _ as V, c as P } from "./import-file-
|
|
1
|
+
import { _ as E, a as L, p as $, V as T, b as B, c as H, d as O, l as F, e as N } from "./vs-list-D8jGusRT.js";
|
|
2
|
+
import { _ as V, c as P } from "./import-file-B4o9p2_2.js";
|
|
3
3
|
import { resolveComponent as u, createElementBlock as c, openBlock as i, Fragment as w, createElementVNode as r, createBlock as C, createCommentVNode as m, createVNode as x, Teleport as R, toDisplayString as g, renderList as S, normalizeStyle as k, normalizeClass as I } from "vue";
|
|
4
4
|
const A = {
|
|
5
5
|
components: { legendIcon: L, closeIcon: E },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as A, a as F, p as T, c as G, V as P, b as Z, d as q, e as D, l as K } from "./vs-list-
|
|
2
|
-
import { e as W, _ as H, V as J, c as Q, g as U, h as X, i as Y } from "./import-file-
|
|
1
|
+
import { _ as A, a as F, p as T, c as G, V as P, b as Z, d as q, e as D, l as K } from "./vs-list-D8jGusRT.js";
|
|
2
|
+
import { e as W, _ as H, V as J, c as Q, g as U, h as X, i as Y } from "./import-file-B4o9p2_2.js";
|
|
3
3
|
import { createElementBlock as g, createCommentVNode as S, openBlock as p, createElementVNode as l, normalizeClass as V, Fragment as R, renderList as N, toDisplayString as O, normalizeStyle as j, createBlock as z, unref as $, mergeProps as ee, resolveComponent as m, withDirectives as M, resolveDynamicComponent as te, createVNode as w, vShow as C } from "vue";
|
|
4
4
|
/**
|
|
5
5
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as m, c as f, b as _, d as b } from "./import-file-
|
|
1
|
+
import { _ as m, c as f, b as _, d as b } from "./import-file-B4o9p2_2.js";
|
|
2
2
|
import { createElementBlock as a, openBlock as r, createElementVNode as s, Fragment as n, renderList as c, toDisplayString as d } from "vue";
|
|
3
3
|
const x = {
|
|
4
4
|
name: "VsTable",
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import yaml from 'js-yaml';
|
|
2
|
-
|
|
3
|
-
yaml.loadSafe = (yml) => {
|
|
4
|
-
try {
|
|
5
|
-
return yaml.load(yml);
|
|
6
|
-
} catch (err) {
|
|
7
|
-
return { error: err.toString() };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default yaml;
|
|
1
|
+
import yaml from 'js-yaml';
|
|
2
|
+
|
|
3
|
+
yaml.loadSafe = (yml) => {
|
|
4
|
+
try {
|
|
5
|
+
return yaml.load(yml);
|
|
6
|
+
} catch (err) {
|
|
7
|
+
return { error: err.toString() };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default yaml;
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import { getFilterSQL, logger, pgClients, getMeta } from '@opengis/fastify-table/utils.js';
|
|
2
|
-
|
|
3
|
-
import { getWidget } from '../../../../utils.js';
|
|
4
|
-
|
|
5
|
-
import downloadClusterData from './utils/downloadClusterData.js';
|
|
6
|
-
|
|
7
|
-
const clusterExists = {};
|
|
8
|
-
|
|
9
|
-
export default async function cluster(req, reply) {
|
|
10
|
-
const { query = {} } = req;
|
|
11
|
-
const { widget, filter, dashboard, search } = query;
|
|
12
|
-
|
|
13
|
-
if (!widget) {
|
|
14
|
-
return { message: 'not enough params: widget', status: 400 };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const { pg = req.pg || pgClients.client, data, style, controls } = await getWidget({ pg: req.pg, dashboard, widget });
|
|
18
|
-
|
|
19
|
-
const pkey = pg.pk?.[data?.table];
|
|
20
|
-
|
|
21
|
-
if (!pkey) {
|
|
22
|
-
return {
|
|
23
|
-
message: `invalid ${widget ? 'widget' : 'dashboard'}: table pk not found (${data?.table})`,
|
|
24
|
-
status: 400,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// data param
|
|
29
|
-
const {
|
|
30
|
-
table,
|
|
31
|
-
query: where = '1=1',
|
|
32
|
-
metrics = [],
|
|
33
|
-
cluster,
|
|
34
|
-
clusterTable = {},
|
|
35
|
-
} = data;
|
|
36
|
-
|
|
37
|
-
if (!cluster) {
|
|
38
|
-
return {
|
|
39
|
-
message: `invalid ${widget ? 'widget' : 'dashboard'}: cluster column not specified`,
|
|
40
|
-
status: 400,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!metrics.length) {
|
|
45
|
-
return {
|
|
46
|
-
message: `invalid ${widget ? 'widget' : 'dashboard'}: metric columns not found`,
|
|
47
|
-
status: 400,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!clusterTable?.name) {
|
|
52
|
-
Object.assign(clusterTable, {
|
|
53
|
-
name: 'bi.cluster',
|
|
54
|
-
title: 'title',
|
|
55
|
-
query: `type='${cluster}'`,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
if (cluster && !clusterExists[cluster]) {
|
|
61
|
-
const res = await downloadClusterData({ pg, cluster });
|
|
62
|
-
if (res) return res;
|
|
63
|
-
clusterExists[cluster] = 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (clusterTable?.name && !pg.pk?.[clusterTable?.name]) {
|
|
67
|
-
return {
|
|
68
|
-
message: 'invalid widget params: clusterTable pkey not found',
|
|
69
|
-
status: 404,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const { bounds, extentStr } = await pg.query(`select count(*),
|
|
74
|
-
st_asgeojson(st_extent(geom))::json as bounds,
|
|
75
|
-
replace(regexp_replace(st_extent(geom)::box2d::text,'BOX\\(|\\)','','g'),' ',',') as "extentStr"
|
|
76
|
-
from ${table} where ${where || '1=1'}`).then((res) => res.rows?.[0] || {});
|
|
77
|
-
const extent = extentStr ? extentStr.split(',') : undefined;
|
|
78
|
-
|
|
79
|
-
// get sql
|
|
80
|
-
const { optimizedSQL } =
|
|
81
|
-
filter || search
|
|
82
|
-
? await getFilterSQL({ pg, table, filter, search })
|
|
83
|
-
: {};
|
|
84
|
-
|
|
85
|
-
const { columns = [] } = await getMeta({ pg, table });
|
|
86
|
-
const columnList = columns.map(el => el.name);
|
|
87
|
-
|
|
88
|
-
if (query.metric && typeof query.metric === 'string') {
|
|
89
|
-
const checkInvalid = query.metric.split(',').find(el => !columnList.includes(el) && el !== 'count');
|
|
90
|
-
if (checkInvalid) {
|
|
91
|
-
return reply.status(404).send(`invalid query metric value: ${checkInvalid}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const multipleMetrics = query.metric ? query.metric.split(',').map(el => el === 'count' ? 'count(*)' : `sum(${el.replace(/'/g, "''")})::float as ${el}`).join(',') : null;
|
|
96
|
-
const multipleMetricsOrder = query.metric ? query.metric.split(',').map(el => el === 'count' ? 'count(*)' : `sum(${el.replace(/'/g, "''")})::float`).join(',') : null;
|
|
97
|
-
const metricFunc = multipleMetrics
|
|
98
|
-
|| `${clusterTable?.operator || 'sum'}("${metrics[0]}")::float`;
|
|
99
|
-
|
|
100
|
-
const q = `select b.*, ${metricFunc} ${multipleMetrics ? '' : 'as metric'}
|
|
101
|
-
from ${optimizedSQL ? `(${optimizedSQL})` : table} q
|
|
102
|
-
left join lateral (select "${pg.pk?.[clusterTable?.name]}" as id, ${clusterTable?.column || cluster} as name, ${clusterTable?.title} as title from ${clusterTable?.name} where ${clusterTable?.codifierColumn || 'codifier'}=q."${clusterTable?.column || cluster}" limit 1)b on 1=1
|
|
103
|
-
where ${where} group by b.id, b.name, b.title order by ${multipleMetricsOrder || metricFunc} desc`;
|
|
104
|
-
|
|
105
|
-
if (query.sql === '1') return q;
|
|
106
|
-
|
|
107
|
-
// auto Index
|
|
108
|
-
// autoIndex({ table, columns: (metrics || []).concat([cluster]) });
|
|
109
|
-
|
|
110
|
-
const { rows = [] } = await pg.query(q);
|
|
111
|
-
const vals = rows.map((el) => el.metric - 0).sort((a, b) => a - b);
|
|
112
|
-
const len = vals.length;
|
|
113
|
-
const sizes = [
|
|
114
|
-
vals[0],
|
|
115
|
-
vals[Math.floor(len / 4)],
|
|
116
|
-
vals[Math.floor(len / 2)],
|
|
117
|
-
vals[Math.floor(len * 0.75)],
|
|
118
|
-
vals[len - 1],
|
|
119
|
-
];
|
|
120
|
-
return { sizes, style, controls, metrics, rows, columns: columns.map(({ name, title, dataTypeID }) => ({ name, title, type: pg.pgType[dataTypeID] })), bounds, extent, count: rows.length, total: rows?.reduce((acc, curr) => (curr.metric || 0) + acc, 0) };
|
|
121
|
-
} catch (err) {
|
|
122
|
-
logger.file('bi/cluster/error', { error: err.toString(), query });
|
|
123
|
-
return { error: err.toString(), status: 500 };
|
|
124
|
-
}
|
|
125
|
-
}
|
|
1
|
+
import { getFilterSQL, logger, pgClients, getMeta } from '@opengis/fastify-table/utils.js';
|
|
2
|
+
|
|
3
|
+
import { getWidget } from '../../../../utils.js';
|
|
4
|
+
|
|
5
|
+
import downloadClusterData from './utils/downloadClusterData.js';
|
|
6
|
+
|
|
7
|
+
const clusterExists = {};
|
|
8
|
+
|
|
9
|
+
export default async function cluster(req, reply) {
|
|
10
|
+
const { query = {} } = req;
|
|
11
|
+
const { widget, filter, dashboard, search } = query;
|
|
12
|
+
|
|
13
|
+
if (!widget) {
|
|
14
|
+
return { message: 'not enough params: widget', status: 400 };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { pg = req.pg || pgClients.client, data, style, controls } = await getWidget({ pg: req.pg, dashboard, widget });
|
|
18
|
+
|
|
19
|
+
const pkey = pg.pk?.[data?.table];
|
|
20
|
+
|
|
21
|
+
if (!pkey) {
|
|
22
|
+
return {
|
|
23
|
+
message: `invalid ${widget ? 'widget' : 'dashboard'}: table pk not found (${data?.table})`,
|
|
24
|
+
status: 400,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// data param
|
|
29
|
+
const {
|
|
30
|
+
table,
|
|
31
|
+
query: where = '1=1',
|
|
32
|
+
metrics = [],
|
|
33
|
+
cluster,
|
|
34
|
+
clusterTable = {},
|
|
35
|
+
} = data;
|
|
36
|
+
|
|
37
|
+
if (!cluster) {
|
|
38
|
+
return {
|
|
39
|
+
message: `invalid ${widget ? 'widget' : 'dashboard'}: cluster column not specified`,
|
|
40
|
+
status: 400,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!metrics.length) {
|
|
45
|
+
return {
|
|
46
|
+
message: `invalid ${widget ? 'widget' : 'dashboard'}: metric columns not found`,
|
|
47
|
+
status: 400,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!clusterTable?.name) {
|
|
52
|
+
Object.assign(clusterTable, {
|
|
53
|
+
name: 'bi.cluster',
|
|
54
|
+
title: 'title',
|
|
55
|
+
query: `type='${cluster}'`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
if (cluster && !clusterExists[cluster]) {
|
|
61
|
+
const res = await downloadClusterData({ pg, cluster });
|
|
62
|
+
if (res) return res;
|
|
63
|
+
clusterExists[cluster] = 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (clusterTable?.name && !pg.pk?.[clusterTable?.name]) {
|
|
67
|
+
return {
|
|
68
|
+
message: 'invalid widget params: clusterTable pkey not found',
|
|
69
|
+
status: 404,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const { bounds, extentStr } = await pg.query(`select count(*),
|
|
74
|
+
st_asgeojson(st_extent(geom))::json as bounds,
|
|
75
|
+
replace(regexp_replace(st_extent(geom)::box2d::text,'BOX\\(|\\)','','g'),' ',',') as "extentStr"
|
|
76
|
+
from ${table} where ${where || '1=1'}`).then((res) => res.rows?.[0] || {});
|
|
77
|
+
const extent = extentStr ? extentStr.split(',') : undefined;
|
|
78
|
+
|
|
79
|
+
// get sql
|
|
80
|
+
const { optimizedSQL } =
|
|
81
|
+
filter || search
|
|
82
|
+
? await getFilterSQL({ pg, table, filter, search })
|
|
83
|
+
: {};
|
|
84
|
+
|
|
85
|
+
const { columns = [] } = await getMeta({ pg, table });
|
|
86
|
+
const columnList = columns.map(el => el.name);
|
|
87
|
+
|
|
88
|
+
if (query.metric && typeof query.metric === 'string') {
|
|
89
|
+
const checkInvalid = query.metric.split(',').find(el => !columnList.includes(el) && el !== 'count');
|
|
90
|
+
if (checkInvalid) {
|
|
91
|
+
return reply.status(404).send(`invalid query metric value: ${checkInvalid}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const multipleMetrics = query.metric ? query.metric.split(',').map(el => el === 'count' ? 'count(*)' : `sum(${el.replace(/'/g, "''")})::float as ${el}`).join(',') : null;
|
|
96
|
+
const multipleMetricsOrder = query.metric ? query.metric.split(',').map(el => el === 'count' ? 'count(*)' : `sum(${el.replace(/'/g, "''")})::float`).join(',') : null;
|
|
97
|
+
const metricFunc = multipleMetrics
|
|
98
|
+
|| `${clusterTable?.operator || 'sum'}("${metrics[0]}")::float`;
|
|
99
|
+
|
|
100
|
+
const q = `select b.*, ${metricFunc} ${multipleMetrics ? '' : 'as metric'}
|
|
101
|
+
from ${optimizedSQL ? `(${optimizedSQL})` : table} q
|
|
102
|
+
left join lateral (select "${pg.pk?.[clusterTable?.name]}" as id, ${clusterTable?.column || cluster} as name, ${clusterTable?.title} as title from ${clusterTable?.name} where ${clusterTable?.codifierColumn || 'codifier'}=q."${clusterTable?.column || cluster}" limit 1)b on 1=1
|
|
103
|
+
where ${where} group by b.id, b.name, b.title order by ${multipleMetricsOrder || metricFunc} desc`;
|
|
104
|
+
|
|
105
|
+
if (query.sql === '1') return q;
|
|
106
|
+
|
|
107
|
+
// auto Index
|
|
108
|
+
// autoIndex({ table, columns: (metrics || []).concat([cluster]) });
|
|
109
|
+
|
|
110
|
+
const { rows = [] } = await pg.query(q);
|
|
111
|
+
const vals = rows.map((el) => el.metric - 0).sort((a, b) => a - b);
|
|
112
|
+
const len = vals.length;
|
|
113
|
+
const sizes = [
|
|
114
|
+
vals[0],
|
|
115
|
+
vals[Math.floor(len / 4)],
|
|
116
|
+
vals[Math.floor(len / 2)],
|
|
117
|
+
vals[Math.floor(len * 0.75)],
|
|
118
|
+
vals[len - 1],
|
|
119
|
+
];
|
|
120
|
+
return { sizes, style, controls, metrics, rows, columns: columns.map(({ name, title, dataTypeID }) => ({ name, title, type: pg.pgType[dataTypeID] })), bounds, extent, count: rows.length, total: rows?.reduce((acc, curr) => (curr.metric || 0) + acc, 0) };
|
|
121
|
+
} catch (err) {
|
|
122
|
+
logger.file('bi/cluster/error', { error: err.toString(), query });
|
|
123
|
+
return { error: err.toString(), status: 500 };
|
|
124
|
+
}
|
|
125
|
+
}
|