@opengis/fastify-table 2.5.37 → 2.5.39
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 +10 -2
- package/dist/server/migrations/users.sql +14 -33
- package/dist/server/plugins/auth/funcs/verifyPassword.d.ts.map +1 -1
- package/dist/server/plugins/auth/funcs/verifyPassword.js +11 -2
- package/dist/server/plugins/crud/funcs/validateData.d.ts +2 -1
- package/dist/server/plugins/crud/funcs/validateData.d.ts.map +1 -1
- package/dist/server/plugins/crud/funcs/validateData.js +5 -2
- package/dist/server/plugins/usercls/index.d.ts +4 -8
- package/dist/server/plugins/usercls/index.d.ts.map +1 -1
- package/dist/server/plugins/usercls/index.js +45 -29
- package/dist/server/routes/access/index.d.ts.map +1 -1
- package/dist/server/routes/access/index.js +16 -6
- 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.d.ts +1 -1
- package/dist/server/routes/cron/index.d.ts.map +1 -1
- package/dist/server/routes/cron/index.js +8 -2
- package/dist/server/routes/crud/controllers/update.js +1 -1
- package/dist/server/routes/crud/index.d.ts.map +1 -1
- package/dist/server/routes/crud/index.js +25 -4
- package/dist/server/routes/dblist/index.d.ts.map +1 -1
- package/dist/server/routes/dblist/index.js +2 -1
- package/dist/server/routes/file/index.d.ts.map +1 -1
- package/dist/server/routes/file/index.js +9 -4
- package/dist/server/routes/grpc/index.d.ts +1 -1
- package/dist/server/routes/grpc/index.d.ts.map +1 -1
- package/dist/server/routes/grpc/index.js +5 -2
- package/dist/server/routes/logger/index.d.ts +1 -1
- package/dist/server/routes/logger/index.d.ts.map +1 -1
- package/dist/server/routes/logger/index.js +5 -2
- package/dist/server/routes/menu/index.d.ts.map +1 -1
- package/dist/server/routes/menu/index.js +3 -2
- package/dist/server/routes/notifications/index.d.ts.map +1 -1
- package/dist/server/routes/notifications/index.js +6 -1
- package/dist/server/routes/properties/index.d.ts.map +1 -1
- package/dist/server/routes/properties/index.js +9 -2
- package/dist/server/routes/table/index.d.ts.map +1 -1
- package/dist/server/routes/table/index.js +27 -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 +7 -3
- package/dist/server/routes/usercls/index.d.ts.map +1 -1
- package/dist/server/routes/usercls/index.js +6 -5
- package/dist/server/routes/util/controllers/api.list.d.ts +2 -1
- package/dist/server/routes/util/controllers/api.list.d.ts.map +1 -1
- package/dist/server/routes/util/controllers/api.list.js +9 -3
- package/dist/server/routes/util/index.d.ts.map +1 -1
- package/dist/server/routes/util/index.js +9 -8
- package/dist/server/routes/widget/index.d.ts.map +1 -1
- package/dist/server/routes/widget/index.js +5 -1
- 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":"AA8FA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA8FA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,iBAmPjC;;AACD,wBAEG"}
|
package/dist/index.js
CHANGED
|
@@ -67,15 +67,17 @@ async function plugin(fastify) {
|
|
|
67
67
|
const opt = { prefix: "/api" };
|
|
68
68
|
// await new Promise(resolve => setTimeout(resolve, 50000)); // ! for debug, simulate Plugin did not start in time
|
|
69
69
|
if (config.disableCors) {
|
|
70
|
-
fastify.addHook("onSend", async (
|
|
70
|
+
fastify.addHook("onSend", async (_, reply) => {
|
|
71
71
|
reply.header("Access-Control-Allow-Origin", "*");
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
const apiListSchema = {
|
|
75
75
|
querystring: {
|
|
76
76
|
type: "object",
|
|
77
|
+
additionalProperties: false,
|
|
77
78
|
properties: {
|
|
78
79
|
package: { type: "string" },
|
|
80
|
+
exclude_package: { type: "string" },
|
|
79
81
|
subdir: { type: "string" },
|
|
80
82
|
md: { type: "string", pattern: "^1$" },
|
|
81
83
|
tags: { type: "string", pattern: "^[a-zA-Z0-9_,]+$" },
|
|
@@ -85,12 +87,17 @@ async function plugin(fastify) {
|
|
|
85
87
|
};
|
|
86
88
|
if (!fastify.hasRoute({ method: "GET", url: "/api/list" })) {
|
|
87
89
|
fastify.get(`${opt.prefix || "/api"}/list`, {
|
|
88
|
-
config: {
|
|
90
|
+
config: {
|
|
91
|
+
tags: ["core", "util"],
|
|
92
|
+
package: "fastify-table",
|
|
93
|
+
role: "admin",
|
|
94
|
+
},
|
|
89
95
|
schema: apiListSchema,
|
|
90
96
|
}, function apiList(req, reply) {
|
|
91
97
|
const result = apiListService({
|
|
92
98
|
includeTags: req.query.tags,
|
|
93
99
|
excludeTags: req.query.exclude_tags,
|
|
100
|
+
excludePackage: req.query.exclude_package,
|
|
94
101
|
packageName: req.query.package,
|
|
95
102
|
subdir: req.query.subdir,
|
|
96
103
|
md: req.query.md,
|
|
@@ -121,6 +128,7 @@ async function plugin(fastify) {
|
|
|
121
128
|
package: r.config?.package,
|
|
122
129
|
tags: Array.isArray(r.config?.tags) ? r.config?.tags : undefined,
|
|
123
130
|
description: r.config?.description,
|
|
131
|
+
summary: r.config?.summary,
|
|
124
132
|
query,
|
|
125
133
|
roles: r.config?.role?.split?.("|"),
|
|
126
134
|
policy: (Array.isArray(r.config?.policy)
|
|
@@ -58,16 +58,8 @@ COMMENT ON COLUMN admin.users.twofa IS 'Двофакторна авториза
|
|
|
58
58
|
|
|
59
59
|
CREATE EXTENSION if not exists pgcrypto SCHEMA public VERSION "1.3";
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
$BODY$
|
|
64
|
-
DECLARE
|
|
65
|
-
BEGIN
|
|
66
|
-
return public.crypt(pass, salt);
|
|
67
|
-
END;
|
|
68
|
-
$BODY$
|
|
69
|
-
LANGUAGE plpgsql VOLATILE
|
|
70
|
-
COST 100;
|
|
61
|
+
alter table admin.users add column if not exists password_new_hash_algorithm boolean;
|
|
62
|
+
update admin.users set password_new_hash_algorithm = false where password_new_hash_algorithm is null;
|
|
71
63
|
|
|
72
64
|
-- DROP FUNCTION admin.insert_update_user_before();
|
|
73
65
|
CREATE OR REPLACE FUNCTION admin.insert_update_user_before()
|
|
@@ -80,30 +72,19 @@ iterations int;
|
|
|
80
72
|
hash character varying;
|
|
81
73
|
|
|
82
74
|
BEGIN
|
|
75
|
+
-- new passwords would use more secure hashing algorithm
|
|
76
|
+
IF TG_OP = 'INSERT' OR (TG_OP = 'UPDATE' AND NEW.password <> OLD.password) THEN
|
|
77
|
+
|
|
78
|
+
NEW.salt = public.gen_salt('bf', 12);
|
|
79
|
+
|
|
80
|
+
IF length(NEW.password) > 0 THEN
|
|
81
|
+
NEW.password = public.crypt(NEW.password, NEW.salt);
|
|
82
|
+
NEW.password_new_hash_algorithm = true;
|
|
83
|
+
END IF;
|
|
84
|
+
|
|
85
|
+
END IF;
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
if(char_length(new.password) <> 0 and char_length(new.password) < 8) then
|
|
86
|
-
--raise exception 'password must be longer than 8 characters';
|
|
87
|
-
end if;
|
|
88
|
-
new.salt=md5(now()::text);
|
|
89
|
-
--raise exception '%','change pass';
|
|
90
|
-
if(new.salt ='') then
|
|
91
|
-
new.salt=gen_salt('md5');
|
|
92
|
-
end if;
|
|
93
|
-
iterations = 10;
|
|
94
|
-
hash='';
|
|
95
|
-
|
|
96
|
-
loop
|
|
97
|
-
if iterations=0 then
|
|
98
|
-
exit;
|
|
99
|
-
end if;
|
|
100
|
-
hash = md5(new.password||hash||new.salt);
|
|
101
|
-
iterations=iterations-1;
|
|
102
|
-
end loop;
|
|
103
|
-
new.password=admin.crypt(hash,new.salt);
|
|
104
|
-
|
|
105
|
-
end if;
|
|
106
|
-
RETURN new;
|
|
87
|
+
RETURN new;
|
|
107
88
|
END
|
|
108
89
|
$BODY$
|
|
109
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;
|
|
1
|
+
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;eA2CA"}
|
|
@@ -11,12 +11,21 @@ export default async function verifyPassword({ pg, username, password, }) {
|
|
|
11
11
|
return { message: "not enough params: username" };
|
|
12
12
|
if (!password || password === "")
|
|
13
13
|
return { message: "not enough params: password" };
|
|
14
|
-
const query = "select * from admin.users where $1 in (login,email,phone) and enabled limit 1";
|
|
14
|
+
const query = "select * from admin.users where $1 in (login,email,phone) and enabled and salt is not null limit 1";
|
|
15
15
|
const json = await pg
|
|
16
16
|
.query(query, [username])
|
|
17
|
-
.then((
|
|
17
|
+
.then((r) => r.rows?.[0] || {});
|
|
18
18
|
if (!json)
|
|
19
19
|
return { message: "user not found" };
|
|
20
|
+
if (json.password_new_hash_algorithm === true) {
|
|
21
|
+
const hash = await pg
|
|
22
|
+
.query(`SELECT public.crypt($1, $2)`, [password, json.salt])
|
|
23
|
+
.then((r) => r.rows?.[0]?.crypt);
|
|
24
|
+
if (json.password === hash) {
|
|
25
|
+
return { user: json };
|
|
26
|
+
}
|
|
27
|
+
return { message: "Wrong password" };
|
|
28
|
+
}
|
|
20
29
|
let hash = "";
|
|
21
30
|
for (let i = 0; i < 10; i += 1) {
|
|
22
31
|
hash = md5(password + hash + json.salt);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AAmJA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,
|
|
1
|
+
{"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AAmJA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,EACX,MAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,OASA"}
|
|
@@ -120,10 +120,13 @@ function checkBody({ body = {}, arr = [], idx }) {
|
|
|
120
120
|
}
|
|
121
121
|
return { message: "ok" };
|
|
122
122
|
}
|
|
123
|
-
export default function validateData({ body = {}, schema = {}, }) {
|
|
123
|
+
export default function validateData({ body = {}, schema = {}, update = false, }) {
|
|
124
|
+
const arr = Object.keys(schema).map((key) => ({ ...schema[key], key }));
|
|
124
125
|
const res = checkBody({
|
|
125
126
|
body,
|
|
126
|
-
arr:
|
|
127
|
+
arr: update
|
|
128
|
+
? arr.filter((el) => Object.keys(body || {}).includes(el.key))
|
|
129
|
+
: arr,
|
|
127
130
|
});
|
|
128
131
|
return res;
|
|
129
132
|
}
|
|
@@ -17,18 +17,14 @@ export declare function deleteUserCls({ name, code }: {
|
|
|
17
17
|
name: string;
|
|
18
18
|
code?: string;
|
|
19
19
|
}, pg?: any): Promise<string>;
|
|
20
|
-
|
|
20
|
+
type UserClsPayload = {
|
|
21
21
|
name: string;
|
|
22
22
|
alias?: string[];
|
|
23
23
|
description?: string;
|
|
24
24
|
data: string | Record<string, any>[];
|
|
25
|
-
}
|
|
26
|
-
export declare function
|
|
27
|
-
|
|
28
|
-
description?: string;
|
|
29
|
-
alias?: string[];
|
|
30
|
-
data: string | Record<string, any>[];
|
|
31
|
-
}, pg?: any): Promise<string>;
|
|
25
|
+
};
|
|
26
|
+
export declare function addUserCls({ name, alias, data, description }: UserClsPayload, pg?: any): Promise<string>;
|
|
27
|
+
export declare function editUserCls({ name, alias, description, data }: UserClsPayload, pg?: any): Promise<string>;
|
|
32
28
|
export declare function getUserClsList({ name, search, sql, custom, }: {
|
|
33
29
|
name?: string;
|
|
34
30
|
search?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/usercls/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,YAAY,CAChC,EACE,IAAI,EACJ,WAAW,EACX,KAAK,EACL,KAAK,EACL,GAAG,EACH,IAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,EAAE,CAAC;CACL,EACD,EAAE,MAAmB,mBA8EtB;AAED,wBAAsB,aAAa,CACjC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/C,EAAE,MAAmB,mBAgBtB;AAED,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/usercls/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,YAAY,CAChC,EACE,IAAI,EACJ,WAAW,EACX,KAAK,EACL,KAAK,EACL,GAAG,EACH,IAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,EAAE,CAAC;CACL,EACD,EAAE,MAAmB,mBA8EtB;AAED,wBAAsB,aAAa,CACjC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/C,EAAE,MAAmB,mBAgBtB;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CACtC,CAAC;AAmDF,wBAAsB,UAAU,CAC9B,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,cAAc,EAClD,EAAE,MAAmB,mBActB;AAED,wBAAsB,WAAW,CAC/B,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,cAAc,EAClD,EAAE,MAAmB,mBAmBtB;AAED,wBAAsB,cAAc,CAClC,EACE,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,GACP,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;CAEjB,EACD,EAAE,MAAmB,gBA0DtB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAmB;;;;;UAuBnE;;AAED,wBAAoB"}
|
|
@@ -73,7 +73,8 @@ export async function deleteUserCls({ name, code }, pg = pgClients.client) {
|
|
|
73
73
|
await pg.query(`delete from admin.user_cls where ((name=$1 and parent is null) or parent=$1) and ${code ? "code=$2" : "true"}`, [name, code].filter(Boolean));
|
|
74
74
|
return "ok";
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
/** Запис класифікатора в межах уже відкритої транзакції (client — з pg.connect()) */
|
|
77
|
+
async function insertUserCls({ name, alias, data, description }, client) {
|
|
77
78
|
const type = typeof data === "string" ? "sql" : "json";
|
|
78
79
|
if (type === "json" && data && !Array.isArray(data)) {
|
|
79
80
|
throw new Error("param data must be an array");
|
|
@@ -84,33 +85,36 @@ export async function addUserCls({ name, alias, data, description, }, pg = pgCli
|
|
|
84
85
|
!data.find((item) => item.id && item.text)) {
|
|
85
86
|
throw new Error("param data must have items");
|
|
86
87
|
}
|
|
88
|
+
if (type === "sql") {
|
|
89
|
+
throw ForbiddenError("access restricted: creation of custom selects is not allowed");
|
|
90
|
+
await dataInsert({
|
|
91
|
+
pg: client,
|
|
92
|
+
table: "admin.user_cls",
|
|
93
|
+
data: { name, alias, description, type, data },
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else if (type === "json") {
|
|
97
|
+
await dataInsert({
|
|
98
|
+
pg: client,
|
|
99
|
+
table: "admin.user_cls",
|
|
100
|
+
data: { name, alias, description, type },
|
|
101
|
+
});
|
|
102
|
+
if (Array.isArray(data) && data.length) {
|
|
103
|
+
await Promise.all(data.map(async (item) => {
|
|
104
|
+
await dataInsert({
|
|
105
|
+
pg: client,
|
|
106
|
+
table: "admin.user_cls",
|
|
107
|
+
data: { ...item, code: item.id, name: item.text, parent: name },
|
|
108
|
+
});
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export async function addUserCls({ name, alias, data, description }, pg = pgClients.client) {
|
|
87
114
|
const client = await pg.connect();
|
|
88
115
|
try {
|
|
89
116
|
await client.query("begin");
|
|
90
|
-
|
|
91
|
-
throw ForbiddenError("access restricted: creation of custom selects is not allowed");
|
|
92
|
-
await dataInsert({
|
|
93
|
-
pg: client,
|
|
94
|
-
table: "admin.user_cls",
|
|
95
|
-
data: { name, alias, description, type, data },
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
else if (type === "json") {
|
|
99
|
-
await dataInsert({
|
|
100
|
-
pg: client,
|
|
101
|
-
table: "admin.user_cls",
|
|
102
|
-
data: { name, alias, description, type },
|
|
103
|
-
});
|
|
104
|
-
if (Array.isArray(data) && data.length) {
|
|
105
|
-
await Promise.all(data.map(async (item) => {
|
|
106
|
-
await dataInsert({
|
|
107
|
-
pg: client,
|
|
108
|
-
table: "admin.user_cls",
|
|
109
|
-
data: { ...item, code: item.id, name: item.text, parent: name },
|
|
110
|
-
});
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
117
|
+
await insertUserCls({ name, alias, data, description }, client);
|
|
114
118
|
await client.query("commit");
|
|
115
119
|
return "ok";
|
|
116
120
|
}
|
|
@@ -122,10 +126,22 @@ export async function addUserCls({ name, alias, data, description, }, pg = pgCli
|
|
|
122
126
|
client.release();
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
|
-
export async function editUserCls({ name, alias, description, data
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
export async function editUserCls({ name, alias, description, data }, pg = pgClients.client) {
|
|
130
|
+
const client = await pg.connect();
|
|
131
|
+
try {
|
|
132
|
+
await client.query("begin");
|
|
133
|
+
await deleteUserCls({ name }, client);
|
|
134
|
+
await insertUserCls({ name, alias, description, data }, client);
|
|
135
|
+
await client.query("commit");
|
|
136
|
+
return "ok";
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
await client.query("rollback");
|
|
140
|
+
throw err;
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
client.release();
|
|
144
|
+
}
|
|
129
145
|
}
|
|
130
146
|
export async function getUserClsList({ name, search, sql, custom, }, pg = pgClients.client) {
|
|
131
147
|
const args = [];
|
|
@@ -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":"AAmBA,wBAA8B,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,iBA8C9D"}
|
|
@@ -6,17 +6,27 @@ 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
8
|
const tags = ["core", "access"];
|
|
9
|
+
const packageName = "fastify-table";
|
|
9
10
|
export default async function route(fastify, opt = {}) {
|
|
10
|
-
fastify.get("/access-group/:id", {
|
|
11
|
-
|
|
11
|
+
fastify.get("/access-group/:id", {
|
|
12
|
+
config: { tags, package: packageName, role: "admin" },
|
|
13
|
+
schema: accessGroupSchema,
|
|
14
|
+
}, accessGroup);
|
|
15
|
+
fastify.post("/access-group/:id", {
|
|
16
|
+
config: { tags, package: packageName, role: "admin" },
|
|
17
|
+
schema: accessGroupPostSchema,
|
|
18
|
+
}, accessGroupPost);
|
|
12
19
|
fastify.get("/access-user/:id", {
|
|
13
|
-
config: { tags, permission: "admin.users.read" },
|
|
20
|
+
config: { tags, package: packageName, permission: "admin.users.read" },
|
|
14
21
|
schema: accessUserSchema,
|
|
15
22
|
}, accessUser);
|
|
16
23
|
fastify.post("/access-user/:id", {
|
|
17
|
-
config: { tags, permission: "admin.users.update" },
|
|
24
|
+
config: { tags, package: packageName, permission: "admin.users.update" },
|
|
18
25
|
schema: accessUserPostSchema,
|
|
19
26
|
}, accessUserPost);
|
|
20
|
-
fastify.get("/access-interface/:name", {
|
|
21
|
-
|
|
27
|
+
fastify.get("/access-interface/:name", {
|
|
28
|
+
config: { tags, package: packageName, role: "admin" },
|
|
29
|
+
schema: accessInterfaceSchema,
|
|
30
|
+
}, accessInterface);
|
|
31
|
+
fastify.get("/resources", { config: { tags, package: packageName, policy: "L0" } }, async () => publicResourcesList);
|
|
22
32
|
}
|
|
@@ -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":"AAgDA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAmGtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -21,7 +21,8 @@ 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
23
|
const tags = ["core", "auth"];
|
|
24
|
-
const
|
|
24
|
+
const packageName = "fastify-table";
|
|
25
|
+
const params = { config: { policy: "L0", tags, package: packageName } };
|
|
25
26
|
const registrationSchema = {
|
|
26
27
|
body: {
|
|
27
28
|
type: "object",
|
|
@@ -68,14 +69,14 @@ function plugin(app, opt = {}) {
|
|
|
68
69
|
app.get("/2factor/recovery", params, recovery);
|
|
69
70
|
}
|
|
70
71
|
if (!app.hasRoute({ method: "GET", url: "/2factor/reset" })) {
|
|
71
|
-
app.get("/2factor/reset", { config: { tags, role: "admin" } }, reset);
|
|
72
|
+
app.get("/2factor/reset", { config: { tags, package: packageName, role: "admin" } }, reset);
|
|
72
73
|
}
|
|
73
74
|
// get/edit user info
|
|
74
75
|
if (!app.hasRoute({ method: "GET", url: "/user" })) {
|
|
75
76
|
app.get("/user", params, getUserInfo);
|
|
76
77
|
}
|
|
77
78
|
if (!app.hasRoute({ method: "POST", url: "/user" })) {
|
|
78
|
-
app.post("/user", { config: { tags, auth: "creds" } }, updateUserInfo);
|
|
79
|
+
app.post("/user", { config: { tags, package: packageName, auth: "creds" } }, updateUserInfo);
|
|
79
80
|
}
|
|
80
81
|
// jwt
|
|
81
82
|
if (!app.hasRoute({ method: "GET", url: "/oauth/authorize" })) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/cron/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/cron/index.ts"],"names":[],"mappings":"AAmBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,QAEvB;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import cronApi from "./controllers/cronApi.js";
|
|
2
|
+
const tags = ["core", "cron"];
|
|
3
|
+
const packageName = "fastify-table";
|
|
2
4
|
const cronSchema = {
|
|
3
5
|
params: {
|
|
4
6
|
type: "object",
|
|
@@ -7,7 +9,11 @@ const cronSchema = {
|
|
|
7
9
|
},
|
|
8
10
|
},
|
|
9
11
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const adminParams = {
|
|
13
|
+
config: { role: "admin", tags, package: packageName },
|
|
14
|
+
schema: cronSchema,
|
|
15
|
+
};
|
|
16
|
+
function plugin(app) {
|
|
17
|
+
app.get("/cron/:name", adminParams, cronApi);
|
|
12
18
|
}
|
|
13
19
|
export default plugin;
|
|
@@ -101,7 +101,7 @@ export default async function update(req, reply) {
|
|
|
101
101
|
logger.file("injection/xss", { msg: xssCheck.error, table }, req);
|
|
102
102
|
throw ConflictError("Дані не пройшли валідацію. Приберіть некоректні дані та спробуйте ще раз");
|
|
103
103
|
}
|
|
104
|
-
const fieldCheck = validateData({ body, schema });
|
|
104
|
+
const fieldCheck = validateData({ body, schema, update: true });
|
|
105
105
|
if (fieldCheck.error) {
|
|
106
106
|
logger.file("injection/formdata", {
|
|
107
107
|
table,
|
|
@@ -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":"AAmBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAqDtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -13,21 +13,42 @@ const tableSchema = {
|
|
|
13
13
|
};
|
|
14
14
|
const policy = "L0";
|
|
15
15
|
const tags = ["core", "crud"];
|
|
16
|
+
const packageName = "fastify-table";
|
|
16
17
|
function plugin(app, opt = {}) {
|
|
17
18
|
app.put("/table/:table/:id?", {
|
|
18
|
-
config: {
|
|
19
|
+
config: {
|
|
20
|
+
tags,
|
|
21
|
+
package: packageName,
|
|
22
|
+
policy,
|
|
23
|
+
summary: "Edit table data",
|
|
24
|
+
},
|
|
19
25
|
schema: tableSchema,
|
|
20
26
|
}, update);
|
|
21
27
|
app.delete("/table/:table/:id?", {
|
|
22
|
-
config: {
|
|
28
|
+
config: {
|
|
29
|
+
tags,
|
|
30
|
+
package: packageName,
|
|
31
|
+
policy,
|
|
32
|
+
summary: "Delete table data",
|
|
33
|
+
},
|
|
23
34
|
schema: tableSchema,
|
|
24
35
|
}, deleteCrud);
|
|
25
36
|
app.post("/table/:table/:id?", {
|
|
26
|
-
config: {
|
|
37
|
+
config: {
|
|
38
|
+
tags,
|
|
39
|
+
package: packageName,
|
|
40
|
+
policy,
|
|
41
|
+
summary: "Add table data",
|
|
42
|
+
},
|
|
27
43
|
schema: tableSchema,
|
|
28
44
|
}, insert);
|
|
29
45
|
app.get("/table/:table/:id?", {
|
|
30
|
-
config: {
|
|
46
|
+
config: {
|
|
47
|
+
tags,
|
|
48
|
+
package: packageName,
|
|
49
|
+
policy,
|
|
50
|
+
summary: "Get table data",
|
|
51
|
+
},
|
|
31
52
|
schema: tableSchema,
|
|
32
53
|
}, table);
|
|
33
54
|
}
|
|
@@ -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":"AAQA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QAiBtC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import readItemList from "./controllers/readItems.js";
|
|
2
2
|
import setItem from "./controllers/setItem.js";
|
|
3
|
+
const packageName = "fastify-table";
|
|
3
4
|
const params = {
|
|
4
|
-
config: { policy: "L0", tags: ["core", "dblist"] },
|
|
5
|
+
config: { policy: "L0", tags: ["core", "dblist"], package: packageName },
|
|
5
6
|
};
|
|
6
7
|
export default function plugin(app) {
|
|
7
8
|
if (!app.hasRoute({ method: "GET", url: "/db-list" })) {
|
|
@@ -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":"AAyBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAqCtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -9,9 +9,14 @@ import uploadImage from "./controllers/uploadImage.js";
|
|
|
9
9
|
import deleteFileAPI from "./controllers/delete.js";
|
|
10
10
|
import { resizeSchema, exportSchema } from "./schema.js";
|
|
11
11
|
const tags = ["core", "file"];
|
|
12
|
+
const packageName = "fastify-table";
|
|
12
13
|
const { uploadPolicy = "L1" } = config;
|
|
13
|
-
const publicParams = {
|
|
14
|
-
|
|
14
|
+
const publicParams = {
|
|
15
|
+
config: { tags, policy: "L0", package: packageName },
|
|
16
|
+
};
|
|
17
|
+
const privateParams = {
|
|
18
|
+
config: { tags, policy: uploadPolicy, package: packageName },
|
|
19
|
+
};
|
|
15
20
|
function plugin(app, opt = {}) {
|
|
16
21
|
app.get("/files/*", publicParams, files);
|
|
17
22
|
if (!app.hasRoute({ method: "GET", url: "/file/resize" })) {
|
|
@@ -19,7 +24,7 @@ function plugin(app, opt = {}) {
|
|
|
19
24
|
method: "GET",
|
|
20
25
|
url: "/file/resize",
|
|
21
26
|
config: {
|
|
22
|
-
...publicParams,
|
|
27
|
+
...publicParams.config,
|
|
23
28
|
rateLimit: config.rateLimit
|
|
24
29
|
? {
|
|
25
30
|
max: +(config.rateLimit?.resize?.max || 1000),
|
|
@@ -34,7 +39,7 @@ function plugin(app, opt = {}) {
|
|
|
34
39
|
app.route({
|
|
35
40
|
method: "GET",
|
|
36
41
|
url: "/api/resize-all",
|
|
37
|
-
config: { tags, role: "admin" },
|
|
42
|
+
config: { tags, package: packageName, role: "admin" },
|
|
38
43
|
schema: resizeSchema,
|
|
39
44
|
handler: resizeAll,
|
|
40
45
|
});
|
|
@@ -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":"AAQA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,QAGvB;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import file2geojson from "./controllers/file2geojson.js";
|
|
2
2
|
import filePreview from "./controllers/filePreview.js";
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const packageName = "fastify-table";
|
|
4
|
+
const publicParams = {
|
|
5
|
+
config: { policy: "L0", tags: ["core", "grpc"], package: packageName },
|
|
6
|
+
};
|
|
7
|
+
function plugin(app) {
|
|
5
8
|
app.post("/file2geojson", publicParams, file2geojson);
|
|
6
9
|
app.get("/file-preview", publicParams, filePreview);
|
|
7
10
|
}
|
|
@@ -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":"AAuBA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,QAOvB;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -2,7 +2,10 @@ 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
4
|
const tags = ["core", "logger"];
|
|
5
|
-
const
|
|
5
|
+
const packageName = "fastify-table";
|
|
6
|
+
const publicParams = {
|
|
7
|
+
config: { tags, package: packageName, policy: "L0", rateLimit: false },
|
|
8
|
+
};
|
|
6
9
|
const loggerSchema = {
|
|
7
10
|
querystring: {
|
|
8
11
|
type: "object",
|
|
@@ -15,7 +18,7 @@ const loggerSchema = {
|
|
|
15
18
|
additionalProperties: false,
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
|
-
function plugin(app
|
|
21
|
+
function plugin(app) {
|
|
19
22
|
app.get("/logger-file/*", { ...publicParams, schema: loggerSchema }, loggerFile);
|
|
20
23
|
app.get("/logger-metrics", publicParams, loggerMetrics);
|
|
21
24
|
}
|
|
@@ -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":"AAcA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAGpD"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import getMenu from "./controllers/getMenu.js";
|
|
2
2
|
import interfaces from "./controllers/interfaces.js";
|
|
3
3
|
const tags = ["core", "menu"];
|
|
4
|
+
const packageName = "fastify-table";
|
|
4
5
|
const publicParams = {
|
|
5
|
-
config: { tags },
|
|
6
|
+
config: { tags, package: packageName },
|
|
6
7
|
};
|
|
7
8
|
const params = {
|
|
8
|
-
config: { tags, role: "admin" },
|
|
9
|
+
config: { tags, package: packageName, role: "admin" },
|
|
9
10
|
};
|
|
10
11
|
export default function route(app, opt = {}) {
|
|
11
12
|
app.get("/user-menu", publicParams, getMenu);
|
|
@@ -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":"AAeA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,QAgBrC"}
|
|
@@ -3,8 +3,13 @@ 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 packageName = "fastify-table";
|
|
6
7
|
const params = {
|
|
7
|
-
config: {
|
|
8
|
+
config: {
|
|
9
|
+
policy: "L1",
|
|
10
|
+
tags: ["core", "notifications"],
|
|
11
|
+
package: packageName,
|
|
12
|
+
},
|
|
8
13
|
};
|
|
9
14
|
export default function route(app) {
|
|
10
15
|
if (!app.hasRoute({ method: "GET", url: "/notification" })) {
|
|
@@ -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":"AAeA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAiBtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import getAppSettings from "./controllers/properties.get.js";
|
|
2
2
|
import postAppSettings from "./controllers/properties.post.js";
|
|
3
3
|
const tags = ["core", "properties"];
|
|
4
|
+
const packageName = "fastify-table";
|
|
4
5
|
const propertiesSchema = {
|
|
5
6
|
params: {
|
|
6
7
|
type: "object",
|
|
@@ -10,7 +11,13 @@ const propertiesSchema = {
|
|
|
10
11
|
},
|
|
11
12
|
};
|
|
12
13
|
function plugin(app, opt = {}) {
|
|
13
|
-
app.get("/settings-app/:entity?", {
|
|
14
|
-
|
|
14
|
+
app.get("/settings-app/:entity?", {
|
|
15
|
+
config: { tags, package: packageName, policy: "L0" },
|
|
16
|
+
schema: propertiesSchema,
|
|
17
|
+
}, getAppSettings);
|
|
18
|
+
app.post("/settings-app/:entity?", {
|
|
19
|
+
config: { tags, package: packageName, role: "admin" },
|
|
20
|
+
schema: propertiesSchema,
|
|
21
|
+
}, postAppSettings);
|
|
15
22
|
}
|
|
16
23
|
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":"AAiCA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAsGtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -14,14 +14,16 @@ 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 packageName = "fastify-table";
|
|
17
18
|
const tags = ["core", "table"];
|
|
18
19
|
function plugin(app, opt = {}) {
|
|
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);
|
|
20
|
+
app.get("/token-info/:token", { config: { tags, package: packageName, role: "admin" } }, tokenInfo);
|
|
21
|
+
app.get("/table-filter/:table", { config: { tags, package: packageName, policy }, schema: filterSchema }, filter);
|
|
22
|
+
app.get("/table-info/:table/:id?", { config: { tags, package: packageName, policy }, schema: tableDataSchema }, tableInfo);
|
|
22
23
|
app.get("/suggest/:data", {
|
|
23
24
|
config: {
|
|
24
25
|
tags,
|
|
26
|
+
package: packageName,
|
|
25
27
|
policy,
|
|
26
28
|
rateLimit: config.rateLimit
|
|
27
29
|
? {
|
|
@@ -32,15 +34,27 @@ function plugin(app, opt = {}) {
|
|
|
32
34
|
},
|
|
33
35
|
schema: suggestSchema,
|
|
34
36
|
}, suggest);
|
|
35
|
-
app.get("/data/:table/:id?", { config: { tags, policy }, schema: tableSchema }, data);
|
|
36
|
-
app.get("/table-data/:table", {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
app.get("/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
app.get("/
|
|
37
|
+
app.get("/data/:table/:id?", { config: { tags, package: packageName, policy }, schema: tableSchema }, data);
|
|
38
|
+
app.get("/table-data/:table", {
|
|
39
|
+
config: { tags, package: packageName, auth: "creds", policy: "L2" },
|
|
40
|
+
schema: tableDataSchema,
|
|
41
|
+
}, data);
|
|
42
|
+
app.get("/table-data/:table/:id", {
|
|
43
|
+
config: { tags, package: packageName, policy },
|
|
44
|
+
schema: tableDataIdSchema,
|
|
45
|
+
}, cardData);
|
|
46
|
+
app.get("/data-info/:id?", { config: { tags, package: packageName, policy }, schema: tableSchema }, dataInfo);
|
|
47
|
+
app.get("/card-data/:token", {
|
|
48
|
+
config: { tags, package: packageName, policy },
|
|
49
|
+
schema: cardTabDataSchema,
|
|
50
|
+
}, cardTabData);
|
|
51
|
+
app.get("/card/:table/:id", { config: { tags, package: packageName, policy }, schema: tableSchema }, card);
|
|
52
|
+
app.get("/search", { config: { tags, package: packageName, policy }, schema: searchSchema }, search);
|
|
53
|
+
app.get("/templates", { config: { tags, package: packageName } }, () => loadTemplatePath);
|
|
54
|
+
app.get("/filter/:table", { config: { tags, package: packageName, policy }, schema: filterSchema }, filter);
|
|
55
|
+
app.get("/form/:name/:id?", {
|
|
56
|
+
config: { tags, package: packageName, auth: "creds", policy: "L2" },
|
|
57
|
+
schema: formSchema,
|
|
58
|
+
}, form);
|
|
45
59
|
}
|
|
46
60
|
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":"AAQA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAQpD"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import getTemplateApi from "./controllers/getTemplate.js";
|
|
2
2
|
import { getTemplateSchema } from "./schema.js";
|
|
3
3
|
const policy = "L0";
|
|
4
|
+
const packageName = "fastify-table";
|
|
4
5
|
const tags = ["core", "templates"];
|
|
5
6
|
export default function route(app, opt = {}) {
|
|
6
7
|
app.route({
|
|
7
8
|
method: "GET",
|
|
8
9
|
url: "/template/:type/:name",
|
|
9
|
-
config: { tags, policy },
|
|
10
|
+
config: { tags, package: packageName, policy },
|
|
10
11
|
schema: getTemplateSchema,
|
|
11
12
|
handler: getTemplateApi,
|
|
12
13
|
});
|
|
@@ -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":"AAaA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QA8GtC"}
|
|
@@ -6,12 +6,14 @@ import uploadChunk from "../../plugins/upload/uploadChunk.js";
|
|
|
6
6
|
import getUploadStatus from "../../plugins/upload/getUploadStatus.js";
|
|
7
7
|
import { BadRequestError, LengthRequiredError } from "../../../errors.js";
|
|
8
8
|
const tags = ["core", "upload"];
|
|
9
|
+
const packageName = "fastify-table";
|
|
9
10
|
export default function plugin(app) {
|
|
10
11
|
// provide server with metadata for chunked upload
|
|
11
12
|
app.post(`/${prefix}/start`, {
|
|
12
13
|
config: {
|
|
13
14
|
tags,
|
|
14
|
-
|
|
15
|
+
package: packageName,
|
|
16
|
+
summary: "Init chunked upload",
|
|
15
17
|
policy: uploadPolicy,
|
|
16
18
|
},
|
|
17
19
|
}, async (req) => {
|
|
@@ -35,7 +37,8 @@ export default function plugin(app) {
|
|
|
35
37
|
app.patch(`/${prefix}/:id`, {
|
|
36
38
|
config: {
|
|
37
39
|
tags,
|
|
38
|
-
|
|
40
|
+
package: packageName,
|
|
41
|
+
summary: "Upload chunk of data",
|
|
39
42
|
policy: uploadPolicy,
|
|
40
43
|
rateLimit: config.rateLimit
|
|
41
44
|
? {
|
|
@@ -72,7 +75,8 @@ export default function plugin(app) {
|
|
|
72
75
|
app.get(`/${prefix}/:id`, {
|
|
73
76
|
config: {
|
|
74
77
|
tags,
|
|
75
|
-
|
|
78
|
+
package: packageName,
|
|
79
|
+
summary: "Check chunked upload status",
|
|
76
80
|
policy: uploadPolicy,
|
|
77
81
|
},
|
|
78
82
|
}, async (req) => {
|
|
@@ -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":"AAoCA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QAsDtC"}
|
|
@@ -28,19 +28,20 @@ import addUserCls from "./controllers/addUserCls.js";
|
|
|
28
28
|
import editUserCls from "./controllers/editUserCls.js";
|
|
29
29
|
import deleteUserCls from "./controllers/deleteUserCls.js";
|
|
30
30
|
const tags = ["core", "usercls"];
|
|
31
|
+
const packageName = "fastify-table";
|
|
31
32
|
export default function plugin(app) {
|
|
32
33
|
if (!app.hasRoute({ method: "GET", url: "/api/user-cls" })) {
|
|
33
|
-
app.get("/user-cls", { config: { tags, policy: "L1" } }, getUserCls);
|
|
34
|
+
app.get("/user-cls", { config: { tags, package: packageName, policy: "L1" } }, getUserCls);
|
|
34
35
|
}
|
|
35
36
|
if (!app.hasRoute({ method: "POST", url: "/api/user-cls" })) {
|
|
36
37
|
app.post("/user-cls", {
|
|
37
|
-
config: { tags, policy: "L1" },
|
|
38
|
+
config: { tags, package: packageName, policy: "L1" },
|
|
38
39
|
schema: { body: addUserClsBodySchema },
|
|
39
40
|
}, addUserCls);
|
|
40
41
|
}
|
|
41
42
|
if (!app.hasRoute({ method: "PUT", url: "/api/user-cls/:name" })) {
|
|
42
43
|
app.put("/user-cls/:name", {
|
|
43
|
-
config: { tags, policy: "L1" },
|
|
44
|
+
config: { tags, package: packageName, policy: "L1" },
|
|
44
45
|
schema: {
|
|
45
46
|
params: userClsParamsSchema,
|
|
46
47
|
body: editUserClsBodySchema,
|
|
@@ -49,13 +50,13 @@ export default function plugin(app) {
|
|
|
49
50
|
}
|
|
50
51
|
if (!app.hasRoute({ method: "DELETE", url: "/api/user-cls/:name" })) {
|
|
51
52
|
app.delete("/user-cls/:name", {
|
|
52
|
-
config: { tags, policy: "L1" },
|
|
53
|
+
config: { tags, package: packageName, policy: "L1" },
|
|
53
54
|
schema: { params: userClsParamsSchema },
|
|
54
55
|
}, deleteUserCls);
|
|
55
56
|
}
|
|
56
57
|
if (!app.hasRoute({ method: "DELETE", url: "/api/user-cls/:name/:code" })) {
|
|
57
58
|
app.delete("/user-cls/:name/:code", {
|
|
58
|
-
config: { tags, policy: "L1" },
|
|
59
|
+
config: { tags, package: packageName, policy: "L1" },
|
|
59
60
|
schema: { params: userClsParamsSchema },
|
|
60
61
|
}, deleteUserCls);
|
|
61
62
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export default function apiListService({ includeTags: queryIncludeTags, excludeTags: queryExcludeTags, packageName, subdir, md, routes, }: {
|
|
1
|
+
export default function apiListService({ includeTags: queryIncludeTags, excludeTags: queryExcludeTags, excludePackage: queryExcludePackage, packageName, subdir, md, routes, }: {
|
|
2
2
|
includeTags?: any;
|
|
3
3
|
excludeTags?: any;
|
|
4
|
+
excludePackage?: any;
|
|
4
5
|
packageName?: string;
|
|
5
6
|
subdir?: string;
|
|
6
7
|
md?: string;
|
|
@@ -1 +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;;;;;;;;;;
|
|
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,cAAc,EAAE,mBAAmB,EACnC,WAAW,EACX,MAAM,EACN,EAAE,EACF,MAAM,GACP,EAAE;IACD,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,GAAG,EAAE,CAAC;CACf;;;;;;;;;;EAmDA"}
|
|
@@ -26,13 +26,16 @@ function toMarkdownTable(data, columns) {
|
|
|
26
26
|
});
|
|
27
27
|
return [header, separator, ...rows].join("\n");
|
|
28
28
|
}
|
|
29
|
-
export default function apiListService({ includeTags: queryIncludeTags, excludeTags: queryExcludeTags, packageName, subdir, md, routes, }) {
|
|
29
|
+
export default function apiListService({ includeTags: queryIncludeTags, excludeTags: queryExcludeTags, excludePackage: queryExcludePackage, packageName, subdir, md, routes, }) {
|
|
30
30
|
const includeTags = queryIncludeTags
|
|
31
31
|
? new Set(queryIncludeTags?.split("|"))
|
|
32
32
|
: undefined;
|
|
33
33
|
const excludeTags = queryExcludeTags
|
|
34
34
|
? new Set(queryExcludeTags?.split("|"))
|
|
35
35
|
: undefined;
|
|
36
|
+
const excludePackage = queryExcludePackage
|
|
37
|
+
? new Set(queryExcludePackage?.split("|"))
|
|
38
|
+
: undefined;
|
|
36
39
|
const filteredRoutes = excludeTags
|
|
37
40
|
? routes.filter((r) => !r.tags || !r.tags.find((tag) => excludeTags.has(tag)))
|
|
38
41
|
: routes;
|
|
@@ -45,8 +48,11 @@ export default function apiListService({ includeTags: queryIncludeTags, excludeT
|
|
|
45
48
|
const filteredRoutes3 = packageName
|
|
46
49
|
? filteredRoutes2.filter((r) => r.package === packageName)
|
|
47
50
|
: filteredRoutes2;
|
|
51
|
+
const filteredRoutes4 = excludePackage
|
|
52
|
+
? filteredRoutes3.filter((r) => !excludePackage.has(r.package))
|
|
53
|
+
: filteredRoutes3;
|
|
48
54
|
if (md) {
|
|
49
|
-
const markdownStr = toMarkdownTable(
|
|
55
|
+
const markdownStr = toMarkdownTable(filteredRoutes4, Array.isArray(columns) ? columns : columns.split("|"));
|
|
50
56
|
return {
|
|
51
57
|
headers: {
|
|
52
58
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
@@ -54,5 +60,5 @@ export default function apiListService({ includeTags: queryIncludeTags, excludeT
|
|
|
54
60
|
data: markdownStr,
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
|
-
return { rows:
|
|
63
|
+
return { rows: filteredRoutes4 };
|
|
58
64
|
}
|
|
@@ -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":"AAaA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QA4CtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -6,17 +6,18 @@ import codeGenerator from "./controllers/code.generator.js";
|
|
|
6
6
|
import dependencies from "./controllers/dependencies.js";
|
|
7
7
|
import apiCheck from "./controllers/api.check.js";
|
|
8
8
|
const tags = ["core", "util"];
|
|
9
|
+
const packageName = "fastify-table";
|
|
9
10
|
function plugin(app, opt = {}) {
|
|
10
|
-
app.get("/next-id", { config: { tags, policy: "L0" } }, nextId);
|
|
11
|
-
app.get("/check", { config: { tags, role: "admin" } }, apiCheck);
|
|
12
|
-
app.get("/status-monitor", { config: { tags, role: "admin" } }, statusMonitor);
|
|
13
|
-
app.get("/user-tokens/:token", { config: { tags, role: "admin|regular" } }, userTokens);
|
|
14
|
-
app.get("/code-gen/:token/:column/:id?", { config: { tags, role: "admin|regular" } }, codeGenerator);
|
|
15
|
-
app.get("/test-proxy", { config: { tags, policy: "L0" } }, (req) => ({
|
|
11
|
+
app.get("/next-id", { config: { tags, package: packageName, policy: "L0" } }, nextId);
|
|
12
|
+
app.get("/check", { config: { tags, package: packageName, role: "admin" } }, apiCheck);
|
|
13
|
+
app.get("/status-monitor", { config: { tags, package: packageName, role: "admin" } }, statusMonitor);
|
|
14
|
+
app.get("/user-tokens/:token", { config: { tags, package: packageName, role: "admin|regular" } }, userTokens);
|
|
15
|
+
app.get("/code-gen/:token/:column/:id?", { config: { tags, package: packageName, role: "admin|regular" } }, codeGenerator);
|
|
16
|
+
app.get("/test-proxy", { config: { tags, package: packageName, policy: "L0" } }, (req) => ({
|
|
16
17
|
...(req.headers || {}),
|
|
17
18
|
sessionId: req.session?.sessionId,
|
|
18
19
|
}));
|
|
19
|
-
app.get("/config", { config: { tags, policy: "L0" /*role: "admin"*/ } }, apiConfig);
|
|
20
|
-
app.get("/dependencies", { config: { tags, policy: "L1", role: "admin" } }, dependencies);
|
|
20
|
+
app.get("/config", { config: { tags, package: packageName, policy: "L0" /*role: "admin"*/ } }, apiConfig);
|
|
21
|
+
app.get("/dependencies", { config: { tags, package: packageName, policy: "L1", role: "admin" } }, dependencies);
|
|
21
22
|
}
|
|
22
23
|
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":"AAwDA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,QAiIrC"}
|
|
@@ -11,6 +11,7 @@ import widgetEntityDel from "./services/widget.entity.del.js";
|
|
|
11
11
|
import uploadMultiPart from "../../plugins/file/uploadMultiPart.js";
|
|
12
12
|
import { UnauthorizedError } from "../../../errors.js";
|
|
13
13
|
const tags = ["core", "widget"];
|
|
14
|
+
const packageName = "fastify-table";
|
|
14
15
|
const { uploadPolicy = "L1" } = config;
|
|
15
16
|
const tableSchema = {
|
|
16
17
|
params: {
|
|
@@ -40,7 +41,10 @@ const tableSchema = {
|
|
|
40
41
|
},
|
|
41
42
|
};
|
|
42
43
|
addHook("onWidgetSet", onWidgetSet);
|
|
43
|
-
const publicParams = {
|
|
44
|
+
const publicParams = {
|
|
45
|
+
config: { tags, package: packageName, policy: "L0" },
|
|
46
|
+
schema: tableSchema,
|
|
47
|
+
};
|
|
44
48
|
export default function route(app) {
|
|
45
49
|
app.get("/v2/widget/:type/:entityType/:objectid", publicParams, async (req) => {
|
|
46
50
|
const result = await widgetEntityGet({
|