@opengis/fastify-table 1.5.1 → 1.5.3
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/index.js +3 -2
- package/dist/server/plugins/grpc/utils/server/plugins/grpc/utils/convertp.proto +137 -0
- package/dist/server/plugins/grpc/utils/server/plugins/grpc/utils/office2pdf.proto +14 -0
- package/dist/server/plugins/policy/funcs/checkPolicy.js +9 -9
- package/dist/server/plugins/table/funcs/getColumnCLS.js +25 -0
- package/dist/server/routes/access/controllers/access.group.js +1 -0
- package/dist/server/routes/logger/index.js +7 -7
- package/dist/utils.js +1 -0
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -89,8 +89,9 @@ async function plugin(fastify, opt) {
|
|
|
89
89
|
loggerPlugin(fastify, opt);
|
|
90
90
|
if (config.rateLimit !== false) {
|
|
91
91
|
await fastify.register(import("@fastify/rate-limit"), {
|
|
92
|
-
max: config.rateLimit?.max || 100,
|
|
93
|
-
timeWindow: config.rateLimit?.timeWindow ||
|
|
92
|
+
max: parseInt(config.rateLimit?.max || 100),
|
|
93
|
+
timeWindow: config.rateLimit?.timeWindow || 60000,
|
|
94
|
+
hook: "preHandler",
|
|
94
95
|
global: true,
|
|
95
96
|
keyGenerator: (req) => `${req.ip}-${req.raw.url.split("?")[0]}`,
|
|
96
97
|
});
|
|
@@ -0,0 +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;
|
|
137
|
+
}
|
|
@@ -0,0 +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;
|
|
14
|
+
}
|
|
@@ -143,18 +143,18 @@ export default function checkPolicy(req, reply) {
|
|
|
143
143
|
return reply.status(403).send("access restricted: 4");
|
|
144
144
|
}
|
|
145
145
|
/* === 5. policy: site auth === */
|
|
146
|
-
if (!validToken && !policy.includes("site") && !isAdmin) {
|
|
146
|
+
/* if (!validToken && !policy.includes("site") && !isAdmin) {
|
|
147
147
|
logger.file("policy/site", {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
path,
|
|
149
|
+
method,
|
|
150
|
+
params,
|
|
151
|
+
query,
|
|
152
|
+
body,
|
|
153
|
+
message: "access restricted: 5",
|
|
154
|
+
uid: user?.uid,
|
|
155
155
|
});
|
|
156
156
|
return reply.status(403).send("access restricted: 5");
|
|
157
|
-
|
|
157
|
+
}*/
|
|
158
158
|
/* === 6. base policy: block non-public api w/ out authorization === */
|
|
159
159
|
if (!validToken && isAdmin && !config.debug && user?.uid && isServer) {
|
|
160
160
|
logger.file("policy/api", {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import loadTemplate from "./loadTemplate.js";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
async function getColumnCLSData(name) {
|
|
5
|
+
const exists = existsSync("module/cls.json");
|
|
6
|
+
const json = exists
|
|
7
|
+
? JSON.parse((await readFile("module/cls.json", "utf-8")) || "{}")
|
|
8
|
+
: {};
|
|
9
|
+
return name
|
|
10
|
+
? Object.keys(json)
|
|
11
|
+
.filter((key) => key.startsWith(`${name}.`))
|
|
12
|
+
.reduce((acc, curr) => ({
|
|
13
|
+
...acc,
|
|
14
|
+
[curr.replace(`${name}.`, "")]: json[curr],
|
|
15
|
+
}), {})
|
|
16
|
+
: json;
|
|
17
|
+
}
|
|
18
|
+
export default async function getColumnCLS(name) {
|
|
19
|
+
const key = [name, "column-cls"].filter(Boolean).join("-");
|
|
20
|
+
if (loadTemplate[key]) {
|
|
21
|
+
return loadTemplate[key];
|
|
22
|
+
}
|
|
23
|
+
loadTemplate[key] = await getColumnCLSData(name);
|
|
24
|
+
return loadTemplate[key];
|
|
25
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pgClients, getAdminAccess } from "../../../../utils.js";
|
|
2
2
|
export default async function accessGroup({ pg = pgClients.client, params, user = {}, unittest, }, reply) {
|
|
3
|
+
debugger;
|
|
3
4
|
if (!params?.id) {
|
|
4
5
|
return reply.status(400).send("not enough params: id");
|
|
5
6
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import loggerFile from
|
|
1
|
+
import loggerFile from "./controllers/logger.file.js";
|
|
2
2
|
// import loggerTest from './controllers/logger.test.api.js';
|
|
3
3
|
const loggerSchema = {
|
|
4
4
|
querystring: {
|
|
5
|
-
type:
|
|
5
|
+
type: "object",
|
|
6
6
|
properties: {
|
|
7
|
-
download: { type:
|
|
8
|
-
full: { type:
|
|
9
|
-
dir: { type:
|
|
10
|
-
token: { type:
|
|
7
|
+
download: { type: "string", pattern: "^(\\d)$" },
|
|
8
|
+
full: { type: "string", pattern: "^(\\d)$" },
|
|
9
|
+
dir: { type: "string", pattern: "^(\\d)$" },
|
|
10
|
+
token: { type: "string" },
|
|
11
11
|
},
|
|
12
12
|
additionalProperties: false,
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
async function plugin(app) {
|
|
16
|
-
app.get(
|
|
16
|
+
app.get("/logger-file/*", { config: { policy: ["public"], rateLimit: false }, schema: loggerSchema }, loggerFile);
|
|
17
17
|
}
|
|
18
18
|
export default plugin;
|
package/dist/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ export { default as redisClients } from "./server/plugins/redis/funcs/redisClien
|
|
|
19
19
|
// template
|
|
20
20
|
export { default as getTemplate } from "./server/plugins/table/funcs/getTemplate.js";
|
|
21
21
|
export { default as getTemplateSync } from "./server/plugins/table/funcs/getTemplateSync.js";
|
|
22
|
+
export { default as getColumnCLS } from "./server/plugins/table/funcs/getColumnCLS.js";
|
|
22
23
|
export { default as getTemplates } from "./server/plugins/table/funcs/getTemplates.js";
|
|
23
24
|
export { default as getTemplatePath } from "./server/plugins/table/funcs/getTemplatePath.js";
|
|
24
25
|
export { default as addTemplateDir } from "./server/plugins/table/funcs/addTemplateDir.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "core-plugins",
|
|
6
6
|
"keywords": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"prepublishOnly": "npm run build",
|
|
23
|
-
"build": "
|
|
23
|
+
"build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist/server/plugins/grpc/utils",
|
|
24
24
|
"patch": "npm version patch && git push && npm publish",
|
|
25
25
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
26
26
|
"test": "node --test",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@grpc/grpc-js": "1.10.6",
|
|
39
39
|
"@grpc/proto-loader": "0.7.12",
|
|
40
40
|
"better-sqlite3": "12.2.0",
|
|
41
|
+
"copyfiles": "^2.4.1",
|
|
41
42
|
"dotenv": "16.5.0",
|
|
42
43
|
"fastify": "5.3.3",
|
|
43
44
|
"fastify-plugin": "5.0.1",
|
|
@@ -64,7 +65,8 @@
|
|
|
64
65
|
"eslint": "^9.35.0",
|
|
65
66
|
"eslint-config-airbnb-extended": "^2.3.1",
|
|
66
67
|
"ts-migrate": "^0.1.35",
|
|
67
|
-
"typescript": "^5.9.2"
|
|
68
|
+
"typescript": "^5.9.2",
|
|
69
|
+
"vitest": "^3.2.4"
|
|
68
70
|
},
|
|
69
71
|
"author": "Softpro",
|
|
70
72
|
"license": "ISC"
|