@opengis/bi 1.1.2 → 1.2.1
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 +11 -2
- package/dist/bi.umd.cjs +72 -720
- package/dist/import-file-D06AZEtP.js +3493 -0
- package/dist/style.css +1 -7
- package/dist/{vs-funnel-bar-mWZ8lvEq.js → vs-funnel-bar-C8m-602x.js} +11 -11
- package/dist/vs-list-BJ0NjSm5.js +525 -0
- package/dist/vs-map-PLlJqaaW.js +294 -0
- package/dist/vs-map-cluster-9tV6eiDA.js +356 -0
- package/dist/{vs-number-CRUhHKym.js → vs-number-B2V_BPer.js} +3 -3
- package/dist/{vs-table-OddIdr1s.js → vs-table-WGE9jyDq.js} +6 -6
- package/dist/vs-text-DkLKRC7F.js +1528 -0
- package/package.json +77 -84
- package/plugin.js +13 -13
- package/server/plugins/vite.js +69 -69
- package/server/routes/dashboard/controllers/utils/yaml.js +11 -11
- package/server/routes/data/controllers/data.js +7 -6
- package/server/routes/data/controllers/util/chartSQL.js +2 -2
- 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/server/utils/getWidget.js +3 -3
- package/utils.js +12 -12
- package/config.js +0 -12
- package/dist/import-file-XFI3CaVb.js +0 -63458
- package/dist/vs-donut-al85JwBt.js +0 -148
- package/dist/vs-list-1QDnN3pH.js +0 -18510
- package/dist/vs-map-CwR6ZYur.js +0 -285
- package/dist/vs-map-cluster-YdXTBIVf.js +0 -314
- package/dist/vs-text-CQ9vn0qO.js +0 -40
package/package.json
CHANGED
|
@@ -1,84 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opengis/bi",
|
|
3
|
-
"version": "1.1
|
|
4
|
-
"description": "BI data visualization module",
|
|
5
|
-
"main": "dist/bi.js",
|
|
6
|
-
"browser": "dist/bi.umd.cjs",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist
|
|
10
|
-
"server
|
|
11
|
-
"plugin.js",
|
|
12
|
-
"utils.js"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"debug": "node --watch-path=server server",
|
|
17
|
-
"dev": "vite",
|
|
18
|
-
"type-check": "vue-tsc --noEmit",
|
|
19
|
-
"build": "vite build",
|
|
20
|
-
"build-app": "cross-env APP=true vite build",
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"format": "prettier --write .",
|
|
23
|
-
"test": "node --test",
|
|
24
|
-
"test21": "node --test ./test/plugins/*",
|
|
25
|
-
"start": "node server.js",
|
|
26
|
-
"prod": "
|
|
27
|
-
"docs:i": "npm install --prefix ./docs",
|
|
28
|
-
"docs:dev": "npm run --prefix ./docs docs:dev",
|
|
29
|
-
"docs:build": "npm run --prefix ./docs docs:build",
|
|
30
|
-
"docs:preview": "npm run --prefix ./docs docs:preview",
|
|
31
|
-
"adduser": "node script/adduser.js"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [
|
|
34
|
-
"bi",
|
|
35
|
-
"data visualization",
|
|
36
|
-
"chart",
|
|
37
|
-
"opengis",
|
|
38
|
-
"vue",
|
|
39
|
-
"fastify"
|
|
40
|
-
],
|
|
41
|
-
"author": "Softpro",
|
|
42
|
-
"license": "ISC",
|
|
43
|
-
"dependencies": {
|
|
44
|
-
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@opengis/fastify-table": "
|
|
49
|
-
"@opengis/v3-core": "^0.3.93",
|
|
50
|
-
"@opengis/v3-filter": "^0.0.71",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"echarts": "^5.5.1",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"eslint": "
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"globals": "^15.10.0",
|
|
79
|
-
"prettier": "^3.3.3",
|
|
80
|
-
"typescript": "^5.4.5",
|
|
81
|
-
"typescript-eslint": "~8.8.1",
|
|
82
|
-
"vue-tsc": "^2.1.6"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@opengis/bi",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "BI data visualization module",
|
|
5
|
+
"main": "dist/bi.js",
|
|
6
|
+
"browser": "dist/bi.umd.cjs",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"server",
|
|
11
|
+
"plugin.js",
|
|
12
|
+
"utils.js"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"debug": "node --watch-path=server server",
|
|
17
|
+
"dev": "vite",
|
|
18
|
+
"type-check": "vue-tsc --noEmit",
|
|
19
|
+
"build": "vite build",
|
|
20
|
+
"build-app": "cross-env APP=true vite build",
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"format": "prettier --write .",
|
|
23
|
+
"test": "node --test",
|
|
24
|
+
"test21": "node --test ./test/plugins/*",
|
|
25
|
+
"start": "node server.js",
|
|
26
|
+
"prod": "NODE_ENV=production npm run start",
|
|
27
|
+
"docs:i": "npm install --prefix ./docs",
|
|
28
|
+
"docs:dev": "npm run --prefix ./docs docs:dev",
|
|
29
|
+
"docs:build": "npm run --prefix ./docs docs:build",
|
|
30
|
+
"docs:preview": "npm run --prefix ./docs docs:preview",
|
|
31
|
+
"adduser": "node script/adduser.js"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"bi",
|
|
35
|
+
"data visualization",
|
|
36
|
+
"chart",
|
|
37
|
+
"opengis",
|
|
38
|
+
"vue",
|
|
39
|
+
"fastify"
|
|
40
|
+
],
|
|
41
|
+
"author": "Softpro",
|
|
42
|
+
"license": "ISC",
|
|
43
|
+
"dependencies": {},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@highlightjs/vue-plugin": "github:highlightjs/vue-plugin",
|
|
46
|
+
"@jspreadsheet-ce/vue": "^5.0.0",
|
|
47
|
+
"@mapbox/sphericalmercator": "^1.2.0",
|
|
48
|
+
"@opengis/fastify-table": "^2.0.33",
|
|
49
|
+
"@opengis/v3-core": "^0.3.93",
|
|
50
|
+
"@opengis/v3-filter": "^0.0.71",
|
|
51
|
+
"cross-env": "^10.1.0",
|
|
52
|
+
"@turf/turf": "^7.1.0",
|
|
53
|
+
"axios": "^1.3.1",
|
|
54
|
+
"echarts": "^5.5.1",
|
|
55
|
+
"highlight.js": "^11.10.0",
|
|
56
|
+
"marked": "^14.1.2",
|
|
57
|
+
"vite": "^5.1.5",
|
|
58
|
+
"vue": "^3.4.27",
|
|
59
|
+
"vue-router": "^4.4.3",
|
|
60
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
61
|
+
"@eslint/js": "^9.12.0",
|
|
62
|
+
"@types/echarts": "^4.9.22",
|
|
63
|
+
"@types/node": "^22.7.5",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
65
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
66
|
+
"eslint": "^8.57.1",
|
|
67
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
68
|
+
"eslint-config-prettier": "^9.1.0",
|
|
69
|
+
"eslint-plugin-vue": "^9.29.0",
|
|
70
|
+
"globals": "^15.10.0",
|
|
71
|
+
"prettier": "^3.3.3",
|
|
72
|
+
"sass-embedded": "1.89.2",
|
|
73
|
+
"typescript": "^5.4.5",
|
|
74
|
+
"typescript-eslint": "~8.8.1",
|
|
75
|
+
"vue-tsc": "^2.1.6"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/plugin.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import fp from 'fastify-plugin';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
2
|
+
// import path from 'node:path';
|
|
3
|
+
// import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
|
-
import { config, addTemplateDir, execMigrations } from '@opengis/fastify-table/utils.js';
|
|
5
|
+
//import { config, addTemplateDir, execMigrations } from '@opengis/fastify-table/utils.js';
|
|
6
6
|
|
|
7
|
-
const fileName = fileURLToPath(import.meta.url);
|
|
8
|
-
const dirName = path.dirname(fileName);
|
|
7
|
+
//const fileName = fileURLToPath(import.meta.url);
|
|
8
|
+
// const dirName = path.dirname(fileName);
|
|
9
9
|
|
|
10
10
|
async function plugin(fastify, opt) {
|
|
11
|
-
fastify.register(import('./server/routes/dashboard/index.mjs'),
|
|
12
|
-
fastify.register(import('./server/routes/dataset/index.mjs'),
|
|
11
|
+
fastify.register(import('./server/routes/dashboard/index.mjs'), opt);
|
|
12
|
+
fastify.register(import('./server/routes/dataset/index.mjs'), opt);
|
|
13
13
|
|
|
14
|
-
fastify.register(import('./server/routes/data/index.mjs'),
|
|
15
|
-
fastify.register(import('./server/routes/edit/index.mjs'),
|
|
16
|
-
fastify.register(import('./server/routes/map/index.mjs'),
|
|
17
|
-
config.templates?.forEach(el => addTemplateDir(el));
|
|
14
|
+
fastify.register(import('./server/routes/data/index.mjs'), opt);
|
|
15
|
+
fastify.register(import('./server/routes/edit/index.mjs'), opt);
|
|
16
|
+
fastify.register(import('./server/routes/map/index.mjs'), opt);
|
|
17
|
+
// config.templates?.forEach(el => addTemplateDir(el));
|
|
18
18
|
|
|
19
|
-
const dir = path.join(dirName, 'server/migrations');
|
|
20
|
-
execMigrations(dir).catch(err => console.log(err));
|
|
19
|
+
// const dir = path.join(dirName, 'server/migrations');
|
|
20
|
+
// execMigrations(dir).catch(err => console.log(err));
|
|
21
21
|
}
|
|
22
22
|
export default fp(plugin);
|
package/server/plugins/vite.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import config from '../../config.js';
|
|
4
|
-
|
|
5
|
-
const { disableAuth } = config;
|
|
6
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
|
7
|
-
|
|
8
|
-
async function plugin(fastify) {
|
|
9
|
-
// vite server
|
|
10
|
-
if (!isProduction) {
|
|
11
|
-
const vite = await import('vite');
|
|
12
|
-
|
|
13
|
-
const viteServer = await vite.createServer({
|
|
14
|
-
server: {
|
|
15
|
-
middlewareMode: true,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
// hot reload
|
|
19
|
-
viteServer.watcher.on('all', (d, t) => {
|
|
20
|
-
if (!t.includes('module') && !t.includes('templates')) return;
|
|
21
|
-
// console.log(d, t);
|
|
22
|
-
viteServer.ws.send({ type: 'full-reload' });
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// this is middleware for vite's dev servert
|
|
26
|
-
fastify.addHook('onRequest', async (req, reply) => {
|
|
27
|
-
// const { user } = req.session?.passport || {};
|
|
28
|
-
const next = () => new Promise((resolve) => {
|
|
29
|
-
viteServer.middlewares(req.raw, reply.raw, () => resolve());
|
|
30
|
-
});
|
|
31
|
-
await next();
|
|
32
|
-
});
|
|
33
|
-
fastify.get('*', async () => {});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// From Build
|
|
38
|
-
fastify.get('*', async (req, reply) => {
|
|
39
|
-
// console.log(disableAuth)
|
|
40
|
-
if (!req.user && !disableAuth) return reply.redirect('/login');
|
|
41
|
-
const stream = fs.createReadStream('dist/index.html');
|
|
42
|
-
return reply
|
|
43
|
-
.headers({ 'Cache-Control': 'public, no-cache' })
|
|
44
|
-
.type('text/html')
|
|
45
|
-
.send(stream);
|
|
46
|
-
});
|
|
47
|
-
fastify.get('/assets/:file', async (req, reply) => {
|
|
48
|
-
const stream = fs.createReadStream(`dist/assets/${req.params.file}`);
|
|
49
|
-
const ext = path.extname(req.params.file);
|
|
50
|
-
const mime = {
|
|
51
|
-
'.js': 'text/javascript',
|
|
52
|
-
'.css': 'text/css',
|
|
53
|
-
'.woff2': 'application/font-woff',
|
|
54
|
-
'.png': 'image/png',
|
|
55
|
-
}[ext];
|
|
56
|
-
// reply.cacheControl('max-age', '1d');
|
|
57
|
-
return mime
|
|
58
|
-
? reply
|
|
59
|
-
.headers({
|
|
60
|
-
'Cache-Control': 'public, max-age=3600',
|
|
61
|
-
'Content-Encoding': 'identity',
|
|
62
|
-
})
|
|
63
|
-
.type(mime)
|
|
64
|
-
.send(stream)
|
|
65
|
-
: stream;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default plugin;
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import config from '../../config.js';
|
|
4
|
+
|
|
5
|
+
const { disableAuth } = config;
|
|
6
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
7
|
+
|
|
8
|
+
async function plugin(fastify) {
|
|
9
|
+
// vite server
|
|
10
|
+
if (!isProduction) {
|
|
11
|
+
const vite = await import('vite');
|
|
12
|
+
|
|
13
|
+
const viteServer = await vite.createServer({
|
|
14
|
+
server: {
|
|
15
|
+
middlewareMode: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
// hot reload
|
|
19
|
+
viteServer.watcher.on('all', (d, t) => {
|
|
20
|
+
if (!t.includes('module') && !t.includes('templates')) return;
|
|
21
|
+
// console.log(d, t);
|
|
22
|
+
viteServer.ws.send({ type: 'full-reload' });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// this is middleware for vite's dev servert
|
|
26
|
+
fastify.addHook('onRequest', async (req, reply) => {
|
|
27
|
+
// const { user } = req.session?.passport || {};
|
|
28
|
+
const next = () => new Promise((resolve) => {
|
|
29
|
+
viteServer.middlewares(req.raw, reply.raw, () => resolve());
|
|
30
|
+
});
|
|
31
|
+
await next();
|
|
32
|
+
});
|
|
33
|
+
fastify.get('*', async () => {});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// From Build
|
|
38
|
+
fastify.get('*', async (req, reply) => {
|
|
39
|
+
// console.log(disableAuth)
|
|
40
|
+
if (!req.user && !disableAuth) return reply.redirect('/login');
|
|
41
|
+
const stream = fs.createReadStream('dist/index.html');
|
|
42
|
+
return reply
|
|
43
|
+
.headers({ 'Cache-Control': 'public, no-cache' })
|
|
44
|
+
.type('text/html')
|
|
45
|
+
.send(stream);
|
|
46
|
+
});
|
|
47
|
+
fastify.get('/assets/:file', async (req, reply) => {
|
|
48
|
+
const stream = fs.createReadStream(`dist/assets/${req.params.file}`);
|
|
49
|
+
const ext = path.extname(req.params.file);
|
|
50
|
+
const mime = {
|
|
51
|
+
'.js': 'text/javascript',
|
|
52
|
+
'.css': 'text/css',
|
|
53
|
+
'.woff2': 'application/font-woff',
|
|
54
|
+
'.png': 'image/png',
|
|
55
|
+
}[ext];
|
|
56
|
+
// reply.cacheControl('max-age', '1d');
|
|
57
|
+
return mime
|
|
58
|
+
? reply
|
|
59
|
+
.headers({
|
|
60
|
+
'Cache-Control': 'public, max-age=3600',
|
|
61
|
+
'Content-Encoding': 'identity',
|
|
62
|
+
})
|
|
63
|
+
.type(mime)
|
|
64
|
+
.send(stream)
|
|
65
|
+
: stream;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default plugin;
|
|
@@ -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;
|
|
@@ -35,19 +35,20 @@ export default async function dataAPI(req, reply) {
|
|
|
35
35
|
|
|
36
36
|
const pg = widgetData.pg || req.pg || pgClients.client;
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const error1 = {};
|
|
39
|
+
const { fields: cols = [] } = await pg.query(
|
|
39
40
|
`select * from ${data.table} t ${widgetData.tableSQL || data.tableSQL || ''} limit 0`
|
|
40
|
-
);
|
|
41
|
-
const columnTypes = cols
|
|
41
|
+
).catch(err => Object.assign(error1, { error: err.toString() })) || {};
|
|
42
|
+
const columnTypes = cols?.map?.((el) => ({
|
|
42
43
|
name: el.name,
|
|
43
44
|
type: pg.pgType?.[el.dataTypeID],
|
|
44
45
|
}));
|
|
45
46
|
|
|
46
47
|
// data param
|
|
47
|
-
const { x, cls, groupbyCls, metric, table, where, tableSQL, groupby, xName, yName, xType, yType, error } =
|
|
48
|
+
const { x, cls, groupbyCls, metric, table, where, tableSQL, groupby, xName, yName, xType, yType, error = error1 } =
|
|
48
49
|
normalizeData(widgetData, query, columnTypes);
|
|
49
50
|
|
|
50
|
-
if (error) { return reply.status(400).send(error); }
|
|
51
|
+
// if (error) { return reply.status(400).send(error); }
|
|
51
52
|
|
|
52
53
|
// auto Index
|
|
53
54
|
if (pg.pk?.[data.table]) {
|
|
@@ -187,7 +188,7 @@ export default async function dataAPI(req, reply) {
|
|
|
187
188
|
|
|
188
189
|
const res = {
|
|
189
190
|
time: Date.now() - time,
|
|
190
|
-
error: errorSql || (!widgetData.sql ? widgetData.error : undefined),
|
|
191
|
+
error: error || errorSql || (!widgetData.sql ? widgetData.error : undefined),
|
|
191
192
|
dimensions,
|
|
192
193
|
filter: xName,
|
|
193
194
|
dimensionsType: [xType, yType].filter((el) => el)?.length
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function number({ metric, where, table, samples }) {
|
|
2
|
-
const sql = `select ${metric} from ${table} where ${where} ${samples ? 'limit 10' : ''}`;
|
|
1
|
+
function number({ metric, where, table, samples, fx }) {
|
|
2
|
+
const sql = `select ${fx || metric} from ${table} where ${where} ${samples ? 'limit 10' : ''}`;
|
|
3
3
|
return sql;
|
|
4
4
|
}
|
|
5
5
|
function table({ columns = [], table, where, samples }) {
|