@opengis/bi 1.0.15 → 1.0.16

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.
Files changed (49) hide show
  1. package/README.md +50 -50
  2. package/config.js +12 -12
  3. package/dist/bi.js +1 -1
  4. package/dist/bi.umd.cjs +63 -63
  5. package/dist/{import-file-CRC0sYYT.js → import-file-BqdbrKVj.js} +7591 -7587
  6. package/dist/{map-component-mixin-BCtWEvzv.js → map-component-mixin-BeW3TYyl.js} +2115 -3794
  7. package/dist/style.css +1 -1
  8. package/dist/{vs-calendar-5ot79n0N.js → vs-calendar-CnosX1Ss.js} +1 -1
  9. package/dist/{vs-funnel-bar-CLo6gXI_.js → vs-funnel-bar-CcXr5oIQ.js} +1 -1
  10. package/dist/{vs-heatmap-DHGA8dRk.js → vs-heatmap-DvOx7wot.js} +1 -1
  11. package/dist/{vs-map-pIn5wS4G.js → vs-map-C2KEv_W6.js} +2 -2
  12. package/dist/{vs-map-cluster-CNgX6JVF.js → vs-map-cluster-DJpEG5n8.js} +2 -2
  13. package/dist/{vs-number-DYfok8VU.js → vs-number-C23hqXxA.js} +1 -1
  14. package/dist/{vs-text-Dckykz09.js → vs-text-COR-T0yn.js} +2 -2
  15. package/package.json +107 -107
  16. package/plugin.js +14 -14
  17. package/server/migrations/bi.dataset.sql +26 -26
  18. package/server/migrations/bi.sql +93 -93
  19. package/server/plugins/docs.js +48 -48
  20. package/server/plugins/hook.js +89 -89
  21. package/server/plugins/vite.js +69 -69
  22. package/server/routes/dashboard/controllers/dashboard.delete.js +38 -38
  23. package/server/routes/dashboard/controllers/dashboard.js +118 -118
  24. package/server/routes/dashboard/controllers/dashboard.list.js +30 -30
  25. package/server/routes/dashboard/controllers/utils/yaml.js +11 -11
  26. package/server/routes/dashboard/index.mjs +25 -25
  27. package/server/routes/data/controllers/data.js +167 -167
  28. package/server/routes/data/controllers/util/chartSQL.js +42 -42
  29. package/server/routes/data/controllers/util/normalizeData.js +59 -59
  30. package/server/routes/data/index.mjs +29 -29
  31. package/server/routes/dataset/index.mjs +19 -19
  32. package/server/routes/db/controllers/dbTablePreview.js +63 -63
  33. package/server/routes/db/controllers/dbTables.js +36 -36
  34. package/server/routes/db/index.mjs +17 -17
  35. package/server/routes/edit/controllers/dashboard.add.js +26 -26
  36. package/server/routes/edit/controllers/dashboard.edit.js +46 -46
  37. package/server/routes/edit/controllers/widget.add.js +75 -75
  38. package/server/routes/edit/controllers/widget.del.js +69 -69
  39. package/server/routes/edit/controllers/widget.edit.js +52 -52
  40. package/server/routes/edit/index.mjs +31 -31
  41. package/server/routes/map/controllers/cluster.js +109 -109
  42. package/server/routes/map/controllers/clusterVtile.js +166 -166
  43. package/server/routes/map/controllers/geojson.js +127 -127
  44. package/server/routes/map/controllers/map.js +60 -60
  45. package/server/routes/map/controllers/utils/downloadClusterData.js +42 -42
  46. package/server/routes/map/controllers/vtile.js +183 -183
  47. package/server/routes/map/index.mjs +25 -25
  48. package/server/utils/getWidget.js +85 -85
  49. package/utils.js +12 -12
@@ -1,85 +1,85 @@
1
- import { getTemplate, pgClients } from '@opengis/fastify-table/utils.js';
2
-
3
- const pg = pgClients.client;
4
-
5
- async function getWidget({ dashboard, widget }) {
6
- if (!dashboard && !widget) {
7
- return { message: `not enough params: dashboard / widget`, status: 400 };
8
- }
9
- const dashboardData = dashboard
10
- ? await getTemplate('dashboard', dashboard)
11
- : null;
12
-
13
- const { id, tableName } =
14
- !dashboardData && pg.pk['bi.dashboard'] && dashboard
15
- ? await pg
16
- .query(
17
- `select dashboard_id as id, table_name as "tableName" from bi.dashboard where $1 in (dashboard_id, name)`,
18
- [dashboard]
19
- )
20
- .then((res1) => res1.rows?.[0] || {})
21
- : {};
22
-
23
- if (!dashboardData && dashboard && !id) {
24
- return { message: `dashboard not found: ${dashboard}`, status: 404 };
25
- }
26
-
27
- dashboardData?.forEach((el) => {
28
- el[2] = el[0].split('.')[0];
29
- });
30
- const dashboardIndex = dashboardData?.find((el) => el[2] == 'index')?.[1];
31
-
32
- const widgetData = dashboard
33
- ? dashboardData?.find((el) => el[2] === (widget || 'index'))?.[1]
34
- : await getTemplate('widget', widget);
35
- if (typeof widgetData === 'string') {
36
- return { source: widgetData, status: 200 };
37
- }
38
- if (!id && !dashboardData && !widgetData) {
39
- return { message: `not found ${widget} ${dashboard}`, status: 404 };
40
- }
41
-
42
- const q = `select *, coalesce(data::jsonb, '{}'::jsonb) || jsonb_build_object('table', table_name) as data from bi.widget where dashboard_id=$1 and name=$2`;
43
-
44
- const {
45
- type,
46
- text,
47
- data = {},
48
- controls,
49
- style,
50
- options,
51
- yml
52
- } = widgetData ||
53
- (await pg
54
- .query(q, [id || dashboard, widget])
55
- .then((res1) => res1.rows?.[0] || {}));
56
-
57
- if (!type) {
58
- return { message: `widget not found: ${widget}`, status: 404 };
59
- }
60
-
61
- Object.assign(data, {
62
- table:
63
- data.table ||
64
- tableName ||
65
- widgetData?.table_name ||
66
- dashboardIndex?.table ||
67
- dashboardIndex?.table_name,
68
- db: dashboardIndex?.db || pgClients.client?.options?.database,
69
- });
70
- const main = { ...(dashboardIndex || {}), ...widgetData, ...data, ...data?.data || {} };
71
-
72
- if (!main?.table) {
73
- return {
74
- message: /* json.error || */ `invalid ${widget ? 'widget' : 'dashboard'}: 1`,
75
- status: 404,
76
- };
77
- }
78
-
79
- const tableSQL = main?.sql?.map(
80
- (el, i) => `left join lateral(${el})t${i + 1} on 1=1`
81
- );
82
-
83
- return { ...main, tableSQL, data, type, text, controls, style, options, yml };
84
- }
85
- export default getWidget;
1
+ import { getTemplate, pgClients } from '@opengis/fastify-table/utils.js';
2
+
3
+ const pg = pgClients.client;
4
+
5
+ async function getWidget({ dashboard, widget }) {
6
+ if (!dashboard && !widget) {
7
+ return { message: `not enough params: dashboard / widget`, status: 400 };
8
+ }
9
+ const dashboardData = dashboard
10
+ ? await getTemplate('dashboard', dashboard)
11
+ : null;
12
+
13
+ const { id, tableName } =
14
+ !dashboardData && pg.pk['bi.dashboard'] && dashboard
15
+ ? await pg
16
+ .query(
17
+ `select dashboard_id as id, table_name as "tableName" from bi.dashboard where $1 in (dashboard_id, name)`,
18
+ [dashboard]
19
+ )
20
+ .then((res1) => res1.rows?.[0] || {})
21
+ : {};
22
+
23
+ if (!dashboardData && dashboard && !id) {
24
+ return { message: `dashboard not found: ${dashboard}`, status: 404 };
25
+ }
26
+
27
+ dashboardData?.forEach((el) => {
28
+ el[2] = el[0].split('.')[0];
29
+ });
30
+ const dashboardIndex = dashboardData?.find((el) => el[2] == 'index')?.[1];
31
+
32
+ const widgetData = dashboard
33
+ ? dashboardData?.find((el) => el[2] === (widget || 'index'))?.[1]
34
+ : await getTemplate('widget', widget);
35
+ if (typeof widgetData === 'string') {
36
+ return { source: widgetData, status: 200 };
37
+ }
38
+ if (!id && !dashboardData && !widgetData) {
39
+ return { message: `not found ${widget} ${dashboard}`, status: 404 };
40
+ }
41
+
42
+ const q = `select *, coalesce(data::jsonb, '{}'::jsonb) || jsonb_build_object('table', table_name) as data from bi.widget where dashboard_id=$1 and name=$2`;
43
+
44
+ const {
45
+ type,
46
+ text,
47
+ data = {},
48
+ controls,
49
+ style,
50
+ options,
51
+ yml
52
+ } = widgetData ||
53
+ (await pg
54
+ .query(q, [id || dashboard, widget])
55
+ .then((res1) => res1.rows?.[0] || {}));
56
+
57
+ if (!type) {
58
+ return { message: `widget not found: ${widget}`, status: 404 };
59
+ }
60
+
61
+ Object.assign(data, {
62
+ table:
63
+ data.table ||
64
+ tableName ||
65
+ widgetData?.table_name ||
66
+ dashboardIndex?.table ||
67
+ dashboardIndex?.table_name,
68
+ db: dashboardIndex?.db || pgClients.client?.options?.database,
69
+ });
70
+ const main = { ...(dashboardIndex || {}), ...widgetData, ...data, ...data?.data || {} };
71
+
72
+ if (!main?.table) {
73
+ return {
74
+ message: /* json.error || */ `invalid ${widget ? 'widget' : 'dashboard'}: 1`,
75
+ status: 404,
76
+ };
77
+ }
78
+
79
+ const tableSQL = main?.sql?.map(
80
+ (el, i) => `left join lateral(${el})t${i + 1} on 1=1`
81
+ );
82
+
83
+ return { ...main, tableSQL, data, type, text, controls, style, options, yml };
84
+ }
85
+ export default getWidget;
package/utils.js CHANGED
@@ -1,12 +1,12 @@
1
- // This file contains code that we reuse
2
- // between our tests.
3
-
4
- // import getTemplatePath from '@opengis/fastify-table/table/controllers/utils/getTemplatePath.js';
5
- import getWidget from './server/utils/getWidget.js';
6
- import yamlSafe from './server/routes/dashboard/controllers/utils/yaml.js';
7
-
8
- export {
9
- // getTemplatePath,
10
- yamlSafe,
11
- getWidget,
12
- };
1
+ // This file contains code that we reuse
2
+ // between our tests.
3
+
4
+ // import getTemplatePath from '@opengis/fastify-table/table/controllers/utils/getTemplatePath.js';
5
+ import getWidget from './server/utils/getWidget.js';
6
+ import yamlSafe from './server/routes/dashboard/controllers/utils/yaml.js';
7
+
8
+ export {
9
+ // getTemplatePath,
10
+ yamlSafe,
11
+ getWidget,
12
+ };