@opengis/fastify-table 2.3.5 → 2.3.6
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.d.ts.map +1 -1
- package/dist/index.js +30 -9
- package/dist/server/plugins/upload/startUpload.d.ts.map +1 -1
- package/dist/server/plugins/upload/startUpload.js +14 -4
- package/dist/server/plugins/upload/uploadChunk.d.ts.map +1 -1
- package/dist/server/plugins/upload/uploadChunk.js +6 -2
- package/dist/server/routes/access/index.d.ts.map +1 -1
- package/dist/server/routes/access/index.js +10 -6
- package/dist/server/routes/auth/index.d.ts +1 -2
- package/dist/server/routes/auth/index.d.ts.map +1 -1
- package/dist/server/routes/auth/index.js +4 -3
- package/dist/server/routes/cron/index.js +1 -1
- package/dist/server/routes/crud/index.d.ts.map +1 -1
- package/dist/server/routes/crud/index.js +14 -4
- package/dist/server/routes/dblist/index.d.ts.map +1 -1
- package/dist/server/routes/dblist/index.js +5 -3
- package/dist/server/routes/file/index.d.ts.map +1 -1
- package/dist/server/routes/file/index.js +10 -7
- package/dist/server/routes/grpc/index.d.ts.map +1 -1
- package/dist/server/routes/grpc/index.js +3 -2
- package/dist/server/routes/logger/index.d.ts.map +1 -1
- package/dist/server/routes/logger/index.js +4 -2
- package/dist/server/routes/menu/index.d.ts.map +1 -1
- package/dist/server/routes/menu/index.js +9 -2
- package/dist/server/routes/notifications/index.d.ts +1 -2
- package/dist/server/routes/notifications/index.d.ts.map +1 -1
- package/dist/server/routes/notifications/index.js +3 -1
- package/dist/server/routes/properties/index.d.ts.map +1 -1
- package/dist/server/routes/properties/index.js +4 -7
- package/dist/server/routes/table/index.d.ts.map +1 -1
- package/dist/server/routes/table/index.js +15 -13
- package/dist/server/routes/templates/index.d.ts.map +1 -1
- package/dist/server/routes/templates/index.js +2 -1
- package/dist/server/routes/upload/index.d.ts.map +1 -1
- package/dist/server/routes/upload/index.js +23 -5
- package/dist/server/routes/usercls/index.d.ts.map +1 -1
- package/dist/server/routes/usercls/index.js +12 -5
- package/dist/server/routes/util/controllers/api.list.d.ts +19 -0
- package/dist/server/routes/util/controllers/api.list.d.ts.map +1 -0
- package/dist/server/routes/util/controllers/api.list.js +58 -0
- package/dist/server/routes/util/index.d.ts.map +1 -1
- package/dist/server/routes/util/index.js +8 -7
- package/dist/server/routes/widget/index.d.ts.map +1 -1
- package/dist/server/routes/widget/index.js +3 -2
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA8FA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,iBAoMjC;;AACD,wBAEG"}
|
package/dist/index.js
CHANGED
|
@@ -56,6 +56,7 @@ import uploadChunkRoutes from "./server/routes/upload/index.js";
|
|
|
56
56
|
import grpcRoutes from "./server/routes/grpc/index.js";
|
|
57
57
|
import notificationsRoutes from "./server/routes/notifications/index.js";
|
|
58
58
|
import userClsRoutes from "./server/routes/usercls/index.js";
|
|
59
|
+
import apiListService from "./server/routes/util/controllers/api.list.js";
|
|
59
60
|
addHook("preForm", preForm);
|
|
60
61
|
addHook("afterTable", afterTable);
|
|
61
62
|
addHook("preTemplate", preTemplate);
|
|
@@ -70,16 +71,35 @@ async function plugin(fastify) {
|
|
|
70
71
|
reply.header("Access-Control-Allow-Origin", "*");
|
|
71
72
|
});
|
|
72
73
|
}
|
|
74
|
+
const apiListSchema = {
|
|
75
|
+
querystring: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties: {
|
|
78
|
+
package: { type: "string" },
|
|
79
|
+
subdir: { type: "string" },
|
|
80
|
+
md: { type: "string" },
|
|
81
|
+
tags: { type: "string" },
|
|
82
|
+
exclude_tags: { type: "string" },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
73
86
|
if (!fastify.hasRoute({ method: "GET", url: "/api/list" })) {
|
|
74
|
-
fastify.get(`${opt.prefix
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
fastify.get(`${opt.prefix || "/api"}/list`, {
|
|
88
|
+
config: { tags: ["core", "util"], role: "admin" },
|
|
89
|
+
schema: apiListSchema,
|
|
90
|
+
}, function apiList(req, reply) {
|
|
91
|
+
const result = apiListService({
|
|
92
|
+
includeTags: req.query.tags,
|
|
93
|
+
excludeTags: req.query.exclude_tags,
|
|
94
|
+
packageName: req.query.package,
|
|
95
|
+
subdir: req.query.subdir,
|
|
96
|
+
md: req.query.md,
|
|
97
|
+
routes,
|
|
98
|
+
});
|
|
99
|
+
if (result.headers) {
|
|
100
|
+
return reply.headers(result.headers).send(result.data);
|
|
81
101
|
}
|
|
82
|
-
return
|
|
102
|
+
return result;
|
|
83
103
|
});
|
|
84
104
|
}
|
|
85
105
|
fastify.addHook("onRoute", (r) => {
|
|
@@ -96,9 +116,10 @@ async function plugin(fastify) {
|
|
|
96
116
|
r.config.package = r.config.package || "fastify-table";
|
|
97
117
|
routes.push({
|
|
98
118
|
method,
|
|
99
|
-
|
|
119
|
+
endpoint: r.url,
|
|
100
120
|
subdir: r.config?.subdir,
|
|
101
121
|
package: r.config?.package,
|
|
122
|
+
tags: Array.isArray(r.config?.tags) ? r.config?.tags : undefined,
|
|
102
123
|
description: r.config?.description,
|
|
103
124
|
query,
|
|
104
125
|
roles: r.config?.role?.split?.("|"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startUpload.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/startUpload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startUpload.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/startUpload.ts"],"names":[],"mappings":"AAmBA,wBAA8B,WAAW,CAAC,EACxC,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,gBA4FA"}
|
|
@@ -6,6 +6,7 @@ import getUploadStatus from "./getUploadStatus.js";
|
|
|
6
6
|
import { prefix, fileDir, metaDir, uploadChunkDirectory, fetchTimeoutMs, } from "./index.js";
|
|
7
7
|
import mimes from "../file/providers/mime/mimes.js";
|
|
8
8
|
import { startUpload as startUploadS3 } from "./s3.js";
|
|
9
|
+
const { chunkSize = 5242880 } = config;
|
|
9
10
|
export default async function startUpload({ host, id, fileName, size, subdir, }) {
|
|
10
11
|
if (subdir && (typeof subdir !== "string" || subdir.includes(".."))) {
|
|
11
12
|
return {
|
|
@@ -20,14 +21,19 @@ export default async function startUpload({ host, id, fileName, size, subdir, })
|
|
|
20
21
|
.join(uploadChunkDirectory, subdir || "")
|
|
21
22
|
.replace(/\\/g, "/");
|
|
22
23
|
if (config.s3) {
|
|
23
|
-
const filepath = path.posix.join(config.folder ||
|
|
24
|
+
const filepath = path.posix.join(config.folder || "", relativeDirpath, `${id1}.${extension}`);
|
|
24
25
|
const { UploadId } = await startUploadS3({
|
|
25
26
|
Bucket: config.s3?.containerName || "work",
|
|
26
27
|
Key: filepath[0] === "/" ? filepath?.slice(1) : filepath,
|
|
27
28
|
ContentType: mimes[extension],
|
|
28
29
|
fileSize: size,
|
|
29
30
|
});
|
|
30
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
id: UploadId,
|
|
33
|
+
UploadId,
|
|
34
|
+
provider: "s3",
|
|
35
|
+
chunkSize,
|
|
36
|
+
};
|
|
31
37
|
}
|
|
32
38
|
const key = id1.split("-").pop();
|
|
33
39
|
const meta = {
|
|
@@ -57,10 +63,14 @@ export default async function startUpload({ host, id, fileName, size, subdir, })
|
|
|
57
63
|
subdir,
|
|
58
64
|
metaPath: undefined,
|
|
59
65
|
relativeDirpath,
|
|
60
|
-
provider: "fs"
|
|
66
|
+
provider: "fs",
|
|
61
67
|
};
|
|
62
68
|
await writeFile(path.join(metaDir, `${id1}.json`), JSON.stringify(metaData, null, 2));
|
|
63
|
-
return {
|
|
69
|
+
return {
|
|
70
|
+
...meta,
|
|
71
|
+
metaPath: undefined,
|
|
72
|
+
chunkSize,
|
|
73
|
+
};
|
|
64
74
|
}
|
|
65
75
|
const res = await fetch(`${host}/${prefix}/start`, {
|
|
66
76
|
method: "POST",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadChunk.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/uploadChunk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadChunk.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/uploadChunk.ts"],"names":[],"mappings":"AAuBA,wBAA8B,WAAW,CAAC,EACxC,IAAI,EACJ,EAAE,EACF,IAAI,EACJ,MAAM,EACN,GAAG,EACH,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,gBA4IA"}
|
|
@@ -7,11 +7,15 @@ import uploadFile from "../file/uploadFile.js";
|
|
|
7
7
|
import applyHook from "../hook/applyHook.js";
|
|
8
8
|
import getFileSize from "../file/getFileSize.js";
|
|
9
9
|
import { finishUpload as finishUploadS3, uploadChunk as uploadChunkS3, getUploadStatus as getUploadStatusS3, findUpload as findUploadS3, } from "./s3.js";
|
|
10
|
+
const { chunkSize = 5242880 } = config;
|
|
10
11
|
export default async function uploadChunk({ host, id, body, offset, end, size, }) {
|
|
11
12
|
if (!host) {
|
|
12
13
|
if (config.s3) {
|
|
13
|
-
const partNumber = Math.floor(offset /
|
|
14
|
-
const { fileSize } = await findUploadS3({ id });
|
|
14
|
+
const partNumber = Math.floor(offset / chunkSize) + 1;
|
|
15
|
+
const { UploadId, fileSize } = await findUploadS3({ id });
|
|
16
|
+
if (!UploadId) {
|
|
17
|
+
return { error: "upload not found", code: 404 };
|
|
18
|
+
}
|
|
15
19
|
await uploadChunkS3({
|
|
16
20
|
id,
|
|
17
21
|
chunk: body,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/index.ts"],"names":[],"mappings":"AAkBA,wBAA8B,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,iBAqC9D"}
|
|
@@ -5,14 +5,18 @@ import accessUserPost from "./controllers/access.user.post.js";
|
|
|
5
5
|
import accessInterface from "./controllers/access.interface.js";
|
|
6
6
|
import { publicResourcesList } from "../../plugins/access/funcs/getResources.js";
|
|
7
7
|
import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema, accessUserPostSchema, accessUserSchema, } from "./schema.js";
|
|
8
|
+
const tags = ["core", "access"];
|
|
8
9
|
export default async function route(fastify, opt = {}) {
|
|
9
|
-
fastify.get("/access-group/:id", { schema: accessGroupSchema }, accessGroup);
|
|
10
|
-
fastify.post("/access-group/:id", { schema: accessGroupPostSchema }, accessGroupPost);
|
|
11
|
-
fastify.get("/access-user/:id", {
|
|
10
|
+
fastify.get("/access-group/:id", { config: { tags }, schema: accessGroupSchema }, accessGroup);
|
|
11
|
+
fastify.post("/access-group/:id", { config: { tags }, schema: accessGroupPostSchema }, accessGroupPost);
|
|
12
|
+
fastify.get("/access-user/:id", {
|
|
13
|
+
config: { tags, permission: "admin.users.read" },
|
|
14
|
+
schema: accessUserSchema,
|
|
15
|
+
}, accessUser);
|
|
12
16
|
fastify.post("/access-user/:id", {
|
|
13
|
-
config: { permission: "admin.users.update" },
|
|
17
|
+
config: { tags, permission: "admin.users.update" },
|
|
14
18
|
schema: accessUserPostSchema,
|
|
15
19
|
}, accessUserPost);
|
|
16
|
-
fastify.get("/access-interface/:name", { schema: accessInterfaceSchema }, accessInterface);
|
|
17
|
-
fastify.get("/resources", { config: { policy: "L0" } }, async () => publicResourcesList);
|
|
20
|
+
fastify.get("/access-interface/:name", { config: { tags }, schema: accessInterfaceSchema }, accessInterface);
|
|
21
|
+
fastify.get("/resources", { config: { tags, policy: "L0" } }, async () => publicResourcesList);
|
|
18
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AA+CA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QA4FtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -20,7 +20,8 @@ import login2faTemplate from "./controllers/page/login2faTemplate.js";
|
|
|
20
20
|
import oauthAuthorize from "./controllers/jwt/authorize.js";
|
|
21
21
|
import oauthToken from "./controllers/jwt/token.js";
|
|
22
22
|
import qrCode from "./controllers/2factor/qrcode.js";
|
|
23
|
-
const
|
|
23
|
+
const tags = ["core", "auth"];
|
|
24
|
+
const params = { config: { policy: "L0", tags } };
|
|
24
25
|
const registrationSchema = {
|
|
25
26
|
body: {
|
|
26
27
|
type: "object",
|
|
@@ -64,14 +65,14 @@ function plugin(app, opt = {}) {
|
|
|
64
65
|
app.get("/2factor/recovery", params, recovery);
|
|
65
66
|
}
|
|
66
67
|
if (!app.hasRoute({ method: "GET", url: "/2factor/reset" })) {
|
|
67
|
-
app.get("/2factor/reset", { config: { role: "admin" } }, reset);
|
|
68
|
+
app.get("/2factor/reset", { config: { tags, role: "admin" } }, reset);
|
|
68
69
|
}
|
|
69
70
|
// get/edit user info
|
|
70
71
|
if (!app.hasRoute({ method: "GET", url: "/user" })) {
|
|
71
72
|
app.get("/user", params, getUserInfo);
|
|
72
73
|
}
|
|
73
74
|
if (!app.hasRoute({ method: "POST", url: "/user" })) {
|
|
74
|
-
app.post("/user", { config: { auth: "creds" } }, updateUserInfo);
|
|
75
|
+
app.post("/user", { config: { tags, auth: "creds" } }, updateUserInfo);
|
|
75
76
|
}
|
|
76
77
|
// jwt
|
|
77
78
|
if (!app.hasRoute({ method: "GET", url: "/oauth/authorize" })) {
|
|
@@ -8,6 +8,6 @@ const cronSchema = {
|
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
function plugin(app, opt = {}) {
|
|
11
|
-
app.get("/cron/:name", { config: { role: "admin" }, schema: cronSchema }, cronApi);
|
|
11
|
+
app.get("/cron/:name", { config: { role: "admin", tags: ["core", "cron"] }, schema: cronSchema }, cronApi);
|
|
12
12
|
}
|
|
13
13
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/crud/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/crud/index.ts"],"names":[],"mappings":"AAkBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAiCtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -12,13 +12,23 @@ const tableSchema = {
|
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
const policy = "L0";
|
|
15
|
+
const tags = ["core", "crud"];
|
|
15
16
|
function plugin(app, opt = {}) {
|
|
16
|
-
app.put("/table/:table/:id?", {
|
|
17
|
+
app.put("/table/:table/:id?", {
|
|
18
|
+
config: { tags, policy, description: "Edit table data" },
|
|
19
|
+
schema: tableSchema,
|
|
20
|
+
}, update);
|
|
17
21
|
app.delete("/table/:table/:id?", {
|
|
18
|
-
config: { policy, description: "Delete table data" },
|
|
22
|
+
config: { tags, policy, description: "Delete table data" },
|
|
19
23
|
schema: tableSchema,
|
|
20
24
|
}, deleteCrud);
|
|
21
|
-
app.post("/table/:table/:id?", {
|
|
22
|
-
|
|
25
|
+
app.post("/table/:table/:id?", {
|
|
26
|
+
config: { tags, policy, description: "Add table data" },
|
|
27
|
+
schema: tableSchema,
|
|
28
|
+
}, insert);
|
|
29
|
+
app.get("/table/:table/:id?", {
|
|
30
|
+
config: { tags, policy, description: "Get table data" },
|
|
31
|
+
schema: tableSchema,
|
|
32
|
+
}, table);
|
|
23
33
|
}
|
|
24
34
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/dblist/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/dblist/index.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QAiBtC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import readItemList from "./controllers/readItems.js";
|
|
2
2
|
import setItem from "./controllers/setItem.js";
|
|
3
|
-
const
|
|
3
|
+
const params = {
|
|
4
|
+
config: { policy: "L0", tags: ["core", "dblist"] },
|
|
5
|
+
};
|
|
4
6
|
export default function plugin(app) {
|
|
5
7
|
if (!app.hasRoute({ method: "GET", url: "/db-list" })) {
|
|
6
8
|
app.route({
|
|
7
9
|
method: "GET",
|
|
8
10
|
url: "/db-list",
|
|
9
|
-
|
|
11
|
+
...params,
|
|
10
12
|
handler: readItemList,
|
|
11
13
|
});
|
|
12
14
|
}
|
|
@@ -14,7 +16,7 @@ export default function plugin(app) {
|
|
|
14
16
|
app.route({
|
|
15
17
|
method: "GET",
|
|
16
18
|
url: "/db-list/:id",
|
|
17
|
-
|
|
19
|
+
...params,
|
|
18
20
|
handler: setItem,
|
|
19
21
|
});
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/file/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/file/index.ts"],"names":[],"mappings":"AAgBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QA+BtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -8,11 +8,14 @@ import exportTable from "./controllers/export.js";
|
|
|
8
8
|
import uploadImage from "./controllers/uploadImage.js";
|
|
9
9
|
import deleteFileAPI from "./controllers/delete.js";
|
|
10
10
|
import { resizeSchema } from "./schema.js";
|
|
11
|
+
const tags = ["core", "file"];
|
|
12
|
+
const publicParams = { config: { tags, policy: "L0" } };
|
|
11
13
|
function plugin(app, opt = {}) {
|
|
12
|
-
app.get("/files/*", { config: { policy: "L0" } }, files);
|
|
14
|
+
app.get("/files/*", { config: { tags, policy: "L0" } }, files);
|
|
13
15
|
if (!app.hasRoute({ method: "GET", url: "/file/resize" })) {
|
|
14
16
|
app.get("/file/resize", {
|
|
15
17
|
config: {
|
|
18
|
+
tags,
|
|
16
19
|
policy: "L0",
|
|
17
20
|
rateLimit: config.rateLimit
|
|
18
21
|
? {
|
|
@@ -24,11 +27,11 @@ function plugin(app, opt = {}) {
|
|
|
24
27
|
schema: resizeSchema,
|
|
25
28
|
}, resize);
|
|
26
29
|
}
|
|
27
|
-
app.get("/api/resize-all", { config: {
|
|
28
|
-
app.post("/file/upload/*",
|
|
29
|
-
app.post("/file/upload-image/*",
|
|
30
|
-
app.get("/file/download/*",
|
|
31
|
-
app.get("/file/delete/*",
|
|
32
|
-
app.get(`/api/export`,
|
|
30
|
+
app.get("/api/resize-all", { config: { tags, role: "admin" }, schema: resizeSchema }, resizeAll);
|
|
31
|
+
app.post("/file/upload/*", publicParams, upload);
|
|
32
|
+
app.post("/file/upload-image/*", publicParams, uploadImage);
|
|
33
|
+
app.get("/file/download/*", publicParams, download);
|
|
34
|
+
app.get("/file/delete/*", publicParams, deleteFileAPI);
|
|
35
|
+
app.get(`/api/export`, publicParams, exportTable);
|
|
33
36
|
}
|
|
34
37
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/grpc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/grpc/index.ts"],"names":[],"mappings":"AAKA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,QAGnC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import file2geojson from "./controllers/file2geojson.js";
|
|
2
2
|
import filePreview from "./controllers/filePreview.js";
|
|
3
|
+
const publicParams = { config: { policy: "L0", tags: ["core", "grpc"] } };
|
|
3
4
|
function plugin(app, opts) {
|
|
4
|
-
app.post("/file2geojson",
|
|
5
|
-
app.get("/file-preview",
|
|
5
|
+
app.post("/file2geojson", publicParams, file2geojson);
|
|
6
|
+
app.get("/file-preview", publicParams, filePreview);
|
|
6
7
|
}
|
|
7
8
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/logger/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/logger/index.ts"],"names":[],"mappings":"AAoBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAOtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import loggerFile from "./controllers/logger.file.js";
|
|
2
2
|
import loggerMetrics from "./controllers/logger.metrics.js";
|
|
3
3
|
// import loggerTest from './controllers/logger.test.api.js';
|
|
4
|
+
const tags = ["core", "logger"];
|
|
5
|
+
const publicParams = { config: { tags, policy: "L0", rateLimit: false } };
|
|
4
6
|
const loggerSchema = {
|
|
5
7
|
querystring: {
|
|
6
8
|
type: "object",
|
|
@@ -14,7 +16,7 @@ const loggerSchema = {
|
|
|
14
16
|
},
|
|
15
17
|
};
|
|
16
18
|
function plugin(app, opt = {}) {
|
|
17
|
-
app.get("/logger-file/*", {
|
|
18
|
-
app.get("/logger-metrics",
|
|
19
|
+
app.get("/logger-file/*", { ...publicParams, schema: loggerSchema }, loggerFile);
|
|
20
|
+
app.get("/logger-metrics", publicParams, loggerMetrics);
|
|
19
21
|
}
|
|
20
22
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/menu/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/menu/index.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAGpD"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import getMenu from "./controllers/getMenu.js";
|
|
2
2
|
import interfaces from "./controllers/interfaces.js";
|
|
3
|
+
const tags = ["core", "menu"];
|
|
4
|
+
const publicParams = {
|
|
5
|
+
config: { tags },
|
|
6
|
+
};
|
|
7
|
+
const params = {
|
|
8
|
+
config: { tags, role: "admin" },
|
|
9
|
+
};
|
|
3
10
|
export default function route(app, opt = {}) {
|
|
4
|
-
app.get("/user-menu", getMenu);
|
|
5
|
-
app.get("/interfaces",
|
|
11
|
+
app.get("/user-menu", publicParams, getMenu);
|
|
12
|
+
app.get("/interfaces", params, interfaces);
|
|
6
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/notifications/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/notifications/index.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,QAgBrC"}
|
|
@@ -3,7 +3,9 @@ import userNotifications from "./controllers/userNotifications.js"; // check all
|
|
|
3
3
|
import addUserNotification from "./controllers/addUserNotification.js"; // add user notification
|
|
4
4
|
import editUserNotification from "./controllers/editUserNotification.js"; // edit unread user notification
|
|
5
5
|
import deleteUserNotification from "./controllers/deleteUserNotification.js"; // delete user notification
|
|
6
|
-
const params = {
|
|
6
|
+
const params = {
|
|
7
|
+
config: { policy: "L1", tags: ["core", "notifications"] },
|
|
8
|
+
};
|
|
7
9
|
export default function route(app) {
|
|
8
10
|
if (!app.hasRoute({ method: "GET", url: "/notification" })) {
|
|
9
11
|
app.get("/notification", params, userNotifications);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/properties/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/properties/index.ts"],"names":[],"mappings":"AAcA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAWtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import getAppSettings from "./controllers/properties.get.js";
|
|
2
2
|
import postAppSettings from "./controllers/properties.post.js";
|
|
3
|
+
const tags = ["core", "properties"];
|
|
3
4
|
const propertiesSchema = {
|
|
4
5
|
type: "object",
|
|
5
6
|
properties: {
|
|
6
7
|
params: {
|
|
7
|
-
|
|
8
|
-
key: { type: "string", pattern: "^([\\d\\w._]+)$" },
|
|
9
|
-
},
|
|
10
|
-
querystring: {
|
|
11
|
-
json: { type: "string", pattern: "^([\\d\\w]+)$" },
|
|
8
|
+
entity: { type: "string", pattern: "^([\\d\\w]+)$" },
|
|
12
9
|
},
|
|
13
10
|
},
|
|
14
11
|
};
|
|
15
12
|
function plugin(app, opt = {}) {
|
|
16
|
-
app.get("/settings-app/:entity?", { config: { policy: "L0" }, schema: propertiesSchema }, getAppSettings);
|
|
17
|
-
app.post("/settings-app/:entity?", { config: { role: "admin" } }, postAppSettings);
|
|
13
|
+
app.get("/settings-app/:entity?", { config: { tags, policy: "L0" }, schema: propertiesSchema }, getAppSettings);
|
|
14
|
+
app.post("/settings-app/:entity?", { config: { tags, role: "admin" }, schema: propertiesSchema }, postAppSettings);
|
|
18
15
|
}
|
|
19
16
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/index.ts"],"names":[],"mappings":"AAgCA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAiFtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -14,12 +14,14 @@ import form from "./controllers/getFormByTable.js";
|
|
|
14
14
|
import loadTemplatePath from "../../plugins/table/funcs/loadTemplatePath.js";
|
|
15
15
|
import { tableDataSchema, tableSchema, searchSchema, suggestSchema, formSchema, filterSchema, cardTabDataSchema, tableDataIdSchema, } from "./schema.js";
|
|
16
16
|
const policy = "L0";
|
|
17
|
+
const tags = ["core", "table"];
|
|
17
18
|
function plugin(app, opt = {}) {
|
|
18
|
-
app.get("/token-info/:token", { config: { role: "admin" } }, tokenInfo);
|
|
19
|
-
app.get("/table-filter/:table", { config: { policy }, schema: filterSchema }, filter);
|
|
20
|
-
app.get("/table-info/:table/:id?", { config: { policy }, schema: tableDataSchema }, tableInfo);
|
|
19
|
+
app.get("/token-info/:token", { config: { tags, role: "admin" } }, tokenInfo);
|
|
20
|
+
app.get("/table-filter/:table", { config: { tags, policy }, schema: filterSchema }, filter);
|
|
21
|
+
app.get("/table-info/:table/:id?", { config: { tags, policy }, schema: tableDataSchema }, tableInfo);
|
|
21
22
|
app.get("/suggest/:data", {
|
|
22
23
|
config: {
|
|
24
|
+
tags,
|
|
23
25
|
policy,
|
|
24
26
|
rateLimit: config.rateLimit
|
|
25
27
|
? {
|
|
@@ -30,15 +32,15 @@ function plugin(app, opt = {}) {
|
|
|
30
32
|
},
|
|
31
33
|
schema: suggestSchema,
|
|
32
34
|
}, suggest);
|
|
33
|
-
app.get("/data/:table/:id?", { config: { policy }, schema: tableSchema }, data);
|
|
34
|
-
app.get("/table-data/:table", { config: { auth: "creds", policy: "L2" }, schema: tableDataSchema }, data);
|
|
35
|
-
app.get("/table-data/:table/:id", { config: { policy }, schema: tableDataIdSchema }, cardData);
|
|
36
|
-
app.get("/data-info/:id?", { config: { policy }, schema: tableSchema }, dataInfo);
|
|
37
|
-
app.get("/card-data/:token", { config: { policy },
|
|
38
|
-
app.get("/card/:table/:id", { config: { policy }, schema: tableSchema }, card);
|
|
39
|
-
app.get("/search", { config: { policy }, schema: searchSchema }, search);
|
|
40
|
-
app.get("/templates", () => loadTemplatePath);
|
|
41
|
-
app.get("/filter/:table", { config: { policy }, schema: filterSchema }, filter);
|
|
42
|
-
app.get("/form/:name/:id?", { config: { auth: "creds", policy: "L2" }, schema: formSchema }, form);
|
|
35
|
+
app.get("/data/:table/:id?", { config: { tags, policy }, schema: tableSchema }, data);
|
|
36
|
+
app.get("/table-data/:table", { config: { tags, auth: "creds", policy: "L2" }, schema: tableDataSchema }, data);
|
|
37
|
+
app.get("/table-data/:table/:id", { config: { tags, policy }, schema: tableDataIdSchema }, cardData);
|
|
38
|
+
app.get("/data-info/:id?", { config: { tags, policy }, schema: tableSchema }, dataInfo);
|
|
39
|
+
app.get("/card-data/:token", { config: { tags, policy }, schema: cardTabDataSchema }, cardTabData);
|
|
40
|
+
app.get("/card/:table/:id", { config: { tags, policy }, schema: tableSchema }, card);
|
|
41
|
+
app.get("/search", { config: { tags, policy }, schema: searchSchema }, search);
|
|
42
|
+
app.get("/templates", { config: { tags } }, () => loadTemplatePath);
|
|
43
|
+
app.get("/filter/:table", { config: { tags, policy }, schema: filterSchema }, filter);
|
|
44
|
+
app.get("/form/:name/:id?", { config: { tags, auth: "creds", policy: "L2" }, schema: formSchema }, form);
|
|
43
45
|
}
|
|
44
46
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/templates/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/templates/index.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAMpD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import getTemplateApi from "./controllers/getTemplate.js";
|
|
2
2
|
import { getTemplateSchema } from "./schema.js";
|
|
3
3
|
const policy = "L0";
|
|
4
|
+
const tags = ["core", "templates"];
|
|
4
5
|
export default function route(app, opt = {}) {
|
|
5
|
-
app.get("/template/:type/:name", { config: { policy }, schema: getTemplateSchema }, getTemplateApi);
|
|
6
|
+
app.get("/template/:type/:name", { config: { tags, policy }, schema: getTemplateSchema }, getTemplateApi);
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/upload/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/upload/index.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QA2GtC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import config from "../../../config.js";
|
|
2
|
-
const { chunkSize =
|
|
2
|
+
const { chunkSize = 5242880 } = config;
|
|
3
3
|
import { prefix } from "../../plugins/upload/index.js";
|
|
4
4
|
import startUpload from "../../plugins/upload/startUpload.js";
|
|
5
5
|
import uploadChunk from "../../plugins/upload/uploadChunk.js";
|
|
6
6
|
import getUploadStatus from "../../plugins/upload/getUploadStatus.js";
|
|
7
7
|
const policy = "L0"; // public
|
|
8
|
+
const tags = ["core", "upload"];
|
|
8
9
|
export default function plugin(app) {
|
|
9
10
|
// provide server with metadata for chunked upload
|
|
10
|
-
app.post(`/${prefix}/start`, {
|
|
11
|
+
app.post(`/${prefix}/start`, {
|
|
12
|
+
config: { tags, description: "Init chunked upload", policy },
|
|
13
|
+
}, async (req, reply) => {
|
|
11
14
|
const { fileName, size, subdir, id } = req.body || {};
|
|
12
15
|
if (!fileName || !size) {
|
|
13
16
|
return reply
|
|
@@ -25,11 +28,24 @@ export default function plugin(app) {
|
|
|
25
28
|
// disable default parser for PATCH /upload/:id
|
|
26
29
|
// allows accept all content types (req.body = raw buffer)
|
|
27
30
|
// limit body size to 50MB by default, depends on upload chunk size
|
|
28
|
-
app.addContentTypeParser("*", { parseAs: "buffer", bodyLimit: chunkSize *
|
|
31
|
+
app.addContentTypeParser("*", { parseAs: "buffer", bodyLimit: chunkSize * 10 }, (req, body, done) => {
|
|
29
32
|
done(null, body);
|
|
30
33
|
});
|
|
31
34
|
// upload chunks
|
|
32
|
-
app.patch(`/${prefix}/:id`, {
|
|
35
|
+
app.patch(`/${prefix}/:id`, {
|
|
36
|
+
config: {
|
|
37
|
+
tags,
|
|
38
|
+
description: "Upload chunk of data",
|
|
39
|
+
policy: config.uploadChunkPolicy || policy,
|
|
40
|
+
rateLimit: config.rateLimit
|
|
41
|
+
? {
|
|
42
|
+
max: +(config.rateLimit?.uploadChunk?.max || 1000),
|
|
43
|
+
timeWindow: config.rateLimit?.uploadChunk?.timeWindow || "1 minute",
|
|
44
|
+
keyGenerator: (req) => `${req.user?.uid || req.ip}-${req.routeOptions.url}`,
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
},
|
|
48
|
+
}, async (req, reply) => {
|
|
33
49
|
if (!req.headers["content-range"]) {
|
|
34
50
|
return reply
|
|
35
51
|
.status(411)
|
|
@@ -57,7 +73,9 @@ export default function plugin(app) {
|
|
|
57
73
|
return result;
|
|
58
74
|
});
|
|
59
75
|
// check upload status
|
|
60
|
-
app.get(`/${prefix}/:id`, {
|
|
76
|
+
app.get(`/${prefix}/:id`, {
|
|
77
|
+
config: { tags, description: "Check chunked upload status", policy },
|
|
78
|
+
}, async (req) => {
|
|
61
79
|
const { id } = req.params;
|
|
62
80
|
const status = await getUploadStatus({ id });
|
|
63
81
|
return status;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/usercls/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/usercls/index.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QAkDtC"}
|
|
@@ -27,19 +27,20 @@ import getUserCls from "./controllers/getUserCls.js";
|
|
|
27
27
|
import addUserCls from "./controllers/addUserCls.js";
|
|
28
28
|
import editUserCls from "./controllers/editUserCls.js";
|
|
29
29
|
import deleteUserCls from "./controllers/deleteUserCls.js";
|
|
30
|
+
const tags = ["core", "usercls"];
|
|
30
31
|
export default function plugin(app) {
|
|
31
32
|
if (!app.hasRoute({ method: "GET", url: "/api/user-cls" })) {
|
|
32
|
-
app.get("/user-cls", { config: { policy: "L1" } }, getUserCls);
|
|
33
|
+
app.get("/user-cls", { config: { tags, policy: "L1" } }, getUserCls);
|
|
33
34
|
}
|
|
34
35
|
if (!app.hasRoute({ method: "POST", url: "/api/user-cls" })) {
|
|
35
36
|
app.post("/user-cls", {
|
|
36
|
-
config: { policy: "L1" },
|
|
37
|
+
config: { tags, policy: "L1" },
|
|
37
38
|
schema: { body: addUserClsBodySchema },
|
|
38
39
|
}, addUserCls);
|
|
39
40
|
}
|
|
40
41
|
if (!app.hasRoute({ method: "PUT", url: "/api/user-cls/:name" })) {
|
|
41
42
|
app.put("/user-cls/:name", {
|
|
42
|
-
config: { policy: "L1" },
|
|
43
|
+
config: { tags, policy: "L1" },
|
|
43
44
|
schema: {
|
|
44
45
|
params: userClsParamsSchema,
|
|
45
46
|
body: editUserClsBodySchema,
|
|
@@ -47,9 +48,15 @@ export default function plugin(app) {
|
|
|
47
48
|
}, editUserCls);
|
|
48
49
|
}
|
|
49
50
|
if (!app.hasRoute({ method: "DELETE", url: "/api/user-cls/:name" })) {
|
|
50
|
-
app.delete("/user-cls/:name", {
|
|
51
|
+
app.delete("/user-cls/:name", {
|
|
52
|
+
config: { tags, policy: "L1" },
|
|
53
|
+
schema: { params: userClsParamsSchema },
|
|
54
|
+
}, deleteUserCls);
|
|
51
55
|
}
|
|
52
56
|
if (!app.hasRoute({ method: "DELETE", url: "/api/user-cls/:name/:code" })) {
|
|
53
|
-
app.delete("/user-cls/:name/:code", {
|
|
57
|
+
app.delete("/user-cls/:name/:code", {
|
|
58
|
+
config: { tags, policy: "L1" },
|
|
59
|
+
schema: { params: userClsParamsSchema },
|
|
60
|
+
}, deleteUserCls);
|
|
54
61
|
}
|
|
55
62
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default function apiListService({ includeTags: queryIncludeTags, excludeTags: queryExcludeTags, packageName, subdir, md, routes, }: {
|
|
2
|
+
includeTags?: any;
|
|
3
|
+
excludeTags?: any;
|
|
4
|
+
packageName?: string;
|
|
5
|
+
subdir?: string;
|
|
6
|
+
md?: string;
|
|
7
|
+
routes: any[];
|
|
8
|
+
}): {
|
|
9
|
+
headers: {
|
|
10
|
+
"Content-Type": string;
|
|
11
|
+
};
|
|
12
|
+
data: string;
|
|
13
|
+
rows?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
rows: any[];
|
|
16
|
+
headers?: undefined;
|
|
17
|
+
data?: undefined;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=api.list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.list.d.ts","sourceRoot":"","sources":["../../../../../server/routes/util/controllers/api.list.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,WAAW,EAAE,gBAAgB,EAC7B,WAAW,EAAE,gBAAgB,EAC7B,WAAW,EACX,MAAM,EACN,EAAE,EACF,MAAM,GACP,EAAE;IACD,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,GAAG,EAAE,CAAC;CACf;;;;;;;;;;EA2CA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import config from "../../../../config.js";
|
|
2
|
+
const columns = config.apiListMDColumns || "method|endpoint|description|tags";
|
|
3
|
+
function toMarkdownTable(data, columns) {
|
|
4
|
+
if (!Array.isArray(data) || !data.length)
|
|
5
|
+
return "";
|
|
6
|
+
// auto-detect columns if not provided
|
|
7
|
+
const cols = columns || [...new Set(data.flatMap((row) => Object.keys(row)))];
|
|
8
|
+
const escape = (value) => String(value ?? "")
|
|
9
|
+
.replace(/\|/g, "\\|")
|
|
10
|
+
.replace(/\n/g, " ");
|
|
11
|
+
const header = `| ${cols.join(" | ")} |`;
|
|
12
|
+
const separator = `| ${cols.map(() => "---").join(" | ")} |`;
|
|
13
|
+
const rows = data.map((row) => {
|
|
14
|
+
return `| ${cols
|
|
15
|
+
.map((col) => {
|
|
16
|
+
const value = row[col];
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return escape(value.join(", "));
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === "object" && value !== null) {
|
|
21
|
+
return escape(JSON.stringify(value));
|
|
22
|
+
}
|
|
23
|
+
return escape(value);
|
|
24
|
+
})
|
|
25
|
+
.join(" | ")} |`;
|
|
26
|
+
});
|
|
27
|
+
return [header, separator, ...rows].join("\n");
|
|
28
|
+
}
|
|
29
|
+
export default function apiListService({ includeTags: queryIncludeTags, excludeTags: queryExcludeTags, packageName, subdir, md, routes, }) {
|
|
30
|
+
const includeTags = queryIncludeTags
|
|
31
|
+
? new Set(queryIncludeTags?.split("|"))
|
|
32
|
+
: undefined;
|
|
33
|
+
const excludeTags = queryExcludeTags
|
|
34
|
+
? new Set(queryExcludeTags?.split("|"))
|
|
35
|
+
: undefined;
|
|
36
|
+
const filteredRoutes = excludeTags
|
|
37
|
+
? routes.filter((r) => !r.tags || !r.tags.find((tag) => excludeTags.has(tag)))
|
|
38
|
+
: routes;
|
|
39
|
+
const filteredRoutes1 = includeTags
|
|
40
|
+
? filteredRoutes.filter((r) => r.tags && r.tags.find((tag) => includeTags.has(tag)))
|
|
41
|
+
: filteredRoutes;
|
|
42
|
+
const filteredRoutes2 = subdir
|
|
43
|
+
? filteredRoutes1.filter((r) => r.subdir === subdir)
|
|
44
|
+
: filteredRoutes1;
|
|
45
|
+
const filteredRoutes3 = packageName
|
|
46
|
+
? filteredRoutes2.filter((r) => r.package === packageName)
|
|
47
|
+
: filteredRoutes2;
|
|
48
|
+
if (md) {
|
|
49
|
+
const markdownStr = toMarkdownTable(filteredRoutes3, Array.isArray(columns) ? columns : columns.split("|"));
|
|
50
|
+
return {
|
|
51
|
+
headers: {
|
|
52
|
+
"Content-Type": "text/markdown",
|
|
53
|
+
},
|
|
54
|
+
data: markdownStr,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return { rows: filteredRoutes3 };
|
|
58
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/util/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/util/index.ts"],"names":[],"mappings":"AAWA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAmCtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -4,16 +4,17 @@ import statusMonitor from "./controllers/status.monitor.js";
|
|
|
4
4
|
import userTokens from "./controllers/user.tokens.js";
|
|
5
5
|
import codeGenerator from "./controllers/code.generator.js";
|
|
6
6
|
import dependencies from "./controllers/dependencies.js";
|
|
7
|
+
const tags = ["core", "util"];
|
|
7
8
|
function plugin(app, opt = {}) {
|
|
8
|
-
app.get("/next-id", { config: { policy: "L0" } }, nextId);
|
|
9
|
-
app.get("/status-monitor", { config: { role: "admin" } }, statusMonitor);
|
|
10
|
-
app.get("/user-tokens/:token", { config: { role: "admin|regular" } }, userTokens);
|
|
11
|
-
app.get("/code-gen/:token/:column/:id?", { config: { role: "admin|regular" } }, codeGenerator);
|
|
12
|
-
app.get("/test-proxy", { config: { policy: "L0" } }, (req) => ({
|
|
9
|
+
app.get("/next-id", { config: { tags, policy: "L0" } }, nextId);
|
|
10
|
+
app.get("/status-monitor", { config: { tags, role: "admin" } }, statusMonitor);
|
|
11
|
+
app.get("/user-tokens/:token", { config: { tags, role: "admin|regular" } }, userTokens);
|
|
12
|
+
app.get("/code-gen/:token/:column/:id?", { config: { tags, role: "admin|regular" } }, codeGenerator);
|
|
13
|
+
app.get("/test-proxy", { config: { tags, policy: "L0" } }, (req) => ({
|
|
13
14
|
...(req.headers || {}),
|
|
14
15
|
sessionId: req.session?.sessionId,
|
|
15
16
|
}));
|
|
16
|
-
app.get("/config", { config: { policy: "L0" /*role: "admin"*/ } }, apiConfig);
|
|
17
|
-
app.get("/dependencies", { config: { policy: "L1", role: "admin" } }, dependencies);
|
|
17
|
+
app.get("/config", { config: { tags, policy: "L0" /*role: "admin"*/ } }, apiConfig);
|
|
18
|
+
app.get("/dependencies", { config: { tags, policy: "L1", role: "admin" } }, dependencies);
|
|
18
19
|
}
|
|
19
20
|
export default plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/widget/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/widget/index.ts"],"names":[],"mappings":"AA2CA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAKpD"}
|
|
@@ -4,6 +4,7 @@ import widgetSet from "./controllers/widget.set.js";
|
|
|
4
4
|
import widgetGet from "./controllers/widget.get.js";
|
|
5
5
|
import fileEdit from "./controllers/file.edit.js";
|
|
6
6
|
import onWidgetSet from "./hook/onWidgetSet.js";
|
|
7
|
+
const tags = ["core", "widget"];
|
|
7
8
|
const tableSchema = {
|
|
8
9
|
params: {
|
|
9
10
|
type: "object",
|
|
@@ -32,10 +33,10 @@ const tableSchema = {
|
|
|
32
33
|
};
|
|
33
34
|
addHook("onWidgetSet", onWidgetSet);
|
|
34
35
|
const policy = "L0";
|
|
35
|
-
const params = { config: { policy }, schema: tableSchema };
|
|
36
|
+
const params = { config: { tags, policy }, schema: tableSchema };
|
|
36
37
|
export default function route(app, opt = {}) {
|
|
37
38
|
app.delete("/widget/:type/:objectid/:id", params, widgetDel);
|
|
38
39
|
app.post("/widget/:type/:objectid/:id?", params, widgetSet);
|
|
39
40
|
app.put("/file-edit/:id", params, fileEdit);
|
|
40
|
-
app.get("/widget/:type/:objectid",
|
|
41
|
+
app.get("/widget/:type/:objectid", params, widgetGet);
|
|
41
42
|
}
|