@opengis/fastify-table 2.4.1 → 2.4.2
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/README.md +86 -86
- package/dist/functions.js +20 -20
- package/dist/module/core/cls/constraint_action.json +9 -9
- package/dist/module/core/cls/constraint_matchtype.json +5 -5
- package/dist/module/core/cls/constraint_type_full.json +17 -17
- package/dist/module/core/cls/core.user_type.json +13 -13
- package/dist/module/core/pt/schemaItem.pt.hbs +17 -17
- package/dist/script/adduser +14 -14
- package/dist/script/dump.js +48 -48
- package/dist/script/dump.ts +216 -216
- package/dist/script/migrate.ts +41 -41
- package/dist/server/helpers/core/badge.js +1 -1
- package/dist/server/helpers/list/descriptionList.js +8 -8
- package/dist/server/helpers/list/tableList.js +4 -4
- package/dist/server/helpers/list/utils/button.js +1 -1
- package/dist/server/helpers/list/utils/buttonDel.js +3 -3
- package/dist/server/helpers/list/utils/buttonEdit.js +3 -3
- package/dist/server/helpers/utils/button.js +1 -1
- package/dist/server/helpers/utils/buttonAdd.js +15 -15
- package/dist/server/helpers/utils/buttonDel.js +11 -11
- package/dist/server/helpers/utils/buttonEdit.js +3 -3
- package/dist/server/migrations/0.sql +99 -99
- package/dist/server/migrations/cls.sql +105 -105
- package/dist/server/migrations/context.sql +136 -136
- package/dist/server/migrations/oauth.sql +79 -79
- package/dist/server/migrations/properties.sql +115 -115
- package/dist/server/migrations/roles.sql +195 -195
- package/dist/server/migrations/template.sql +43 -43
- package/dist/server/migrations/users.sql +151 -151
- package/dist/server/plugins/access/funcs/getUserPermissions.js +7 -7
- package/dist/server/plugins/auth/funcs/authorizeUser.js +4 -4
- package/dist/server/plugins/auth/funcs/getQuery.js +20 -20
- package/dist/server/plugins/crud/funcs/dataUpdate.js +7 -7
- package/dist/server/plugins/crud/funcs/getAccess.js +14 -14
- package/dist/server/plugins/crud/funcs/utils/getInsertQuery.js +6 -6
- package/dist/server/plugins/crud/funcs/utils/logChanges.js +18 -18
- package/dist/server/plugins/grpc/utils/convertp.proto +136 -136
- package/dist/server/plugins/grpc/utils/htmlTemplate.js +10 -10
- package/dist/server/plugins/grpc/utils/office2pdf.proto +13 -13
- package/dist/server/plugins/metric/loggerSystem.js +1 -1
- package/dist/server/plugins/pg/funcs/autoIndex.js +5 -5
- package/dist/server/plugins/pg/funcs/getMeta.js +10 -10
- package/dist/server/plugins/pg/funcs/init.js +36 -36
- package/dist/server/plugins/sqlite/funcs/init.js +22 -22
- package/dist/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +1 -1
- package/dist/server/plugins/table/funcs/getSelect.js +1 -1
- package/dist/server/plugins/table/funcs/gisIRColumn.js +3 -3
- package/dist/server/plugins/usercls/index.js +2 -2
- package/dist/server/routes/access/controllers/access.group.js +6 -6
- package/dist/server/routes/access/controllers/access.group.post.js +5 -5
- package/dist/server/routes/access/controllers/access.interface.js +14 -14
- package/dist/server/routes/access/controllers/access.user.js +6 -6
- package/dist/server/routes/auth/controllers/2factor/providers/totp.js +5 -5
- package/dist/server/routes/auth/controllers/2factor/qrcode.js +1 -1
- package/dist/server/routes/auth/controllers/2factor/recovery.js +1 -1
- package/dist/server/routes/auth/controllers/2factor/verify.js +1 -1
- package/dist/server/routes/auth/controllers/core/getUserInfo.js +33 -33
- package/dist/server/routes/auth/controllers/core/passwordRecovery.js +1 -1
- package/dist/server/routes/auth/controllers/core/registration.js +2 -2
- package/dist/server/routes/auth/controllers/page/login2faTemplate.js +1 -1
- package/dist/server/routes/file/controllers/resizeAll.js +6 -6
- package/dist/server/routes/grpc/controllers/file2geojson.js +13 -13
- package/dist/server/routes/menu/controllers/getMenu.js +9 -9
- package/dist/server/routes/notifications/controllers/readNotifications.js +4 -4
- package/dist/server/routes/notifications/controllers/userNotifications.js +3 -3
- package/dist/server/routes/table/controllers/card.js +1 -1
- package/dist/server/routes/table/controllers/filter.js +6 -6
- package/dist/server/routes/table/controllers/form.js +1 -1
- package/dist/server/routes/table/controllers/getFormByTable.js +6 -6
- package/dist/server/routes/table/controllers/suggest.js +3 -3
- package/dist/server/routes/table/controllers/tableData.js +2 -2
- package/dist/server/routes/table/controllers/tableInfo.js +10 -10
- package/dist/server/routes/table/functions/getData.js +13 -13
- package/dist/server/routes/widget/controllers/widget.get.js +33 -33
- package/dist/server/routes/widget/controllers/widget.set.js +3 -3
- package/dist/server/templates/page/2factor-recovery.html +101 -101
- package/dist/server/templates/page/2factor.html +140 -140
- package/dist/server/templates/page/login.html +90 -90
- package/dist/server/templates/page/loginEuSign.html +123 -123
- package/dist/server/templates/pt/recovery-codes-email-template.hbs +12 -12
- package/dist/server/templates/pt/recovery-password-email-template.html +20 -20
- package/package.json +98 -98
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
service Convert {
|
|
4
|
-
rpc csvToXls(csvToXlsParams) returns (FileBase64) {}
|
|
5
|
-
rpc jsonToXls(jsonToXlsParams) returns (FileBase64) {}
|
|
6
|
-
rpc pdfMerge(pdfMergeParams) returns (FileBase64) {}
|
|
7
|
-
rpc htmlToPdf(htmlToPdfParams) returns (FileBase64) {}
|
|
8
|
-
rpc excelToJson(excelToJsonParams) returns (FileBase64) {}
|
|
9
|
-
rpc xmlToJson(xmlToJsonParams) returns (FileBase64) {}
|
|
10
|
-
rpc htmlToDoc(htmlToDocParams) returns (FileBase64) {}
|
|
11
|
-
rpc htmlToImage(htmlToImageParams) returns (FileBase64) {}
|
|
12
|
-
rpc geojsonToShp(geojsonToShpParams) returns (FileBase64) {}
|
|
13
|
-
rpc shpToGeojson(shpToGeojsonParams) returns (FileBase64) {}
|
|
14
|
-
rpc docToPDF(docToPDFParams) returns (FileBase64) {}
|
|
15
|
-
rpc mergeImages(mergeImagesIn) returns (FileBase64) {}
|
|
16
|
-
rpc resizeImage(resizeImageIn) returns (FileBase64) {}
|
|
17
|
-
rpc jsonToYaml(jsonToYamlIn) returns (FileBase64) {}
|
|
18
|
-
rpc yamlToJson(yamlToJsonIn) returns (FileBase64) {}
|
|
19
|
-
rpc log(log_in) returns (log_out) {}
|
|
20
|
-
rpc geojsonToGpkg(geojsonToShpParams) returns (FileBase64) {}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
message jsonToYamlIn {
|
|
24
|
-
string json = 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
message yamlToJsonIn {
|
|
28
|
-
string yaml = 1;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
message resizeImageIn {
|
|
32
|
-
string base64 = 1;
|
|
33
|
-
uint64 width = 2;
|
|
34
|
-
uint64 height = 3;
|
|
35
|
-
uint32 quality = 4;
|
|
36
|
-
uint32 subsampling = 5;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
message pdfToImgIn {
|
|
40
|
-
string pdfPath = 1;
|
|
41
|
-
string imgPath = 2;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
message pdfToImgOut {
|
|
45
|
-
string imgPath = 1;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
message log_in {
|
|
49
|
-
uint32 rows = 1;
|
|
50
|
-
string level = 2;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
message log_out {
|
|
54
|
-
repeated string logs = 1;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
enum mergeImageFormat {
|
|
58
|
-
VERTICAL = 0;
|
|
59
|
-
HORIZONTAL = 1;
|
|
60
|
-
OVERLAY = 2;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
message imageMeta {
|
|
64
|
-
string base64 = 1;
|
|
65
|
-
mergeImageFormat mergeFormat = 2;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
message mergeImagesIn {
|
|
69
|
-
repeated string images = 1;
|
|
70
|
-
repeated imageMeta imagesMeta = 2;
|
|
71
|
-
string background = 3;
|
|
72
|
-
string mergeFormat = 4;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
message docToPDFParams {
|
|
76
|
-
string base64 = 1;
|
|
77
|
-
string to = 2;
|
|
78
|
-
string ext = 3;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
message shpToGeojsonParams {
|
|
82
|
-
string base64 = 1;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
message geojsonToShpParams {
|
|
86
|
-
string geojson = 1;
|
|
87
|
-
string proj = 2;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
message xmlToJsonParams {
|
|
91
|
-
string xml = 1;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
message jsonToXlsParams {
|
|
95
|
-
string json = 1;
|
|
96
|
-
string header = 2;
|
|
97
|
-
string subheader = 3;
|
|
98
|
-
string colmodel = 4;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
message csvToXlsParams {
|
|
102
|
-
string csv = 1;
|
|
103
|
-
string header = 2;
|
|
104
|
-
string subheader = 3;
|
|
105
|
-
string separator = 4;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
message excelToJsonParams {
|
|
109
|
-
string base64 = 1;
|
|
110
|
-
string type = 2;
|
|
111
|
-
string delimiter = 3;
|
|
112
|
-
string encoding = 4;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
message htmlToPdfParams {
|
|
116
|
-
string html = 1;
|
|
117
|
-
string pdfPageConfig = 2;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
message pdfMergeParams {
|
|
121
|
-
repeated string mergeFiles = 1;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
message htmlToImageParams {
|
|
125
|
-
string html = 1;
|
|
126
|
-
string format = 2;
|
|
127
|
-
uint64 width = 3;
|
|
128
|
-
uint64 height = 4;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
message htmlToDocParams {
|
|
132
|
-
string html = 1;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
message FileBase64 {
|
|
136
|
-
string result = 1;
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
service Convert {
|
|
4
|
+
rpc csvToXls(csvToXlsParams) returns (FileBase64) {}
|
|
5
|
+
rpc jsonToXls(jsonToXlsParams) returns (FileBase64) {}
|
|
6
|
+
rpc pdfMerge(pdfMergeParams) returns (FileBase64) {}
|
|
7
|
+
rpc htmlToPdf(htmlToPdfParams) returns (FileBase64) {}
|
|
8
|
+
rpc excelToJson(excelToJsonParams) returns (FileBase64) {}
|
|
9
|
+
rpc xmlToJson(xmlToJsonParams) returns (FileBase64) {}
|
|
10
|
+
rpc htmlToDoc(htmlToDocParams) returns (FileBase64) {}
|
|
11
|
+
rpc htmlToImage(htmlToImageParams) returns (FileBase64) {}
|
|
12
|
+
rpc geojsonToShp(geojsonToShpParams) returns (FileBase64) {}
|
|
13
|
+
rpc shpToGeojson(shpToGeojsonParams) returns (FileBase64) {}
|
|
14
|
+
rpc docToPDF(docToPDFParams) returns (FileBase64) {}
|
|
15
|
+
rpc mergeImages(mergeImagesIn) returns (FileBase64) {}
|
|
16
|
+
rpc resizeImage(resizeImageIn) returns (FileBase64) {}
|
|
17
|
+
rpc jsonToYaml(jsonToYamlIn) returns (FileBase64) {}
|
|
18
|
+
rpc yamlToJson(yamlToJsonIn) returns (FileBase64) {}
|
|
19
|
+
rpc log(log_in) returns (log_out) {}
|
|
20
|
+
rpc geojsonToGpkg(geojsonToShpParams) returns (FileBase64) {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
message jsonToYamlIn {
|
|
24
|
+
string json = 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message yamlToJsonIn {
|
|
28
|
+
string yaml = 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message resizeImageIn {
|
|
32
|
+
string base64 = 1;
|
|
33
|
+
uint64 width = 2;
|
|
34
|
+
uint64 height = 3;
|
|
35
|
+
uint32 quality = 4;
|
|
36
|
+
uint32 subsampling = 5;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message pdfToImgIn {
|
|
40
|
+
string pdfPath = 1;
|
|
41
|
+
string imgPath = 2;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message pdfToImgOut {
|
|
45
|
+
string imgPath = 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
message log_in {
|
|
49
|
+
uint32 rows = 1;
|
|
50
|
+
string level = 2;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
message log_out {
|
|
54
|
+
repeated string logs = 1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enum mergeImageFormat {
|
|
58
|
+
VERTICAL = 0;
|
|
59
|
+
HORIZONTAL = 1;
|
|
60
|
+
OVERLAY = 2;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
message imageMeta {
|
|
64
|
+
string base64 = 1;
|
|
65
|
+
mergeImageFormat mergeFormat = 2;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
message mergeImagesIn {
|
|
69
|
+
repeated string images = 1;
|
|
70
|
+
repeated imageMeta imagesMeta = 2;
|
|
71
|
+
string background = 3;
|
|
72
|
+
string mergeFormat = 4;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
message docToPDFParams {
|
|
76
|
+
string base64 = 1;
|
|
77
|
+
string to = 2;
|
|
78
|
+
string ext = 3;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
message shpToGeojsonParams {
|
|
82
|
+
string base64 = 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
message geojsonToShpParams {
|
|
86
|
+
string geojson = 1;
|
|
87
|
+
string proj = 2;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
message xmlToJsonParams {
|
|
91
|
+
string xml = 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
message jsonToXlsParams {
|
|
95
|
+
string json = 1;
|
|
96
|
+
string header = 2;
|
|
97
|
+
string subheader = 3;
|
|
98
|
+
string colmodel = 4;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
message csvToXlsParams {
|
|
102
|
+
string csv = 1;
|
|
103
|
+
string header = 2;
|
|
104
|
+
string subheader = 3;
|
|
105
|
+
string separator = 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
message excelToJsonParams {
|
|
109
|
+
string base64 = 1;
|
|
110
|
+
string type = 2;
|
|
111
|
+
string delimiter = 3;
|
|
112
|
+
string encoding = 4;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
message htmlToPdfParams {
|
|
116
|
+
string html = 1;
|
|
117
|
+
string pdfPageConfig = 2;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
message pdfMergeParams {
|
|
121
|
+
repeated string mergeFiles = 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
message htmlToImageParams {
|
|
125
|
+
string html = 1;
|
|
126
|
+
string format = 2;
|
|
127
|
+
uint64 width = 3;
|
|
128
|
+
uint64 height = 4;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
message htmlToDocParams {
|
|
132
|
+
string html = 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
message FileBase64 {
|
|
136
|
+
string result = 1;
|
|
137
137
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// TODO delete style when fully switch to the new code with merge
|
|
2
|
-
const createTemplate = ({ domain, html }) => `<!DOCTYPE html>\
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<base uri="http://${domain}/">
|
|
6
|
-
<meta charset="utf-8">
|
|
7
|
-
<style>html, body {font-size: 10pt !important;}</style>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
${html || ''}
|
|
11
|
-
</body>
|
|
2
|
+
const createTemplate = ({ domain, html }) => `<!DOCTYPE html>\
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<base uri="http://${domain}/">
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<style>html, body {font-size: 10pt !important;}</style>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
${html || ''}
|
|
11
|
+
</body>
|
|
12
12
|
</html`;
|
|
13
13
|
export default createTemplate;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
service OfficeConverterService {
|
|
4
|
-
rpc OfficeToPdf(OfficeToPdfRequest) returns (OfficeToPdfResponse) {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
message OfficeToPdfRequest {
|
|
8
|
-
string file = 1;
|
|
9
|
-
string ext = 2;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
message OfficeToPdfResponse {
|
|
13
|
-
string file = 1;
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
service OfficeConverterService {
|
|
4
|
+
rpc OfficeToPdf(OfficeToPdfRequest) returns (OfficeToPdfResponse) {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
message OfficeToPdfRequest {
|
|
8
|
+
string file = 1;
|
|
9
|
+
string ext = 2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
message OfficeToPdfResponse {
|
|
13
|
+
string file = 1;
|
|
14
14
|
}
|
|
@@ -12,7 +12,7 @@ const rclient2 = getRedis({ db: 2 });
|
|
|
12
12
|
// const rclient10 = getRedis({ db: 10 });
|
|
13
13
|
const filesFolder = getFolder(config);
|
|
14
14
|
const redisKey = "logger-process-online";
|
|
15
|
-
const sqlQuery = `select datname as dbname, application_name as app, client_addr as client_ip,
|
|
15
|
+
const sqlQuery = `select datname as dbname, application_name as app, client_addr as client_ip,
|
|
16
16
|
(now()-backend_start)::text as msec, state, query from pg_stat_activity where datname=$1`;
|
|
17
17
|
const prev = {};
|
|
18
18
|
const cpuUsage = () => {
|
|
@@ -43,7 +43,7 @@ export default async function autoIndex({ table, columns: filter1, pg = pgClient
|
|
|
43
43
|
}
|
|
44
44
|
const cols = tbs
|
|
45
45
|
? await pg
|
|
46
|
-
.query(`SELECT attrelid::regclass AS tbl, attname AS aname, atttypid::regtype AS datatype, atttypid
|
|
46
|
+
.query(`SELECT attrelid::regclass AS tbl, attname AS aname, atttypid::regtype AS datatype, atttypid
|
|
47
47
|
FROM pg_attribute WHERE attrelid::regclass::text = $1 and attname = any($2::text[])`, [tbs, attrs])
|
|
48
48
|
.then((el) => el.rows || [])
|
|
49
49
|
: [];
|
|
@@ -78,13 +78,13 @@ export default async function autoIndex({ table, columns: filter1, pg = pgClient
|
|
|
78
78
|
qIndex.push(`CREATE INDEX if not exists ${name}_lower ON ${el.nspname}.${el.relname} USING ${indexUsing} (lower(${el.aname}) ${suffix})`);
|
|
79
79
|
}
|
|
80
80
|
if (indexUsing === "gist") {
|
|
81
|
-
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "gist1")}
|
|
81
|
+
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "gist1")}
|
|
82
82
|
ON ${el.nspname}.${el.relname} USING gist (${el.aname})`);
|
|
83
|
-
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "area")}
|
|
83
|
+
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "area")}
|
|
84
84
|
ON ${el.nspname}.${el.relname} USING btree (st_area(st_transform(${el.aname},3857)))`);
|
|
85
|
-
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "area_true")}
|
|
85
|
+
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "area_true")}
|
|
86
86
|
ON ${el.nspname}.${el.relname} USING btree (st_area(${el.aname}, true))`);
|
|
87
|
-
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "4326")}
|
|
87
|
+
qIndex.push(`CREATE INDEX if not exists ${name.replace("gist", "4326")}
|
|
88
88
|
ON ${el.nspname}.${el.relname} USING gist (st_transform(${el.aname},4326))`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -21,9 +21,9 @@ export default async function getMeta(opt, nocache) {
|
|
|
21
21
|
}
|
|
22
22
|
const { fields = [] } = await pg.query(`select * from ${table} limit 0`);
|
|
23
23
|
const pks1 = await pg
|
|
24
|
-
.query(`SELECT json_object_agg(c.conrelid::regclass, a.attname) as pks1
|
|
25
|
-
FROM pg_constraint c
|
|
26
|
-
left join pg_attribute a on c.conrelid=a.attrelid and a.attnum = c.conkey[1]
|
|
24
|
+
.query(`SELECT json_object_agg(c.conrelid::regclass, a.attname) as pks1
|
|
25
|
+
FROM pg_constraint c
|
|
26
|
+
left join pg_attribute a on c.conrelid=a.attrelid and a.attnum = c.conkey[1]
|
|
27
27
|
WHERE c.contype='p'::"char" and c.conrelid::regclass = $1::regclass`, [table])
|
|
28
28
|
.then((el) => el.rows[0].pks1 || {});
|
|
29
29
|
const pk = table.startsWith("public.")
|
|
@@ -32,13 +32,13 @@ export default async function getMeta(opt, nocache) {
|
|
|
32
32
|
const geomColumns = fields.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry");
|
|
33
33
|
const geomAttr = geomColumns.find((el) => el.name === "geom_4326") || geomColumns[0];
|
|
34
34
|
const dbColumns = await pg
|
|
35
|
-
.query(`select json_object_agg(
|
|
36
|
-
attname,
|
|
37
|
-
json_build_object(
|
|
38
|
-
'title', pg_catalog.col_description(attrelid,attnum)
|
|
39
|
-
/*,'type', atttypid::regtype */
|
|
40
|
-
)
|
|
41
|
-
) from pg_catalog.pg_attribute a
|
|
35
|
+
.query(`select json_object_agg(
|
|
36
|
+
attname,
|
|
37
|
+
json_build_object(
|
|
38
|
+
'title', pg_catalog.col_description(attrelid,attnum)
|
|
39
|
+
/*,'type', atttypid::regtype */
|
|
40
|
+
)
|
|
41
|
+
) from pg_catalog.pg_attribute a
|
|
42
42
|
where attrelid=$1::regclass and attnum>0`, [table])
|
|
43
43
|
.then((el) => el.rows?.[0]?.json_object_agg || {});
|
|
44
44
|
fields.forEach((el) => Object.assign(el, { ...(dbColumns[el.name] || {}) }));
|
|
@@ -22,15 +22,15 @@ async function init(client) {
|
|
|
22
22
|
.query(`SELECT json_object_agg(t.oid:: text, pg_catalog.format_type(t.oid, NULL)) FROM pg_catalog.pg_type t`)
|
|
23
23
|
.then((el) => el.rows[0]?.json_object_agg || {});
|
|
24
24
|
const pks = await client
|
|
25
|
-
.query(`
|
|
26
|
-
SELECT
|
|
27
|
-
connamespace::regnamespace::text,
|
|
28
|
-
conrelid::regclass,
|
|
29
|
-
(
|
|
30
|
-
SELECT attname FROM pg_attribute WHERE attrelid = c.conrelid AND attnum = c.conkey[1]
|
|
31
|
-
) as pk
|
|
32
|
-
FROM pg_constraint c
|
|
33
|
-
WHERE contype = 'p'
|
|
25
|
+
.query(`
|
|
26
|
+
SELECT
|
|
27
|
+
connamespace::regnamespace::text,
|
|
28
|
+
conrelid::regclass,
|
|
29
|
+
(
|
|
30
|
+
SELECT attname FROM pg_attribute WHERE attrelid = c.conrelid AND attnum = c.conkey[1]
|
|
31
|
+
) as pk
|
|
32
|
+
FROM pg_constraint c
|
|
33
|
+
WHERE contype = 'p'
|
|
34
34
|
AND connamespace::regnamespace::text NOT IN ('sde')`)
|
|
35
35
|
.then((el) => el.rows || []);
|
|
36
36
|
const pk = pks.reduce((acc, curr) => ({
|
|
@@ -40,36 +40,36 @@ async function init(client) {
|
|
|
40
40
|
: curr.conrelid]: curr.pk,
|
|
41
41
|
}), {});
|
|
42
42
|
const tlist = await client
|
|
43
|
-
.query(`SELECT
|
|
44
|
-
array_agg(
|
|
45
|
-
(
|
|
46
|
-
SELECT
|
|
47
|
-
nspname
|
|
48
|
-
FROM
|
|
49
|
-
pg_namespace
|
|
50
|
-
WHERE
|
|
51
|
-
oid = relnamespace
|
|
52
|
-
) || '.' || relname
|
|
53
|
-
) tlist
|
|
54
|
-
FROM
|
|
55
|
-
pg_class
|
|
56
|
-
WHERE
|
|
43
|
+
.query(`SELECT
|
|
44
|
+
array_agg(
|
|
45
|
+
(
|
|
46
|
+
SELECT
|
|
47
|
+
nspname
|
|
48
|
+
FROM
|
|
49
|
+
pg_namespace
|
|
50
|
+
WHERE
|
|
51
|
+
oid = relnamespace
|
|
52
|
+
) || '.' || relname
|
|
53
|
+
) tlist
|
|
54
|
+
FROM
|
|
55
|
+
pg_class
|
|
56
|
+
WHERE
|
|
57
57
|
relkind IN ('r', 'v', 'm')`)
|
|
58
58
|
.then((d) => d.rows[0].tlist);
|
|
59
59
|
const rows = await client
|
|
60
|
-
.query(`SELECT
|
|
61
|
-
(
|
|
62
|
-
SELECT
|
|
63
|
-
nspname
|
|
64
|
-
FROM
|
|
65
|
-
pg_namespace
|
|
66
|
-
WHERE
|
|
67
|
-
oid = relnamespace
|
|
68
|
-
) || '.' || relname AS tname,
|
|
69
|
-
relkind
|
|
70
|
-
FROM
|
|
71
|
-
pg_class
|
|
72
|
-
WHERE
|
|
60
|
+
.query(`SELECT
|
|
61
|
+
(
|
|
62
|
+
SELECT
|
|
63
|
+
nspname
|
|
64
|
+
FROM
|
|
65
|
+
pg_namespace
|
|
66
|
+
WHERE
|
|
67
|
+
oid = relnamespace
|
|
68
|
+
) || '.' || relname AS tname,
|
|
69
|
+
relkind
|
|
70
|
+
FROM
|
|
71
|
+
pg_class
|
|
72
|
+
WHERE
|
|
73
73
|
relkind IN ('r', 'v', 'm')`)
|
|
74
74
|
.then((el) => el.rows || []);
|
|
75
75
|
const relkinds = rows.reduce((acc, curr) => Object.assign(acc, { [curr.tname]: curr.relkind }), {});
|
|
@@ -3,28 +3,28 @@ function init(client) {
|
|
|
3
3
|
if (!client) {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
6
|
-
const rows = client.prepare(`WITH tables AS (
|
|
7
|
-
SELECT name AS table_name
|
|
8
|
-
FROM sqlite_master
|
|
9
|
-
WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
|
|
10
|
-
),
|
|
11
|
-
pk_columns AS (
|
|
12
|
-
SELECT
|
|
13
|
-
m.name AS table_name,
|
|
14
|
-
ti.name AS column_name,
|
|
15
|
-
ti.pk
|
|
16
|
-
FROM sqlite_master m
|
|
17
|
-
JOIN pragma_table_info(m.name) AS ti
|
|
18
|
-
WHERE ti.pk = 1
|
|
19
|
-
)
|
|
20
|
-
SELECT table_name, column_name
|
|
21
|
-
FROM pk_columns
|
|
22
|
-
WHERE table_name IN (
|
|
23
|
-
SELECT table_name
|
|
24
|
-
FROM pk_columns
|
|
25
|
-
GROUP BY table_name
|
|
26
|
-
HAVING COUNT(*) = 1
|
|
27
|
-
)
|
|
6
|
+
const rows = client.prepare(`WITH tables AS (
|
|
7
|
+
SELECT name AS table_name
|
|
8
|
+
FROM sqlite_master
|
|
9
|
+
WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
|
|
10
|
+
),
|
|
11
|
+
pk_columns AS (
|
|
12
|
+
SELECT
|
|
13
|
+
m.name AS table_name,
|
|
14
|
+
ti.name AS column_name,
|
|
15
|
+
ti.pk
|
|
16
|
+
FROM sqlite_master m
|
|
17
|
+
JOIN pragma_table_info(m.name) AS ti
|
|
18
|
+
WHERE ti.pk = 1
|
|
19
|
+
)
|
|
20
|
+
SELECT table_name, column_name
|
|
21
|
+
FROM pk_columns
|
|
22
|
+
WHERE table_name IN (
|
|
23
|
+
SELECT table_name
|
|
24
|
+
FROM pk_columns
|
|
25
|
+
GROUP BY table_name
|
|
26
|
+
HAVING COUNT(*) = 1
|
|
27
|
+
)
|
|
28
28
|
ORDER BY table_name;`).all();
|
|
29
29
|
const pk = Object.fromEntries(rows.map((row) => [row.table_name, row.column_name]));
|
|
30
30
|
const tlist = client.prepare('SELECT name FROM sqlite_master WHERE type=\'table\' AND name NOT LIKE \'sqlite_%\';').all().reduce((acc, curr) => {
|
|
@@ -6,7 +6,7 @@ async function getCustomQuery({ pg, table, customFilter }) {
|
|
|
6
6
|
?.map((el) => el?.split("_").pop());
|
|
7
7
|
const customFilterSQL = pg?.pk?.["admin.properties"]
|
|
8
8
|
? await pg
|
|
9
|
-
.query(`select json_agg(json_build_object('id',property_id,'name',property_key,'query',property_text)
|
|
9
|
+
.query(`select json_agg(json_build_object('id',property_id,'name',property_key,'query',property_text)
|
|
10
10
|
) as property_json from admin.properties where property_key is not null and property_entity='customQuery' and object_id=$1`, [table])
|
|
11
11
|
.then((el) => el.rows?.[0]?.property_json || [])
|
|
12
12
|
: [];
|
|
@@ -4,7 +4,7 @@ import getTemplate from "./getTemplate.js";
|
|
|
4
4
|
const loadCls = {};
|
|
5
5
|
const sqls = {
|
|
6
6
|
sql: "select data from admin.user_cls where name=$1 union all select data from admin.cls where name=$1",
|
|
7
|
-
json: `select json_agg(json_build_object('id', code, 'text', name, 'icon', icon, 'color', color)) as data from admin.user_cls where parent=$1
|
|
7
|
+
json: `select json_agg(json_build_object('id', code, 'text', name, 'icon', icon, 'color', color)) as data from admin.user_cls where parent=$1
|
|
8
8
|
union all select json_agg(json_build_object('id', code, 'text', name, 'icon', icon, 'color', color)) as data from admin.cls where parent=$1`,
|
|
9
9
|
};
|
|
10
10
|
export default async function getSelect(name, pg = pgClients.client, nocache = false) {
|
|
@@ -18,7 +18,7 @@ export default async function gisIRColumn({ pg = pgClients.client, layer, column
|
|
|
18
18
|
custom,
|
|
19
19
|
});
|
|
20
20
|
const { tlist } = await pg
|
|
21
|
-
.query(`select array_agg((select nspname from pg_namespace where oid=relnamespace)||'.'||relname) tlist from pg_class
|
|
21
|
+
.query(`select array_agg((select nspname from pg_namespace where oid=relnamespace)||'.'||relname) tlist from pg_class
|
|
22
22
|
where relkind in ('r','v','m')`)
|
|
23
23
|
.then((el) => el.rows?.[0] || {});
|
|
24
24
|
const tableName = body?.table || layer;
|
|
@@ -33,9 +33,9 @@ export default async function gisIRColumn({ pg = pgClients.client, layer, column
|
|
|
33
33
|
const colField = pg.pgType?.[col.dataTypeID]?.includes("[]")
|
|
34
34
|
? `unnest(${column})`
|
|
35
35
|
: column;
|
|
36
|
-
const q = `select ${colField} as id, count(*)::int from (
|
|
36
|
+
const q = `select ${colField} as id, count(*)::int from (
|
|
37
37
|
${fData?.optimizedSQL ||
|
|
38
|
-
`select * from ${tableName} where ${body?.query || "true"}`}
|
|
38
|
+
`select * from ${tableName} where ${body?.query || "true"}`}
|
|
39
39
|
)t group by ${colField} order by count desc limit 15`;
|
|
40
40
|
if (sql)
|
|
41
41
|
return q;
|
|
@@ -139,9 +139,9 @@ export async function getUserClsList({ name, search, sql, custom, type, }, pg =
|
|
|
139
139
|
.filter(Boolean)
|
|
140
140
|
.join(" and ") || "1=1";
|
|
141
141
|
console.log(name, search, where);
|
|
142
|
-
const customQuery = `select true as custom, name, type, description, alias, case when type = 'sql' then 1 else (select count(*) from admin.user_cls where parent=t.name limit 1) end as count
|
|
142
|
+
const customQuery = `select true as custom, name, type, description, alias, case when type = 'sql' then 1 else (select count(*) from admin.user_cls where parent=t.name limit 1) end as count
|
|
143
143
|
from admin.user_cls t where parent is null and ${where} and ${typeStr ? `type='${typeStr}'` : "true"}`;
|
|
144
|
-
const gitQuery = `select false as custom, name, type, null as description, null as alias, case when type = 'sql' then 1 else (select count(*) from admin.cls where parent=t.name limit 1) end as count
|
|
144
|
+
const gitQuery = `select false as custom, name, type, null as description, null as alias, case when type = 'sql' then 1 else (select count(*) from admin.cls where parent=t.name limit 1) end as count
|
|
145
145
|
from admin.cls t where parent is null and ${where.replace(/admin.user_cls/g, "admin.cls")} and ${typeStr ? `type='${typeStr}'` : "true"}`;
|
|
146
146
|
const q = [
|
|
147
147
|
custom !== "0" ? customQuery : null,
|
|
@@ -10,18 +10,18 @@ export default async function accessGroup({ pg = pgClients.client, params, user
|
|
|
10
10
|
user,
|
|
11
11
|
});
|
|
12
12
|
const routes = await pg
|
|
13
|
-
.query(`select a.route_id as path, b.actions from admin.routes a
|
|
14
|
-
left join admin.role_access b on a.route_id=b.route_id
|
|
13
|
+
.query(`select a.route_id as path, b.actions from admin.routes a
|
|
14
|
+
left join admin.role_access b on a.route_id=b.route_id
|
|
15
15
|
where b.role_id=$1`, [params.id])
|
|
16
16
|
.then((el) => el.rows || []);
|
|
17
17
|
const resources = await pg
|
|
18
|
-
.query(`select resource_id, actions from admin.role_access
|
|
18
|
+
.query(`select resource_id, actions from admin.role_access
|
|
19
19
|
where resource_id is not null and role_id=$1`, [params.id])
|
|
20
20
|
.then((el) => el.rows || []);
|
|
21
21
|
const users = await pg
|
|
22
|
-
.query(`select user_uid as id, user_name as name, access_granted,
|
|
23
|
-
b.cdate as user_created, b.last_activity_date as last_activity from admin.user_roles a
|
|
24
|
-
left join admin.users b on a.user_uid=b.uid
|
|
22
|
+
.query(`select user_uid as id, user_name as name, access_granted,
|
|
23
|
+
b.cdate as user_created, b.last_activity_date as last_activity from admin.user_roles a
|
|
24
|
+
left join admin.users b on a.user_uid=b.uid
|
|
25
25
|
where a.role_id=$1`, [params.id])
|
|
26
26
|
.then((el) => el.rows || []);
|
|
27
27
|
return { routes, resources, users };
|
|
@@ -30,20 +30,20 @@ export default async function accessGroupPost({ pg = pgClients.client, params, u
|
|
|
30
30
|
.filter((el) => el.resource && el.actions)
|
|
31
31
|
.map((el) => pg.query("insert into admin.role_access(role_id,resource_id,route_id,actions) values ($1,$2,$3,$4)", [id, el.resource, el.path, el.actions])));
|
|
32
32
|
const rows = await pg
|
|
33
|
-
.query(`select a.route_id as path, b.actions as actions from admin.routes a
|
|
34
|
-
left join admin.role_access b on a.route_id=b.route_id
|
|
33
|
+
.query(`select a.route_id as path, b.actions as actions from admin.routes a
|
|
34
|
+
left join admin.role_access b on a.route_id=b.route_id
|
|
35
35
|
where b.role_id=$1`, [id])
|
|
36
36
|
.then((el) => el.rows || []);
|
|
37
37
|
const resources = await pg
|
|
38
|
-
.query(`select resource_id, actions from admin.role_access
|
|
38
|
+
.query(`select resource_id, actions from admin.role_access
|
|
39
39
|
where resource_id is not null and role_id=$1`, [id])
|
|
40
40
|
.then((el) => el.rows || []);
|
|
41
41
|
if (!users?.length) {
|
|
42
42
|
return reply.status(200).send({ id, routes: rows, resources });
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const q = `delete from admin.user_roles where role_id='${id.replace(/'/g, "''")}';
|
|
46
|
-
insert into admin.user_roles(role_id,user_uid,access_granted)
|
|
45
|
+
const q = `delete from admin.user_roles where role_id='${id.replace(/'/g, "''")}';
|
|
46
|
+
insert into admin.user_roles(role_id,user_uid,access_granted)
|
|
47
47
|
values ${users
|
|
48
48
|
.filter((el) => el?.id)
|
|
49
49
|
.map((el) => `('${id.replace(/'/g, "''")}','${el.id.replace(/'/g, "''")}','${user?.uid?.replace(/'/g, "''")}')`)}`;
|