@opengis/fastify-table 2.0.116 → 2.0.118
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/helper.d.ts.map +1 -1
- package/dist/helper.js +3 -0
- package/dist/server/plugins/auth/index.js +1 -1
- package/dist/server/routes/auth/controllers/core/getUserInfo.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/core/getUserInfo.js +9 -1
- package/dist/server/routes/auth/index.d.ts.map +1 -1
- package/dist/server/routes/auth/index.js +14 -1
- package/dist/server/routes/file/controllers/resizeAll.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/resizeAll.js +6 -4
- package/dist/server/routes/table/functions/getData.js +1 -1
- package/package.json +93 -93
package/dist/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../helper.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AAEvD,QAAA,MAAQ,MAAM,KAAoB,CAAC;AAInC,wBAAsB,KAAK,kBAI1B;AAGD,wBAAsB,QAAQ,kBAW7B;AAED,wBAAgB,KAAK,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../helper.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AAEvD,QAAA,MAAQ,MAAM,KAAoB,CAAC;AAInC,wBAAsB,KAAK,kBAI1B;AAGD,wBAAsB,QAAQ,kBAW7B;AAED,wBAAgB,KAAK,QAWpB;AAED,OAAO,EAEL,MAAM,EACN,MAAM,EACN,SAAS,GACV,CAAC"}
|
package/dist/helper.js
CHANGED
|
@@ -24,6 +24,9 @@ export function build() {
|
|
|
24
24
|
if (!app) {
|
|
25
25
|
app = Fastify({ logger: false });
|
|
26
26
|
app.register(appService, config);
|
|
27
|
+
app.addHook("onRequest", async (req) => {
|
|
28
|
+
req.user = req.user || { uid: "1", user_type: "admin" };
|
|
29
|
+
});
|
|
27
30
|
addTemplateDir(path.join(process.cwd(), "module/test"));
|
|
28
31
|
// await app.ready(); // ? ensure plugins registered, can not add fastify hooks after app is ready
|
|
29
32
|
}
|
|
@@ -10,7 +10,7 @@ const { prefix = "/api" } = config;
|
|
|
10
10
|
export async function onRequest(req, reply) {
|
|
11
11
|
const { hostname, headers, routeOptions } = req;
|
|
12
12
|
const { config: routeConfig, method, handler, url } = routeOptions || {};
|
|
13
|
-
const { policy } = routeConfig;
|
|
13
|
+
const { policy } = routeConfig || {};
|
|
14
14
|
const isApi = method && url && typeof handler === "function" && url !== "*";
|
|
15
15
|
// handle non-api at vite/vike
|
|
16
16
|
if (!isApi) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserInfo.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/getUserInfo.ts"],"names":[],"mappings":"AAiCA,wBAA8B,WAAW,CAAC,GAAG,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"getUserInfo.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/getUserInfo.ts"],"names":[],"mappings":"AAiCA,wBAA8B,WAAW,CAAC,GAAG,EAAE,GAAG,eAkEjD"}
|
|
@@ -45,7 +45,15 @@ export default async function getUserInfo(req) {
|
|
|
45
45
|
}
|
|
46
46
|
const userInfo = Object.fromEntries(Object.entries(req.user).filter(([key]) => !["salt", "password"].includes(key)));
|
|
47
47
|
const { rows = [] } = req.pg?.pk?.["admin.properties"]
|
|
48
|
-
? await req.pg.query(`select
|
|
48
|
+
? await req.pg.query(`select
|
|
49
|
+
property_key as key,
|
|
50
|
+
case
|
|
51
|
+
when property_text is not null then to_jsonb(property_text)
|
|
52
|
+
when property_int is not null then to_jsonb(property_int)
|
|
53
|
+
when property_json is not null then property_json::jsonb
|
|
54
|
+
end as val
|
|
55
|
+
from admin.properties
|
|
56
|
+
where property_key~'^(${config.settingKeys || "site|map|admin"})'`)
|
|
49
57
|
: {};
|
|
50
58
|
const settings = rows.reduce((p, { key, val }) => {
|
|
51
59
|
const [k1, k2] = key.split(".");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkD1C,iBAAS,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,GAAE,GAAQ,QAqFlD;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -21,6 +21,19 @@ 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 params = { config: { policy: "L0" } };
|
|
24
|
+
const registrationSchema = {
|
|
25
|
+
body: {
|
|
26
|
+
type: "object",
|
|
27
|
+
required: ["password"],
|
|
28
|
+
properties: {
|
|
29
|
+
password: { type: "string", minLength: 6, maxLength: 100 },
|
|
30
|
+
email: { type: "string", format: "email" },
|
|
31
|
+
login: { type: "string" },
|
|
32
|
+
first_name: { type: "string" },
|
|
33
|
+
last_name: { type: "string" },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
24
37
|
function plugin(app, opt = {}) {
|
|
25
38
|
if (opt.routes === false || config.auth?.customRoutes) {
|
|
26
39
|
return;
|
|
@@ -35,7 +48,7 @@ function plugin(app, opt = {}) {
|
|
|
35
48
|
app.post("/api/login", params, login);
|
|
36
49
|
}
|
|
37
50
|
if (!app.hasRoute({ method: "POST", url: "/api/registration" })) {
|
|
38
|
-
app.post("/api/registration", params, registration);
|
|
51
|
+
app.post("/api/registration", { ...params, schema: registrationSchema }, registration);
|
|
39
52
|
}
|
|
40
53
|
if (!app.hasRoute({ method: "POST", url: "/api/recovery" })) {
|
|
41
54
|
app.post("/api/recovery", params, passwordRecovery);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizeAll.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/resizeAll.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resizeAll.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/resizeAll.ts"],"names":[],"mappings":"AAkHA,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAsH3D"}
|
|
@@ -4,7 +4,7 @@ import { pgClients, eventStream, logger, isFileExists, downloadFile, uploadFile,
|
|
|
4
4
|
import grpc from "../../../plugins/grpc/grpc.js";
|
|
5
5
|
import { images } from "../../../plugins/file/utils/allowedExtensions.js";
|
|
6
6
|
const { resizeImage } = grpc();
|
|
7
|
-
async function resizeOne({ relpath: relpath1, resizeQuality = 80, maxWidth = 2048, errors = [], success = [], notfound = [], equalwidth = [], send = () => { },
|
|
7
|
+
async function resizeOne({ relpath: relpath1, resizeQuality = 80, maxWidth = 2048, errors = [], success = [], notfound = [], equalwidth = [], send = () => { }, }) {
|
|
8
8
|
const exists = await isFileExists(relpath1);
|
|
9
9
|
const existsOriginal = await isFileExists(relpath1.replace("files/", "files/original/"));
|
|
10
10
|
const relpath = existsOriginal
|
|
@@ -42,6 +42,7 @@ async function resizeOne({ relpath: relpath1, resizeQuality = 80, maxWidth = 204
|
|
|
42
42
|
const resizeHeight = resizeWidth / ratio;
|
|
43
43
|
send(`original ${relpath} width/height/ratio: ${width} / ${height} / ${ratio}`);
|
|
44
44
|
send(`resize ${relpath} width/height/ratio/quality: ${resizeWidth} / ${resizeHeight} / ${resizeWidth / resizeHeight} / ${resizeQuality}`);
|
|
45
|
+
const unittest = process.env.NODE_ENV === "test" || process.env.VITEST;
|
|
45
46
|
// skip for resize with small unit test image
|
|
46
47
|
if (resizeWidth === width && !unittest) {
|
|
47
48
|
send(`resize ${relpath} skip: resize width equals to original`);
|
|
@@ -60,7 +61,7 @@ async function resizeOne({ relpath: relpath1, resizeQuality = 80, maxWidth = 204
|
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
62
63
|
export default async function resizeAll(req, reply) {
|
|
63
|
-
const { pg = pgClients.client, query = {}
|
|
64
|
+
const { pg = pgClients.client, query = {} } = req;
|
|
64
65
|
const { nocache, filepath, quality = 80, limit, sql, w = 2048 } = query;
|
|
65
66
|
if (nocache) {
|
|
66
67
|
const clearQ = `update crm.files set resized=null
|
|
@@ -87,7 +88,9 @@ export default async function resizeAll(req, reply) {
|
|
|
87
88
|
const errors = [];
|
|
88
89
|
const notfound = [];
|
|
89
90
|
const equalwidth = [];
|
|
90
|
-
const send =
|
|
91
|
+
const send = process.env.NODE_ENV === "test" || process.env.VITEST
|
|
92
|
+
? console.log
|
|
93
|
+
: eventStream(reply);
|
|
91
94
|
try {
|
|
92
95
|
send(`file max resize width: ${w}`);
|
|
93
96
|
send(`file max resize quality: ${resizeQuality}`);
|
|
@@ -104,7 +107,6 @@ export default async function resizeAll(req, reply) {
|
|
|
104
107
|
notfound,
|
|
105
108
|
equalwidth,
|
|
106
109
|
send,
|
|
107
|
-
unittest,
|
|
108
110
|
})), Promise.resolve());
|
|
109
111
|
if (success.length) {
|
|
110
112
|
await pg.query("update crm.files set resized=true where file_path=any($1::text[])", [success]);
|
|
@@ -395,7 +395,7 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
395
395
|
from (select * ${sql
|
|
396
396
|
?.filter((el) => el.inline)
|
|
397
397
|
.map((el) => `,(${el.sql})`)
|
|
398
|
-
.join("") || ""} from ${viewSql ? `(${viewSql})` : table1} t ${sqlTable})
|
|
398
|
+
.join("") || ""} from ${viewSql ? `(${viewSql})` : table1} t ${sqlTable})t
|
|
399
399
|
where ${[loadTable?.query, tokenData?.query, accessQuery, contextQuery]
|
|
400
400
|
.filter(Boolean)
|
|
401
401
|
.filter((el) => checkQuery(el))
|
package/package.json
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "core-plugins",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"fastify",
|
|
8
|
-
"table",
|
|
9
|
-
"crud",
|
|
10
|
-
"auth",
|
|
11
|
-
"pg",
|
|
12
|
-
"backend"
|
|
13
|
-
],
|
|
14
|
-
"main": "dist/index.js",
|
|
15
|
-
"exports": {
|
|
16
|
-
".": "./dist/index.js",
|
|
17
|
-
"./index.js": "./dist/index.js",
|
|
18
|
-
"./utils.js": "./dist/utils.js"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist/*"
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"dump": "bun ./script/dump.ts",
|
|
25
|
-
"migrate": "MIGRATE=true bun ./script/migrate.ts",
|
|
26
|
-
"dump1": "bun ./dist/script/dump.js",
|
|
27
|
-
"migrate1": "MIGRATE=true bun ./dist/script/migrate.js",
|
|
28
|
-
"prepublishOnly": "npm run build",
|
|
29
|
-
"clean": "tsc -b --clean",
|
|
30
|
-
"build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist && copyfiles server/templates/**/*.hbs dist && copyfiles script/* dist && copyfiles -u 2 module/core/*/* dist/module/core",
|
|
31
|
-
"prod": "NODE_ENV=production bun dist/server",
|
|
32
|
-
"patch": "npm version patch && git push && npm publish",
|
|
33
|
-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
34
|
-
"test": "npx vitest run",
|
|
35
|
-
"compress": "node compress.js",
|
|
36
|
-
"dev1": "bun --hot dist/server",
|
|
37
|
-
"dev": "NODE_ENV=production bun start",
|
|
38
|
-
"start": "LOG_LEVEL=trace bun server"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@aws-sdk/client-s3": "3.879.0",
|
|
42
|
-
"@aws-sdk/lib-storage": "3.879.0",
|
|
43
|
-
"@fastify/cookie": "11.0.2",
|
|
44
|
-
"@fastify/http-proxy": "11.1.2",
|
|
45
|
-
"@fastify/multipart": "9.0.3",
|
|
46
|
-
"@fastify/passport": "3.0.2",
|
|
47
|
-
"@fastify/rate-limit": "10.3.0",
|
|
48
|
-
"@fastify/session": "11.1.0",
|
|
49
|
-
"@grpc/grpc-js": "1.10.11",
|
|
50
|
-
"@grpc/proto-loader": "0.7.15",
|
|
51
|
-
"apache-crypt": "1.2.6",
|
|
52
|
-
"better-sqlite3": "12.2.0",
|
|
53
|
-
"dotenv": "16.5.0",
|
|
54
|
-
"fastify": "5.3.3",
|
|
55
|
-
"fastify-plugin": "5.0.1",
|
|
56
|
-
"fastify-session-redis-store": "7.1.2",
|
|
57
|
-
"handlebars": "4.7.8",
|
|
58
|
-
"image-size": "1.2.0",
|
|
59
|
-
"ioredis": "5.3.2",
|
|
60
|
-
"js-yaml": "4.1.0",
|
|
61
|
-
"markdown-it": "14.1.0",
|
|
62
|
-
"nodemailer": "7.0.6",
|
|
63
|
-
"otplib": "12.0.1",
|
|
64
|
-
"pg": "8.11.6",
|
|
65
|
-
"pino": "9.5.0",
|
|
66
|
-
"pino-abstract-transport": "2.0.0",
|
|
67
|
-
"promised-handlebars": "2.0.1",
|
|
68
|
-
"qrcode": "1.5.4",
|
|
69
|
-
"sharp": "0.34.5",
|
|
70
|
-
"uglify-js": "3.19.3",
|
|
71
|
-
"undici": "7.16.0"
|
|
72
|
-
},
|
|
73
|
-
"devDependencies": {
|
|
74
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
75
|
-
"@types/bun": "^1.3.5",
|
|
76
|
-
"@types/js-yaml": "^4.0.9",
|
|
77
|
-
"@types/markdown-it": "^14.1.2",
|
|
78
|
-
"@types/node": "^24.3.1",
|
|
79
|
-
"@types/nodemailer": "^7.0.1",
|
|
80
|
-
"@types/passport": "^1.0.17",
|
|
81
|
-
"@types/passport-local": "^1.0.38",
|
|
82
|
-
"@types/pg": "^8.15.5",
|
|
83
|
-
"@types/qrcode": "^1.5.5",
|
|
84
|
-
"copyfiles": "^2.4.1",
|
|
85
|
-
"eslint": "^9.35.0",
|
|
86
|
-
"eslint-config-airbnb-extended": "^2.3.1",
|
|
87
|
-
"ts-migrate": "^0.1.35",
|
|
88
|
-
"typescript": "^5.9.2",
|
|
89
|
-
"vitest": "^3.2.4"
|
|
90
|
-
},
|
|
91
|
-
"author": "Softpro",
|
|
92
|
-
"license": "ISC"
|
|
93
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@opengis/fastify-table",
|
|
3
|
+
"version": "2.0.118",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "core-plugins",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"fastify",
|
|
8
|
+
"table",
|
|
9
|
+
"crud",
|
|
10
|
+
"auth",
|
|
11
|
+
"pg",
|
|
12
|
+
"backend"
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js",
|
|
17
|
+
"./index.js": "./dist/index.js",
|
|
18
|
+
"./utils.js": "./dist/utils.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/*"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"dump": "bun ./script/dump.ts",
|
|
25
|
+
"migrate": "MIGRATE=true bun ./script/migrate.ts",
|
|
26
|
+
"dump1": "bun ./dist/script/dump.js",
|
|
27
|
+
"migrate1": "MIGRATE=true bun ./dist/script/migrate.js",
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"clean": "tsc -b --clean",
|
|
30
|
+
"build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist && copyfiles server/templates/**/*.hbs dist && copyfiles script/* dist && copyfiles -u 2 module/core/*/* dist/module/core",
|
|
31
|
+
"prod": "NODE_ENV=production bun dist/server",
|
|
32
|
+
"patch": "npm version patch && git push && npm publish",
|
|
33
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
34
|
+
"test": "npx vitest run",
|
|
35
|
+
"compress": "node compress.js",
|
|
36
|
+
"dev1": "bun --hot dist/server",
|
|
37
|
+
"dev": "NODE_ENV=production bun start",
|
|
38
|
+
"start": "LOG_LEVEL=trace bun server"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@aws-sdk/client-s3": "3.879.0",
|
|
42
|
+
"@aws-sdk/lib-storage": "3.879.0",
|
|
43
|
+
"@fastify/cookie": "11.0.2",
|
|
44
|
+
"@fastify/http-proxy": "11.1.2",
|
|
45
|
+
"@fastify/multipart": "9.0.3",
|
|
46
|
+
"@fastify/passport": "3.0.2",
|
|
47
|
+
"@fastify/rate-limit": "10.3.0",
|
|
48
|
+
"@fastify/session": "11.1.0",
|
|
49
|
+
"@grpc/grpc-js": "1.10.11",
|
|
50
|
+
"@grpc/proto-loader": "0.7.15",
|
|
51
|
+
"apache-crypt": "1.2.6",
|
|
52
|
+
"better-sqlite3": "12.2.0",
|
|
53
|
+
"dotenv": "16.5.0",
|
|
54
|
+
"fastify": "5.3.3",
|
|
55
|
+
"fastify-plugin": "5.0.1",
|
|
56
|
+
"fastify-session-redis-store": "7.1.2",
|
|
57
|
+
"handlebars": "4.7.8",
|
|
58
|
+
"image-size": "1.2.0",
|
|
59
|
+
"ioredis": "5.3.2",
|
|
60
|
+
"js-yaml": "4.1.0",
|
|
61
|
+
"markdown-it": "14.1.0",
|
|
62
|
+
"nodemailer": "7.0.6",
|
|
63
|
+
"otplib": "12.0.1",
|
|
64
|
+
"pg": "8.11.6",
|
|
65
|
+
"pino": "9.5.0",
|
|
66
|
+
"pino-abstract-transport": "2.0.0",
|
|
67
|
+
"promised-handlebars": "2.0.1",
|
|
68
|
+
"qrcode": "1.5.4",
|
|
69
|
+
"sharp": "0.34.5",
|
|
70
|
+
"uglify-js": "3.19.3",
|
|
71
|
+
"undici": "7.16.0"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
75
|
+
"@types/bun": "^1.3.5",
|
|
76
|
+
"@types/js-yaml": "^4.0.9",
|
|
77
|
+
"@types/markdown-it": "^14.1.2",
|
|
78
|
+
"@types/node": "^24.3.1",
|
|
79
|
+
"@types/nodemailer": "^7.0.1",
|
|
80
|
+
"@types/passport": "^1.0.17",
|
|
81
|
+
"@types/passport-local": "^1.0.38",
|
|
82
|
+
"@types/pg": "^8.15.5",
|
|
83
|
+
"@types/qrcode": "^1.5.5",
|
|
84
|
+
"copyfiles": "^2.4.1",
|
|
85
|
+
"eslint": "^9.35.0",
|
|
86
|
+
"eslint-config-airbnb-extended": "^2.3.1",
|
|
87
|
+
"ts-migrate": "^0.1.35",
|
|
88
|
+
"typescript": "^5.9.2",
|
|
89
|
+
"vitest": "^3.2.4"
|
|
90
|
+
},
|
|
91
|
+
"author": "Softpro",
|
|
92
|
+
"license": "ISC"
|
|
93
|
+
}
|