@opengis/fastify-table 1.4.7 → 1.4.9
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/config.js +1 -0
- package/index.js +5 -0
- package/package.json +8 -2
- package/server/plugins/file/downloadFile.js +18 -0
- package/server/plugins/file/getExport.js +38 -0
- package/server/plugins/file/isFileExists.js +17 -0
- package/server/plugins/file/providers/fs.js +100 -0
- package/server/plugins/file/providers/index.d.ts +49 -0
- package/server/plugins/file/providers/index.js +37 -0
- package/server/plugins/file/providers/mime/index.js +12 -0
- package/server/plugins/file/providers/mime/mimes.js +1180 -0
- package/server/plugins/file/providers/s3/client.js +41 -0
- package/server/plugins/file/providers/s3/funcs/downloadFile.js +50 -0
- package/server/plugins/file/providers/s3/funcs/fileExists.js +32 -0
- package/server/plugins/file/providers/s3/funcs/uploadFile.js +38 -0
- package/server/plugins/file/providers/s3/funcs/utils/getS3FilePath.js +23 -0
- package/server/plugins/file/providers/s3/index.js +12 -0
- package/server/plugins/file/providers/utils/getDataSize.js +20 -0
- package/server/plugins/file/providers/utils/getValidData.js +32 -0
- package/server/plugins/file/providers/utils/handlers/dataTypes.js +8 -0
- package/server/plugins/file/providers/utils/handlers/index.js +53 -0
- package/server/plugins/file/providers/utils/handlers/sizeHandlers.js +11 -0
- package/server/plugins/file/providers/utils/streamToBuffer.js +8 -0
- package/server/plugins/file/providers/utils/typeguards/isArray.js +3 -0
- package/server/plugins/file/providers/utils/typeguards/isBuffer.js +3 -0
- package/server/plugins/file/providers/utils/typeguards/isPath.js +5 -0
- package/server/plugins/file/providers/utils/typeguards/isReadableStream.js +8 -0
- package/server/plugins/file/providers/utils/typeguards/isText.js +3 -0
- package/server/plugins/file/uploadFile.js +19 -0
- package/server/plugins/file/uploadMultiPart.js +63 -0
- package/server/plugins/file/utils/allowedExtensions.js +25 -0
- package/server/plugins/file/utils/getFileType.js +10 -0
- package/server/plugins/file/utils/getPath.js +25 -0
- package/server/plugins/file/utils/isFileExists.js +15 -0
- package/server/plugins/file/utils/uploadFileDisk.js +87 -0
- package/server/plugins/grpc/file2json.js +54 -0
- package/server/plugins/grpc/grpc.js +295 -0
- package/server/plugins/grpc/office2pdf.js +68 -0
- package/server/plugins/grpc/utils/convertp.proto +137 -0
- package/server/plugins/grpc/utils/csv2xls.js +8 -0
- package/server/plugins/grpc/utils/excel2Json.js +8 -0
- package/server/plugins/grpc/utils/html2doc.js +19 -0
- package/server/plugins/grpc/utils/html2img.js +18 -0
- package/server/plugins/grpc/utils/html2pdf.js +23 -0
- package/server/plugins/grpc/utils/htmlTemplate.js +14 -0
- package/server/plugins/grpc/utils/json2xls.js +13 -0
- package/server/plugins/grpc/utils/mergePdf.js +20 -0
- package/server/plugins/grpc/utils/office2pdf.proto +14 -0
- package/server/plugins/table/funcs/getData.js +9 -3
- package/server/routes/file/controllers/delete.js +108 -0
- package/server/routes/file/controllers/download.js +66 -0
- package/server/routes/file/controllers/export.js +283 -0
- package/server/routes/file/controllers/files.js +72 -0
- package/server/routes/file/controllers/resize.js +90 -0
- package/server/routes/file/controllers/resizeAll.js +164 -0
- package/server/routes/file/controllers/upload.js +53 -0
- package/server/routes/file/controllers/uploadImage.js +47 -0
- package/server/routes/file/controllers/utils/convertJSONToCSV.js +36 -0
- package/server/routes/file/controllers/utils/convertJSONToXls.js +44 -0
- package/server/routes/file/controllers/utils/formatResult.js +17 -0
- package/server/routes/file/index.mjs +26 -0
- package/server/routes/file/schema.js +16 -0
- package/server/routes/grpc/controllers/file2geojson.js +60 -0
- package/server/routes/grpc/controllers/filePreview.js +89 -0
- package/server/routes/grpc/index.mjs +12 -0
- package/server/routes/table/controllers/cardData.js +10 -4
- package/server/routes/table/controllers/tableData.js +5 -5
- package/server/routes/table/functions/getData.js +21 -11
- package/utils.js +30 -2
|
@@ -19,7 +19,7 @@ const defaultLimit = 20;
|
|
|
19
19
|
|
|
20
20
|
export default async function dataAPI(req, reply, called) {
|
|
21
21
|
const {
|
|
22
|
-
pg = pgClients.client, params, query = {}, user = {}, contextQuery, sufix = true,
|
|
22
|
+
pg = pgClients.client, params, headers = {}, query = {}, user = {}, contextQuery, sufix = true,
|
|
23
23
|
} = req;
|
|
24
24
|
|
|
25
25
|
const time = Date.now();
|
|
@@ -64,15 +64,27 @@ export default async function dataAPI(req, reply, called) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const id = tokenData?.id || hookData?.id || params?.id;
|
|
67
|
-
const { actions = [], query: accessQuery } = await getAccess({
|
|
67
|
+
const { actions = [], query: accessQuery } = await getAccess({
|
|
68
|
+
table: tokenData?.table || hookData?.table || params.table, id, user,
|
|
69
|
+
}, pg) || {};
|
|
68
70
|
|
|
69
71
|
if (!actions.includes('view') && !config?.local && !called) {
|
|
70
72
|
return reply.status(403).send('access restricted');
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
const body = loadTable || hookData || tokenData;
|
|
76
|
+
|
|
73
77
|
const {
|
|
74
|
-
table, columns = [], sql, cardSql,
|
|
75
|
-
} = loadTable || tokenData || params;
|
|
78
|
+
table, columns = [], sql, cardSql, form, meta, sqlColumns, public: ispublic, editable = false,
|
|
79
|
+
} = loadTable || hookData || tokenData || params;
|
|
80
|
+
|
|
81
|
+
const filters = ((body?.filter_list || [])
|
|
82
|
+
.concat(body?.filterInline || [])
|
|
83
|
+
.concat(body?.filterCustom || [])
|
|
84
|
+
.concat(body?.filterState || [])
|
|
85
|
+
.concat(body?.filterList || [])
|
|
86
|
+
.concat(body?.filters || [])
|
|
87
|
+
).filter(el => el.id || el.name);
|
|
76
88
|
|
|
77
89
|
const tableMeta = await getMeta({ pg, table });
|
|
78
90
|
timeArr.push(Date.now());
|
|
@@ -119,13 +131,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
const objectId = tokenData?.id || hookData?.id || params.id;
|
|
122
|
-
const isdefault = !objectId ? (
|
|
123
|
-
.concat(loadTable?.filterInline || [])
|
|
124
|
-
.concat(loadTable?.filterCustom || [])
|
|
125
|
-
.concat(loadTable?.filterState || [])
|
|
126
|
-
.concat(loadTable?.filterList || [])
|
|
127
|
-
.concat(loadTable?.filters || [])
|
|
128
|
-
.find(el => el.default) : null;
|
|
134
|
+
const isdefault = !objectId ? filters.find(el => el.default) : null;
|
|
129
135
|
|
|
130
136
|
const checkFilter = [query.filter, query.search, query.state, query.custom, isdefault].filter((el) => el).length;
|
|
131
137
|
|
|
@@ -186,6 +192,10 @@ export default async function dataAPI(req, reply, called) {
|
|
|
186
192
|
throw new Error(err.toString());
|
|
187
193
|
});
|
|
188
194
|
|
|
195
|
+
if (!rows.length && headers?.referer?.includes?.('/card/')) {
|
|
196
|
+
return reply.status(403).send('access restricted: empty rows');
|
|
197
|
+
}
|
|
198
|
+
|
|
189
199
|
timeArr.push(Date.now());
|
|
190
200
|
|
|
191
201
|
if (uid && rows.length && !config.security?.disableToken && (editable || actions.includes('edit') || actions.includes('del'))) {
|
package/utils.js
CHANGED
|
@@ -72,7 +72,7 @@ import config from './config.js';
|
|
|
72
72
|
import dblist from './dblist.js';
|
|
73
73
|
import redactionList from './redactionList.js';
|
|
74
74
|
import eventStream from './server/plugins/util/funcs/eventStream.js';
|
|
75
|
-
import isFileExists from './server/plugins/crud/funcs/isFileExists.js';
|
|
75
|
+
// import isFileExists from './server/plugins/crud/funcs/isFileExists.js';
|
|
76
76
|
import getFolder from './server/plugins/crud/funcs/utils/getFolder.js';
|
|
77
77
|
|
|
78
78
|
import logChanges from './server/plugins/crud/funcs/utils/logChanges.js';
|
|
@@ -86,6 +86,21 @@ import mdToHTML from './server/plugins/md/funcs/mdToHTML.js';
|
|
|
86
86
|
import flattenObject from './server/plugins/util/funcs/flattenObject.js';
|
|
87
87
|
import unflattenObject from './server/plugins/util/funcs/unflattenObject.js';
|
|
88
88
|
|
|
89
|
+
// file
|
|
90
|
+
import isFileExists from './server/plugins/file/isFileExists.js';
|
|
91
|
+
import downloadFile from './server/plugins/file/downloadFile.js';
|
|
92
|
+
import uploadFile from './server/plugins/file/uploadFile.js';
|
|
93
|
+
import uploadMultiPart from './server/plugins/file/uploadMultiPart.js';
|
|
94
|
+
import getMimeType from './server/plugins/file/providers/mime/index.js';
|
|
95
|
+
import getFileType from './server/plugins/file/utils/getFileType.js';
|
|
96
|
+
import allowedExtensions from './server/plugins/file/utils/allowedExtensions.js';
|
|
97
|
+
|
|
98
|
+
// grpc
|
|
99
|
+
import grpc from './server/plugins/grpc/grpc.js';
|
|
100
|
+
import file2json from './server/plugins/grpc/file2json.js';
|
|
101
|
+
import officeConverter from './server/plugins/grpc/office2pdf.js';
|
|
102
|
+
import getExport from './server/plugins/file/getExport.js';
|
|
103
|
+
|
|
89
104
|
export default null;
|
|
90
105
|
export {
|
|
91
106
|
config,
|
|
@@ -101,7 +116,7 @@ export {
|
|
|
101
116
|
getRedis,
|
|
102
117
|
redisClients,
|
|
103
118
|
logger,
|
|
104
|
-
isFileExists,
|
|
119
|
+
// isFileExists,
|
|
105
120
|
eventStream,
|
|
106
121
|
|
|
107
122
|
// hook
|
|
@@ -166,4 +181,17 @@ export {
|
|
|
166
181
|
|
|
167
182
|
flattenObject,
|
|
168
183
|
unflattenObject,
|
|
184
|
+
|
|
185
|
+
// file
|
|
186
|
+
isFileExists,
|
|
187
|
+
downloadFile,
|
|
188
|
+
uploadFile,
|
|
189
|
+
uploadMultiPart,
|
|
190
|
+
file2json,
|
|
191
|
+
grpc,
|
|
192
|
+
getMimeType,
|
|
193
|
+
getFileType,
|
|
194
|
+
getExport,
|
|
195
|
+
officeConverter,
|
|
196
|
+
allowedExtensions,
|
|
169
197
|
};
|