@opengis/fastify-table 2.0.107 → 2.0.109
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 +5 -0
- package/dist/server/plugins/crud/funcs/dataInsert.js +1 -1
- package/dist/server/plugins/crud/funcs/dataUpdate.js +2 -2
- package/dist/server/plugins/crud/funcs/validateData.js +1 -1
- package/dist/server/plugins/file/providers/fs.js +2 -2
- package/dist/server/plugins/file/providers/s3/funcs/downloadFile.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/downloadFile.js +1 -2
- package/dist/server/plugins/file/providers/s3/funcs/fileExists.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/fileExists.js +1 -2
- package/dist/server/plugins/file/providers/s3/funcs/uploadFile.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/s3/funcs/uploadFile.js +1 -2
- package/dist/server/plugins/file/providers/s3/index.js +4 -4
- package/dist/server/plugins/logger/getLogger.d.ts.map +1 -1
- package/dist/server/plugins/logger/getLogger.js +1 -1
- package/dist/server/plugins/logger/index.js +3 -3
- package/dist/server/plugins/migration/exec.migrations.js +6 -6
- package/dist/server/plugins/pg/funcs/autoIndex.d.ts +1 -2
- package/dist/server/plugins/pg/funcs/autoIndex.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/autoIndex.js +24 -27
- package/dist/server/plugins/pg/funcs/getMeta.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/getMeta.js +3 -5
- package/dist/server/plugins/pg/funcs/getPG.js +1 -1
- package/dist/server/plugins/pg/funcs/getPGAsync.js +1 -1
- package/dist/server/plugins/pg/funcs/init.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/init.js +23 -31
- package/dist/server/plugins/pg/funcs/pool.js +2 -2
- package/dist/server/plugins/pg/index.d.ts.map +1 -1
- package/dist/server/plugins/pg/index.js +3 -1
- package/dist/server/plugins/redis/funcs/getRedis.js +1 -1
- package/dist/server/plugins/upload/finishUpload.d.ts +9 -0
- package/dist/server/plugins/upload/finishUpload.d.ts.map +1 -0
- package/dist/server/plugins/upload/finishUpload.js +33 -0
- package/dist/server/plugins/upload/getUploadStatus.d.ts +5 -0
- package/dist/server/plugins/upload/getUploadStatus.d.ts.map +1 -0
- package/dist/server/plugins/upload/getUploadStatus.js +31 -0
- package/dist/server/plugins/upload/index.d.ts +6 -0
- package/dist/server/plugins/upload/index.d.ts.map +1 -0
- package/dist/server/plugins/upload/index.js +12 -0
- package/dist/server/plugins/upload/startUpload.d.ts +8 -0
- package/dist/server/plugins/upload/startUpload.d.ts.map +1 -0
- package/dist/server/plugins/upload/startUpload.js +59 -0
- package/dist/server/plugins/upload/uploadChunk.d.ts +9 -0
- package/dist/server/plugins/upload/uploadChunk.d.ts.map +1 -0
- package/dist/server/plugins/upload/uploadChunk.js +61 -0
- package/dist/server/plugins/util/funcs/unflattenObject.d.ts.map +1 -1
- package/dist/server/plugins/util/funcs/unflattenObject.js +2 -2
- package/dist/server/routes/auth/controllers/2factor/providers/totp.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/2factor/providers/totp.js +1 -1
- package/dist/server/routes/auth/controllers/core/registration.d.ts +4 -1
- package/dist/server/routes/auth/controllers/core/registration.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/core/registration.js +14 -5
- package/dist/server/routes/table/controllers/filter.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/filter.js +7 -0
- package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
- package/dist/server/routes/table/functions/getData.js +0 -11
- package/dist/server/routes/upload/index.d.ts +2 -0
- package/dist/server/routes/upload/index.d.ts.map +1 -0
- package/dist/server/routes/upload/index.js +65 -0
- package/dist/server/types/core.d.ts +0 -1
- package/dist/server/types/core.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -0
- 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":"AAuFA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QA6J3B;;AACD,wBAA0B"}
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ import templatesRoutes from "./server/routes/templates/index.js";
|
|
|
46
46
|
import widgetRoutes from "./server/routes/widget/index.js";
|
|
47
47
|
import authRoutes from "./server/routes/auth/index.js";
|
|
48
48
|
import fileRoutes from "./server/routes/file/index.js";
|
|
49
|
+
import uploadChunkRoutes from "./server/routes/upload/index.js";
|
|
49
50
|
import grpcRoutes from "./server/routes/grpc/index.js";
|
|
50
51
|
import notificationsRoutes from "./server/routes/notifications/index.js";
|
|
51
52
|
const filename = fileURLToPath(import.meta.url);
|
|
@@ -115,6 +116,9 @@ function plugin(fastify) {
|
|
|
115
116
|
keyGenerator: (req) => `${req.ip}-${req.raw.url.split("?")[0]}`,
|
|
116
117
|
});
|
|
117
118
|
}
|
|
119
|
+
else {
|
|
120
|
+
console.log("⚠️ rate limit is disabled");
|
|
121
|
+
}
|
|
118
122
|
// add multipart parser before any route registration
|
|
119
123
|
fastify.register(import("@fastify/multipart"), {
|
|
120
124
|
limits: {
|
|
@@ -138,6 +142,7 @@ function plugin(fastify) {
|
|
|
138
142
|
fastify.register(authRoutes); // from fastify-auth
|
|
139
143
|
// from fastify-file
|
|
140
144
|
fastify.register(fileRoutes);
|
|
145
|
+
fastify.register(uploadChunkRoutes);
|
|
141
146
|
fastify.register(grpcRoutes, opt);
|
|
142
147
|
// from admin
|
|
143
148
|
fastify.register(notificationsRoutes, opt);
|
|
@@ -109,7 +109,7 @@ export default async function dataInsert({ id, table: table1, referer, data, pg:
|
|
|
109
109
|
if (!isClient) {
|
|
110
110
|
await client.query("commit;");
|
|
111
111
|
}
|
|
112
|
-
return res;
|
|
112
|
+
return { ...res, id: id1, data: res.rows[0] };
|
|
113
113
|
}
|
|
114
114
|
catch (err) {
|
|
115
115
|
logger.file("crud/insert", {
|
|
@@ -76,7 +76,7 @@ export default async function dataUpdate({ table, tokenData, referer, id, data,
|
|
|
76
76
|
json_object_agg(f_geometry_column, case when srid = 0 then 4326 else srid end) as rel
|
|
77
77
|
from public.geometry_columns group by f_table_schema||'.'||f_table_name
|
|
78
78
|
)q`)
|
|
79
|
-
.then((
|
|
79
|
+
.then((el) => el.rows?.[0] || {});
|
|
80
80
|
Object.assign(srids, srids1);
|
|
81
81
|
}
|
|
82
82
|
const updateQuery = `UPDATE ${table} SET ${systemColumns ? `${systemColumns}${filterData?.length ? "," : ""}` : ""}
|
|
@@ -176,7 +176,7 @@ export default async function dataUpdate({ table, tokenData, referer, id, data,
|
|
|
176
176
|
if (!isClient) {
|
|
177
177
|
await client.query("commit;");
|
|
178
178
|
}
|
|
179
|
-
return res || {};
|
|
179
|
+
return { ...(res || {}), id };
|
|
180
180
|
}
|
|
181
181
|
catch (err) {
|
|
182
182
|
logger.file("crud/update", {
|
|
@@ -81,7 +81,7 @@ function checkBody({ body = {}, arr = [], idx }) {
|
|
|
81
81
|
}, []);
|
|
82
82
|
const invalidField = res.find((el) => el?.error);
|
|
83
83
|
if (invalidField) {
|
|
84
|
-
console.warn("invalid field: ", invalidField?.key, invalidField?.error);
|
|
84
|
+
console.warn("⚠️ invalid field: ", invalidField?.key, invalidField?.error);
|
|
85
85
|
return invalidField;
|
|
86
86
|
}
|
|
87
87
|
return { message: "ok" };
|
|
@@ -51,12 +51,12 @@ const uploadFile = () => async (fp, data, opt = {}) => {
|
|
|
51
51
|
}
|
|
52
52
|
await fsp.mkdir(path.dirname(filepath), { recursive: true });
|
|
53
53
|
try {
|
|
54
|
-
const exists = await isFileExists(
|
|
54
|
+
const exists = await isFileExists(filepath);
|
|
55
55
|
if (!exists) {
|
|
56
56
|
await fsp.writeFile(filepath, validData, opt);
|
|
57
57
|
}
|
|
58
58
|
else if (isBuffer(validData) || isReadableStream(validData)) {
|
|
59
|
-
await fsp.
|
|
59
|
+
await fsp.appendFile(filepath, validData, opt);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
await fsp.copyFile(validData, filepath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/downloadFile.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,aAAa,GAChB,aAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAC1B,IAAI,MAAM,EAAE,UAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,
|
|
1
|
+
{"version":3,"file":"downloadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/downloadFile.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,aAAa,GAChB,aAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAC1B,IAAI,MAAM,EAAE,UAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBA0CnD,CAAC;AAEJ,eAAe,aAAa,CAAC"}
|
|
@@ -11,8 +11,7 @@ import getS3FilePath from "./utils/getS3FilePath.js";
|
|
|
11
11
|
const getFileStream = (s3Settings) => async (fp, options = {}) => {
|
|
12
12
|
const filepath = getS3FilePath(fp, s3Settings);
|
|
13
13
|
const bucketParams = {
|
|
14
|
-
Bucket:
|
|
15
|
-
.containerName,
|
|
14
|
+
Bucket: s3Settings?.containerName || config.s3?.containerName || "work",
|
|
16
15
|
Key: filepath[0] === "/" ? filepath?.slice(1) : filepath,
|
|
17
16
|
Range: options.Range,
|
|
18
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileExists.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/fileExists.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe,GAClB,aAAa,GAAG,MACV,IAAI,GAAG,EAAE,UAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,
|
|
1
|
+
{"version":3,"file":"fileExists.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/fileExists.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe,GAClB,aAAa,GAAG,MACV,IAAI,GAAG,EAAE,UAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBAkBhD,CAAC;AAEJ,eAAe,eAAe,CAAC"}
|
|
@@ -8,8 +8,7 @@ import isFileExists from "../../../utils/isFileExists.js";
|
|
|
8
8
|
const getFileMetadata = (s3Settings) => async (fp, options = {}) => {
|
|
9
9
|
const filepath = getS3FilePath(fp, s3Settings);
|
|
10
10
|
const bucketParams = {
|
|
11
|
-
Bucket:
|
|
12
|
-
.containerName,
|
|
11
|
+
Bucket: s3Settings?.containerName || config.s3?.containerName || "work",
|
|
13
12
|
Key: filepath[0] === "/" ? filepath?.slice(1) : filepath,
|
|
14
13
|
};
|
|
15
14
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/uploadFile.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,UAAU,GAAI,aAAa,GAAG,MAAY,IAAI,GAAG,EAAE,MAAM,GAAG,+
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/file/providers/s3/funcs/uploadFile.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,UAAU,GAAI,aAAa,GAAG,MAAY,IAAI,GAAG,EAAE,MAAM,GAAG,+EA6BjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -13,8 +13,7 @@ const uploadFile = (s3Settings) => async (fp, data) => {
|
|
|
13
13
|
const type = getMimeType(filepath);
|
|
14
14
|
try {
|
|
15
15
|
const bucketParams = {
|
|
16
|
-
Bucket:
|
|
17
|
-
.containerName,
|
|
16
|
+
Bucket: s3Settings?.containerName || config.s3?.containerName || "work",
|
|
18
17
|
Key: filepath,
|
|
19
18
|
ContentLength: size,
|
|
20
19
|
ContentType: type,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import downloadFile from
|
|
2
|
-
import fileExists from
|
|
3
|
-
import uploadFile from
|
|
1
|
+
import downloadFile from "./funcs/downloadFile.js";
|
|
2
|
+
import fileExists from "./funcs/fileExists.js";
|
|
3
|
+
import uploadFile from "./funcs/uploadFile.js";
|
|
4
4
|
export default function s3Storage(opt) {
|
|
5
5
|
return {
|
|
6
|
-
name:
|
|
6
|
+
name: "s3",
|
|
7
7
|
downloadFile: downloadFile(opt),
|
|
8
8
|
uploadFile: uploadFile(opt),
|
|
9
9
|
fileExists: fileExists(opt),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,UAAU,cAAe,SAAQ,IAAI,CAAC,MAAM;IAC1C,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;AAmDD,QAAA,MAAM,MAAM,EAAE,cAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,UAAU,cAAe,SAAQ,IAAI,CAAC,MAAM;IAC1C,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;AAmDD,QAAA,MAAM,MAAM,EAAE,cAAgD,CAAC;AAiC/D,eAAe,MAAM,CAAC"}
|
|
@@ -59,6 +59,6 @@ logger.metrics = function metrics(key, val, dbName) {
|
|
|
59
59
|
return;
|
|
60
60
|
rclient2
|
|
61
61
|
.hincrby(`${dbname}:system_metrics`, key, val || 1)
|
|
62
|
-
.catch((err) => console.warn("logger metrics error", err.toString()));
|
|
62
|
+
.catch((err) => console.warn("⚠️ logger metrics error", err.toString()));
|
|
63
63
|
};
|
|
64
64
|
export default logger;
|
|
@@ -6,7 +6,7 @@ process.on("uncaughtException", (err) => {
|
|
|
6
6
|
if (err.message === "Connection terminated unexpectedly" ||
|
|
7
7
|
err.code === "ECONNRESET") {
|
|
8
8
|
logger.file("pg", { error: err.toString() });
|
|
9
|
-
console.warn("Ignored pg connection drop:", err.toString());
|
|
9
|
+
console.warn("⚠️ Ignored pg connection drop:", err.toString());
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
throw err; // keep normal behavior
|
|
@@ -18,13 +18,13 @@ process.on("unhandledRejection", (err) => {
|
|
|
18
18
|
"Connection terminated due to connection timeout",
|
|
19
19
|
].includes(err.message)) {
|
|
20
20
|
logger.file("pg", { error: err.message });
|
|
21
|
-
console.warn("Ignored pg connection timeout / close:", err.toString());
|
|
21
|
+
console.warn("⚠️ Ignored pg connection timeout / close:", err.toString());
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (err.message === "Connection is closed." ||
|
|
25
25
|
err.message.includes("maxRetriesPerRequest")) {
|
|
26
26
|
logger.file("redis", { error: err.message });
|
|
27
|
-
console.warn("Ignored redis connection close:", err.toString());
|
|
27
|
+
console.warn("⚠️ Ignored redis connection close:", err.toString());
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
throw err;
|
|
@@ -10,19 +10,19 @@ export default async function execMigrations(dirPath, pg = pgClients.client, isc
|
|
|
10
10
|
if (!dirPath) {
|
|
11
11
|
const txt = "migrations skip: path not specified";
|
|
12
12
|
if (debug)
|
|
13
|
-
console.warn(txt);
|
|
13
|
+
console.warn(`⚠️ ${txt}`);
|
|
14
14
|
return txt;
|
|
15
15
|
}
|
|
16
16
|
if (config.migrationsCore === false && iscore) {
|
|
17
17
|
const txt = `migrations skip: core - ${dirPath}`;
|
|
18
18
|
if (debug)
|
|
19
|
-
console.
|
|
19
|
+
console.warn(`⚠️ ${txt}`);
|
|
20
20
|
return txt;
|
|
21
21
|
}
|
|
22
22
|
if (config.migrations === false && !iscore) {
|
|
23
23
|
const txt = `migrations skip: path - ${dirPath}`;
|
|
24
24
|
if (debug)
|
|
25
|
-
console.
|
|
25
|
+
console.warn(`⚠️ ${txt}`);
|
|
26
26
|
return txt;
|
|
27
27
|
}
|
|
28
28
|
if (process.env.NODE_ENV !== "production" &&
|
|
@@ -30,7 +30,7 @@ export default async function execMigrations(dirPath, pg = pgClients.client, isc
|
|
|
30
30
|
!(iscore ? config.migrationsCore : config.migrations)) {
|
|
31
31
|
const txt = `migrations skip: not a production environment - ${iscore ? "core" : "path"} : ${dirPath}`;
|
|
32
32
|
if (debug)
|
|
33
|
-
console.
|
|
33
|
+
console.warn(`⚠️ ${txt}`);
|
|
34
34
|
return txt;
|
|
35
35
|
}
|
|
36
36
|
if (debug)
|
|
@@ -39,7 +39,7 @@ export default async function execMigrations(dirPath, pg = pgClients.client, isc
|
|
|
39
39
|
if (!exists) {
|
|
40
40
|
const txt = `migrations skip: directory not found - ${dirPath}`;
|
|
41
41
|
if (debug)
|
|
42
|
-
console.warn(txt);
|
|
42
|
+
console.warn(`⚠️ ${txt}`);
|
|
43
43
|
return txt;
|
|
44
44
|
}
|
|
45
45
|
// get directory sql file list
|
|
@@ -50,7 +50,7 @@ export default async function execMigrations(dirPath, pg = pgClients.client, isc
|
|
|
50
50
|
if (!content?.length) {
|
|
51
51
|
const txt = `migrations skip: no sql in specified directory - ${dirPath}`;
|
|
52
52
|
if (debug)
|
|
53
|
-
console.warn(txt);
|
|
53
|
+
console.warn(`⚠️ ${txt}`);
|
|
54
54
|
return txt;
|
|
55
55
|
}
|
|
56
56
|
await content.reduce((promise, filename) => promise.then(() => execSql(path.join(dirPath, filename), pg)), Promise.resolve());
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default autoIndex;
|
|
1
|
+
export default function autoIndex({ table, columns: filter1, pg, gin, }: any): Promise<"empty table list" | "ok" | null>;
|
|
3
2
|
//# sourceMappingURL=autoIndex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoIndex.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/autoIndex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"autoIndex.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/autoIndex.ts"],"names":[],"mappings":"AAaA,wBAA8B,SAAS,CAAC,EACtC,KAAK,EACL,OAAO,EAAE,OAAO,EAChB,EAAoB,EACpB,GAAG,GACJ,EAAE,GAAG,6CAwJL"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import config from "../../../../config.js";
|
|
3
2
|
import pgClient from "../pgClients.js";
|
|
4
|
-
|
|
5
|
-
const getTable = ({ table }) => table
|
|
3
|
+
const getTable = (table) => table
|
|
6
4
|
?.toLowerCase?.()
|
|
7
5
|
?.replace?.(/[\n\r]+/g, " ")
|
|
8
6
|
?.split?.(" from ")
|
|
9
|
-
?.filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
|
|
7
|
+
?.filter((el) => /^[a-z0-9_]+\.[a-z0-9_"]+/.test(el))
|
|
10
8
|
?.map((el) => el?.split?.(/[ )]/)?.[0]);
|
|
11
9
|
const loadedIndex = {};
|
|
12
|
-
|
|
13
|
-
async function autoIndex({ table, columns: filter1, pg = pgClient.client, gin, }) {
|
|
10
|
+
export default async function autoIndex({ table, columns: filter1, pg = pgClient.client, gin, }) {
|
|
14
11
|
const filter = filter1.filter((el) => el);
|
|
15
|
-
if (!filter?.length || !table
|
|
12
|
+
if (!filter?.length || !table)
|
|
16
13
|
return null;
|
|
17
14
|
const attrs = filter
|
|
18
15
|
.map((el) => (el.name || el).replace(/'/g, ""))
|
|
@@ -26,27 +23,33 @@ async function autoIndex({ table, columns: filter1, pg = pgClient.client, gin, }
|
|
|
26
23
|
[el.name]: el.type || "-",
|
|
27
24
|
}), {});
|
|
28
25
|
const redisKey = `autoindex1:${table}:${attrs.join(";")}`;
|
|
29
|
-
const tableList =
|
|
26
|
+
const tableList = pg.pk[table.replace(/"/g, "")] ? [table] : getTable(table);
|
|
27
|
+
if (!tableList.length) {
|
|
28
|
+
return "empty table list";
|
|
29
|
+
}
|
|
30
30
|
const existsCache = loadedIndex[redisKey];
|
|
31
31
|
if (existsCache && !config.disableCache) {
|
|
32
32
|
return "ok";
|
|
33
33
|
}
|
|
34
34
|
const tbs = tableList[0];
|
|
35
35
|
const [ns, tbl] = tableList[0]?.split?.(".") || [];
|
|
36
|
-
const
|
|
37
|
-
? await pg
|
|
38
|
-
|
|
36
|
+
const index = tbl
|
|
37
|
+
? await pg
|
|
38
|
+
.query("select * from pg_indexes where tablename = $1 and schemaname = $2", [tbl, ns])
|
|
39
|
+
.then((el) => el.rows || [])
|
|
40
|
+
: [];
|
|
39
41
|
if (existsCache && !config.disableCache && index?.length > 0) {
|
|
40
42
|
return null;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const cols = tbs
|
|
45
|
+
? await pg
|
|
46
|
+
.query(`SELECT attrelid::regclass AS tbl, attname AS aname, atttypid::regtype AS datatype, atttypid
|
|
47
|
+
FROM pg_attribute WHERE attrelid::regclass::text = $1 and attname = any($2::text[])`, [tbs, attrs])
|
|
48
|
+
.then((el) => el.rows || [])
|
|
49
|
+
: [];
|
|
45
50
|
const qIndex = [];
|
|
46
51
|
const indexAr = {};
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < cols.length; i += 1) {
|
|
49
|
-
const el = cols[i];
|
|
52
|
+
cols.forEach((el) => {
|
|
50
53
|
el.relname = tbl;
|
|
51
54
|
el.nspname = ns;
|
|
52
55
|
const isGin = types[el.aname] === "Text" || gin;
|
|
@@ -60,7 +63,7 @@ async function autoIndex({ table, columns: filter1, pg = pgClient.client, gin, }
|
|
|
60
63
|
indexAr[el.aname] = {
|
|
61
64
|
name,
|
|
62
65
|
type: el.datatype,
|
|
63
|
-
exists,
|
|
66
|
+
exists,
|
|
64
67
|
};
|
|
65
68
|
// drop
|
|
66
69
|
/* if (exists?.length > 1) {
|
|
@@ -85,18 +88,12 @@ async function autoIndex({ table, columns: filter1, pg = pgClient.client, gin, }
|
|
|
85
88
|
ON ${el.nspname}.${el.relname} USING gist (st_transform(${el.aname},4326))`);
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
}
|
|
91
|
+
});
|
|
89
92
|
loadedIndex[redisKey] = 1;
|
|
90
|
-
// throw qIndex;
|
|
91
93
|
if (!qIndex.length)
|
|
92
94
|
return null;
|
|
93
|
-
if (config.local) {
|
|
94
|
-
// console.log(qIndex.filter((v, i, a) => a.indexOf(v) === i));
|
|
95
|
-
}
|
|
96
|
-
// logger.file('index', { table, filter, sql: qIndex.filter((v, i, a) => a.indexOf(v) === i) });
|
|
97
95
|
qIndex
|
|
98
|
-
.filter((
|
|
99
|
-
.map((el) => pg.
|
|
96
|
+
.filter((el, idx, arr) => arr.indexOf(el) === idx)
|
|
97
|
+
.map((el) => pg.query(el).catch((err) => console.log(err.toString())));
|
|
100
98
|
return "ok";
|
|
101
99
|
}
|
|
102
|
-
export default autoIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/getMeta.ts"],"names":[],"mappings":"AAKA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"getMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/getMeta.ts"],"names":[],"mappings":"AAKA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,gBAuE5D"}
|
|
@@ -6,9 +6,7 @@ export default async function getMeta(opt, nocache) {
|
|
|
6
6
|
if (!pg)
|
|
7
7
|
return { error: "pg connection not established", status: 400 };
|
|
8
8
|
// reconnect if at start of process connection was unavailable
|
|
9
|
-
if (!pg.pk) {
|
|
10
|
-
pg.connectionAttempt = 0;
|
|
11
|
-
pg.init = init(pg);
|
|
9
|
+
if (!pg.pk || nocache) {
|
|
12
10
|
await init(pg);
|
|
13
11
|
}
|
|
14
12
|
const table1 = opt?.table || opt;
|
|
@@ -27,8 +25,8 @@ export default async function getMeta(opt, nocache) {
|
|
|
27
25
|
WHERE c.contype='p'::"char" and c.conrelid::regclass = $1::regclass`, [table])
|
|
28
26
|
.then((el) => el.rows[0].pks1 || {});
|
|
29
27
|
const pk = table.startsWith("public.")
|
|
30
|
-
? pks1[table.replace("public.", "")]
|
|
31
|
-
: pks1[table]
|
|
28
|
+
? pks1[table.replace("public.", "")]
|
|
29
|
+
: pks1[table];
|
|
32
30
|
const geomColumns = fields.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry");
|
|
33
31
|
const geomAttr = geomColumns.find((el) => el.name === "geom_4326") || geomColumns[0];
|
|
34
32
|
const dbColumns = await pg
|
|
@@ -36,7 +36,7 @@ function getPG(param = {}) {
|
|
|
36
36
|
pgClients[name] = pool(dbConfig);
|
|
37
37
|
pgClients[name].init = () => init(pgClients[name]); // for compatibility
|
|
38
38
|
// force init
|
|
39
|
-
init(pgClients[name]).catch((err) => console.warn("pg client init error", host, port, dbConfig.database));
|
|
39
|
+
init(pgClients[name]).catch((err) => console.warn("⚠️ pg client init error", host, port, dbConfig.database));
|
|
40
40
|
return pgClients[name];
|
|
41
41
|
}
|
|
42
42
|
if (config.pg) {
|
|
@@ -5,7 +5,7 @@ async function getPGAsync(param) {
|
|
|
5
5
|
const { host, port, database } = client?.options || {};
|
|
6
6
|
if (client && !client.tlist) {
|
|
7
7
|
// force init
|
|
8
|
-
await init(client).catch((err) => console.warn("PG client init error", host, port, database));
|
|
8
|
+
await init(client).catch((err) => console.warn("⚠️ PG client init error", host, port, database));
|
|
9
9
|
}
|
|
10
10
|
return client;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,iBAAe,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/init.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,iBAAe,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,iBAsNtC;AAGD,eAAe,IAAI,CAAC"}
|
|
@@ -18,35 +18,27 @@ async function init(client) {
|
|
|
18
18
|
if (!client || !client.query || !client.connect) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
.query(`SELECT
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
) AS pk,
|
|
43
|
-
(
|
|
44
|
-
SELECT
|
|
45
|
-
json_object_agg(t.oid:: text, pg_catalog.format_type(t.oid, NULL))
|
|
46
|
-
FROM
|
|
47
|
-
pg_catalog.pg_type t
|
|
48
|
-
) AS "pgType"`)
|
|
49
|
-
.then((d) => d.rows[0]);
|
|
21
|
+
const pgType = await client
|
|
22
|
+
.query(`SELECT json_object_agg(t.oid:: text, pg_catalog.format_type(t.oid, NULL)) FROM pg_catalog.pg_type t`)
|
|
23
|
+
.then((el) => el.rows[0]?.json_object_agg || {});
|
|
24
|
+
const pks = await client
|
|
25
|
+
.query(`
|
|
26
|
+
SELECT
|
|
27
|
+
connamespace::regnamespace::text,
|
|
28
|
+
conrelid::regclass,
|
|
29
|
+
(
|
|
30
|
+
SELECT attname FROM pg_attribute WHERE attrelid = c.conrelid AND attnum = c.conkey[1]
|
|
31
|
+
) as pk
|
|
32
|
+
FROM pg_constraint c
|
|
33
|
+
WHERE contype = 'p'
|
|
34
|
+
AND connamespace::regnamespace::text NOT IN ('sde')`)
|
|
35
|
+
.then((el) => el.rows || []);
|
|
36
|
+
const pk = pks.reduce((acc, curr) => ({
|
|
37
|
+
...acc,
|
|
38
|
+
[curr.connamespace === "public"
|
|
39
|
+
? `${curr.connamespace}.${curr.conrelid}`
|
|
40
|
+
: curr.conrelid]: curr.pk,
|
|
41
|
+
}), {});
|
|
50
42
|
const tlist = await client
|
|
51
43
|
.query(`SELECT
|
|
52
44
|
array_agg(
|
|
@@ -109,10 +101,10 @@ async function init(client) {
|
|
|
109
101
|
}
|
|
110
102
|
catch (err) {
|
|
111
103
|
if (err.code === "57014") {
|
|
112
|
-
console.warn("pg.querySafe timeout", q);
|
|
104
|
+
console.warn("⚠️ pg.querySafe timeout", q);
|
|
113
105
|
return { rows: [], timeout: true };
|
|
114
106
|
}
|
|
115
|
-
console.warn("pg.querySafe error", q);
|
|
107
|
+
console.warn("⚠️ pg.querySafe error", q);
|
|
116
108
|
throw err;
|
|
117
109
|
}
|
|
118
110
|
finally {
|
|
@@ -25,14 +25,14 @@ export default (param = {}) => {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
pool.on("error", (err) => {
|
|
28
|
-
console.warn("Unexpected error on idle client", param.database);
|
|
28
|
+
console.warn("⚠️ Unexpected error on idle client", param.database);
|
|
29
29
|
config.ready[`pg:${param.database}`] = false;
|
|
30
30
|
logger.file("pg", {
|
|
31
31
|
error: err.toString(),
|
|
32
32
|
database: param.database,
|
|
33
33
|
});
|
|
34
34
|
if (config.trace) {
|
|
35
|
-
console.warn("Unexpected error on idle client details:", err.toString(), err.stack);
|
|
35
|
+
console.warn("⚠️ Unexpected error on idle client details:", err.toString(), err.stack);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
pool.on("connect", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/pg/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/pg/index.ts"],"names":[],"mappings":"AAkCA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QAwB3B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -3,7 +3,9 @@ import pgClients from "./pgClients.js";
|
|
|
3
3
|
import getPGAsync from "./funcs/getPGAsync.js";
|
|
4
4
|
import logger from "../logger/getLogger.js";
|
|
5
5
|
function close() {
|
|
6
|
-
Object.keys(pgClients)
|
|
6
|
+
Object.keys(pgClients)
|
|
7
|
+
.filter((key) => !pgClients[key]?.ending && !pgClients[key]?.ended)
|
|
8
|
+
.forEach((key) => {
|
|
7
9
|
console.log("Closing pg client", key);
|
|
8
10
|
pgClients[key].end();
|
|
9
11
|
});
|
|
@@ -33,7 +33,7 @@ function getRedis({ db, host, port, closeClient = false, retryStrategy = (times)
|
|
|
33
33
|
config.ready[`redis:${key}`] = true;
|
|
34
34
|
});
|
|
35
35
|
redisClients[key].on("error", (err) => {
|
|
36
|
-
console.warn("Ignored redis error:", err.message);
|
|
36
|
+
console.warn("⚠️ Ignored redis error:", err.message);
|
|
37
37
|
logger.file("redis", { error: err.toString() });
|
|
38
38
|
});
|
|
39
39
|
console.log("redis connected", db, host, port);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finishUpload.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/finishUpload.ts"],"names":[],"mappings":"AAMA,wBAA8B,YAAY,CAAC,EACzC,IAAI,EACJ,EAAE,GACH,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAqC/D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { prefix, metaDir, fetchTimeoutMs } from "./index.js";
|
|
5
|
+
export default async function finishUpload({ host, id, }) {
|
|
6
|
+
if (!host) {
|
|
7
|
+
const metaExists = existsSync(path.join(metaDir, `${id}.json`));
|
|
8
|
+
if (!metaExists) {
|
|
9
|
+
return { error: "upload not found: " + id, code: 404 };
|
|
10
|
+
}
|
|
11
|
+
const meta = JSON.parse(await readFile(path.join(metaDir, `${id}.json`), "utf8"));
|
|
12
|
+
if (meta.uploaded !== meta.size) {
|
|
13
|
+
return { error: "Upload not complete", code: 400 };
|
|
14
|
+
}
|
|
15
|
+
const metaData = {
|
|
16
|
+
...meta,
|
|
17
|
+
uploadDate: new Date().toISOString(),
|
|
18
|
+
exists: true,
|
|
19
|
+
finished: true,
|
|
20
|
+
};
|
|
21
|
+
const fileBytes = Buffer.from(JSON.stringify(metaData, null, 2));
|
|
22
|
+
// save metadata
|
|
23
|
+
await writeFile(path.join(metaDir, `${id}.json`), fileBytes);
|
|
24
|
+
return { success: true, code: 200 };
|
|
25
|
+
}
|
|
26
|
+
const res = await fetch(`${host}/${prefix}/${id}/finish`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
signal: AbortSignal.timeout(fetchTimeoutMs),
|
|
29
|
+
}).catch((err) => ({
|
|
30
|
+
json: () => Promise.resolve({ error: err.toString(), code: 501 }),
|
|
31
|
+
}));
|
|
32
|
+
return res.json();
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUploadStatus.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/getUploadStatus.ts"],"names":[],"mappings":"AAaA,wBAA8B,eAAe,CAAC,EAC5C,IAAI,EACJ,EAAE,GACH,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,gBA+BA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { prefix, metaDir, uploadChunkDirectory, fetchTimeoutMs, } from "./index.js";
|
|
5
|
+
import isFileExists from "../file/isFileExists.js";
|
|
6
|
+
export default async function getUploadStatus({ host, id, }) {
|
|
7
|
+
// return local file metadata
|
|
8
|
+
if (!host) {
|
|
9
|
+
const metaExists = existsSync(path.join(metaDir, `${id}.json`));
|
|
10
|
+
// check file upload status: finished/inprogress
|
|
11
|
+
const meta = metaExists
|
|
12
|
+
? JSON.parse(await readFile(path.join(metaDir, `${id}.json`), "utf8"))
|
|
13
|
+
: {};
|
|
14
|
+
const fileExists = await isFileExists(path
|
|
15
|
+
.join(uploadChunkDirectory, `${id}.${meta.extension}`)
|
|
16
|
+
.replace(/\\/g, "/"));
|
|
17
|
+
return {
|
|
18
|
+
...meta,
|
|
19
|
+
uploadChunkDirectory,
|
|
20
|
+
exists: !!fileExists,
|
|
21
|
+
finished: meta.uploaded && meta.size && meta.uploaded === meta.size,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// request remote file upload status
|
|
25
|
+
const resp = await fetch(`${host}/${prefix}/${id}`, {
|
|
26
|
+
signal: AbortSignal.timeout(fetchTimeoutMs),
|
|
27
|
+
}).catch((err) => ({
|
|
28
|
+
json: () => Promise.resolve({ error: err.toString(), code: 501 }),
|
|
29
|
+
}));
|
|
30
|
+
return resp.json();
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const fetchTimeoutMs: number;
|
|
2
|
+
export declare const prefix = "file/upload2";
|
|
3
|
+
export declare const uploadChunkDirectory = "/files/uploads";
|
|
4
|
+
export declare const fileDir: string;
|
|
5
|
+
export declare const metaDir: string;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,QAAmC,CAAC;AAE/D,eAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAErD,eAAO,MAAM,OAAO,QAEE,CAAC;AAEvB,eAAO,MAAM,OAAO,QAA4B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import config from "../../../config.js";
|
|
3
|
+
import getFolder from "../crud/funcs/utils/getFolder.js";
|
|
4
|
+
config.chunkSize = +(config.chunkSize || 1048576); // 1 MB per chunk by default
|
|
5
|
+
const rootDir = getFolder(config, "local");
|
|
6
|
+
export const fetchTimeoutMs = +(config.fetchTimeoutMs || 5000);
|
|
7
|
+
export const prefix = "file/upload2";
|
|
8
|
+
export const uploadChunkDirectory = "/files/uploads";
|
|
9
|
+
export const fileDir = path
|
|
10
|
+
.join(rootDir, uploadChunkDirectory)
|
|
11
|
+
.replace(/\\/g, "/");
|
|
12
|
+
export const metaDir = path.join(fileDir, "tmp");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startUpload.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/startUpload.ts"],"names":[],"mappings":"AAaA,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,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,gBAkEA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import getUploadStatus from "./getUploadStatus.js";
|
|
5
|
+
import { prefix, fileDir, metaDir, uploadChunkDirectory, fetchTimeoutMs, } from "./index.js";
|
|
6
|
+
export default async function startUpload({ host, id, fileName, size, subdir, }) {
|
|
7
|
+
if (subdir && (typeof subdir !== "string" || subdir.includes(".."))) {
|
|
8
|
+
return {
|
|
9
|
+
error: "invalid params: subdir",
|
|
10
|
+
code: 400,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (!host) {
|
|
14
|
+
const extension = path.extname(fileName).substring(1);
|
|
15
|
+
const id1 = id || randomUUID();
|
|
16
|
+
const key = id1.split("-").pop();
|
|
17
|
+
const meta = {
|
|
18
|
+
id: id1,
|
|
19
|
+
key,
|
|
20
|
+
fileName,
|
|
21
|
+
size,
|
|
22
|
+
extension,
|
|
23
|
+
uploaded: 0,
|
|
24
|
+
exists: false,
|
|
25
|
+
};
|
|
26
|
+
// check current upload state
|
|
27
|
+
if (id) {
|
|
28
|
+
const status = await getUploadStatus({ id });
|
|
29
|
+
Object.assign(meta, status);
|
|
30
|
+
}
|
|
31
|
+
// resume file upload
|
|
32
|
+
if (meta.uploaded > 0) {
|
|
33
|
+
return meta;
|
|
34
|
+
}
|
|
35
|
+
// if not started - start new upload
|
|
36
|
+
const relativeDirpath = path
|
|
37
|
+
.join(uploadChunkDirectory, subdir || "")
|
|
38
|
+
.replace(/\\/g, "/");
|
|
39
|
+
await mkdir(path.join(fileDir, "tmp"), { recursive: true });
|
|
40
|
+
// create metadata for resumable upload
|
|
41
|
+
const metaData = {
|
|
42
|
+
...meta,
|
|
43
|
+
subdir,
|
|
44
|
+
metaPath: undefined,
|
|
45
|
+
relativeDirpath,
|
|
46
|
+
};
|
|
47
|
+
await writeFile(path.join(metaDir, `${id1}.json`), JSON.stringify(metaData, null, 2));
|
|
48
|
+
return { ...meta, metaPath: undefined };
|
|
49
|
+
}
|
|
50
|
+
const res = await fetch(`${host}/${prefix}/start`, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: { "Content-Type": "application/json" },
|
|
53
|
+
body: JSON.stringify({ fileName, size, subdir, id }),
|
|
54
|
+
signal: AbortSignal.timeout(fetchTimeoutMs),
|
|
55
|
+
}).catch((err) => ({
|
|
56
|
+
json: () => Promise.resolve({ error: err.toString(), code: 501 }),
|
|
57
|
+
}));
|
|
58
|
+
return res.json();
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadChunk.d.ts","sourceRoot":"","sources":["../../../../server/plugins/upload/uploadChunk.ts"],"names":[],"mappings":"AAaA,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,gBA+EA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { prefix, metaDir, fetchTimeoutMs, uploadChunkDirectory, } from "./index.js";
|
|
5
|
+
import uploadFile from "../file/uploadFile.js";
|
|
6
|
+
import applyHook from "../hook/applyHook.js";
|
|
7
|
+
export default async function uploadChunk({ host, id, body, offset, end, size, }) {
|
|
8
|
+
if (!host) {
|
|
9
|
+
const metaExists = existsSync(path.join(metaDir, `${id}.json`));
|
|
10
|
+
if (!metaExists) {
|
|
11
|
+
return { error: "File not found", code: 404 };
|
|
12
|
+
}
|
|
13
|
+
const meta = JSON.parse(await readFile(path.join(metaDir, `${id}.json`), "utf8"));
|
|
14
|
+
if (size !== meta.size) {
|
|
15
|
+
return { error: "Total size mismatch", code: 400 };
|
|
16
|
+
}
|
|
17
|
+
if (offset !== meta.uploaded) {
|
|
18
|
+
return { error: "Wrong offset", expected: meta.uploaded, code: 409 };
|
|
19
|
+
}
|
|
20
|
+
if (body?.length !== end - offset + 1) {
|
|
21
|
+
return { error: "Chunk size mismatch", code: 400 };
|
|
22
|
+
}
|
|
23
|
+
// append chunk to existing file
|
|
24
|
+
await uploadFile(path
|
|
25
|
+
.join(uploadChunkDirectory, `${id}.${meta.extension}`)
|
|
26
|
+
.replace(/\\/g, "/"), body);
|
|
27
|
+
meta.uploaded = end + 1;
|
|
28
|
+
// update metadata for resumable upload
|
|
29
|
+
await writeFile(path.join(metaDir, `${id}.json`), JSON.stringify(meta, null, 2));
|
|
30
|
+
const finished = meta.uploaded === meta.size;
|
|
31
|
+
if (finished) {
|
|
32
|
+
const metaData = {
|
|
33
|
+
...meta,
|
|
34
|
+
uploadDate: new Date().toISOString(),
|
|
35
|
+
exists: true,
|
|
36
|
+
finished: true,
|
|
37
|
+
};
|
|
38
|
+
// save metadata
|
|
39
|
+
const fileBytes = Buffer.from(JSON.stringify(metaData, null, 2));
|
|
40
|
+
await writeFile(path.join(metaDir, `${id}.json`), fileBytes);
|
|
41
|
+
const payload = { uploaded: meta.uploaded, finished };
|
|
42
|
+
const hookData = await applyHook("afterChunkedUpload", { id, meta });
|
|
43
|
+
return hookData || payload;
|
|
44
|
+
}
|
|
45
|
+
return { uploaded: meta.uploaded, finished };
|
|
46
|
+
}
|
|
47
|
+
if (!end || !size) {
|
|
48
|
+
return { error: "not enough params: offset/end/size", code: 400 };
|
|
49
|
+
}
|
|
50
|
+
const res = await fetch(`${host}/${prefix}/${id}`, {
|
|
51
|
+
method: "PATCH",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Range": `bytes ${offset || 0}-${end}/${size}`,
|
|
54
|
+
},
|
|
55
|
+
body,
|
|
56
|
+
signal: AbortSignal.timeout(fetchTimeoutMs),
|
|
57
|
+
}).catch((err) => ({
|
|
58
|
+
json: () => Promise.resolve({ error: err.toString(), code: 501 }),
|
|
59
|
+
}));
|
|
60
|
+
return res.json();
|
|
61
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/util/funcs/unflattenObject.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/util/funcs/unflattenObject.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,GAAG,MAkDnD"}
|
|
@@ -18,7 +18,7 @@ export default function unflattenObject(flatObj) {
|
|
|
18
18
|
nestedObj[part] = JSON.parse(flatObj[key] || "{}");
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
21
|
-
console.warn(
|
|
21
|
+
console.warn(`⚠️ Error parsing JSON for key ${key}:`, err.toString());
|
|
22
22
|
nestedObj[part] = flatObj[key]; // fallback to original value if parsing fails
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -29,7 +29,7 @@ export default function unflattenObject(flatObj) {
|
|
|
29
29
|
nestedObj[part] = JSON.parse(flatObj[key] || "{}");
|
|
30
30
|
}
|
|
31
31
|
catch (err) {
|
|
32
|
-
console.warn(
|
|
32
|
+
console.warn(`⚠️ Error parsing JSON for key ${key}:`, err.toString());
|
|
33
33
|
nestedObj[part] = flatObj[key]; // fallback to original value if parsing fails
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../../../../../../server/routes/auth/controllers/2factor/providers/totp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAU1D,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,UAAU,CAAC;CAChB;AAED,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAmBD,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO,kBAK/C,CAAC;AAEF,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO,kBAK/C,CAAC;AAEF,QAAA,MAAM,SAAS,GAAU,aAAa,OAAO;;;;EAc5C,CAAC;AAuBF,QAAA,MAAM,QAAQ,GAAU,aAAa,OAAO;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../../../../../../server/routes/auth/controllers/2factor/providers/totp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAU1D,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,UAAU,CAAC;CAChB;AAED,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAmBD,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO,kBAK/C,CAAC;AAEF,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO,kBAK/C,CAAC;AAEF,QAAA,MAAM,SAAS,GAAU,aAAa,OAAO;;;;EAc5C,CAAC;AAuBF,QAAA,MAAM,QAAQ,GAAU,aAAa,OAAO;;;;;;;;;;;;EA0D3C,CAAC;AAEF,QAAA,MAAM,MAAM,GAAU,0BAA0B,KAAK;;;EAiBpD,CAAC;AAKF,QAAA,MAAM,MAAM,GAAU,2BAA2B,KAAK,iBAqBrD,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;;AAE3E,wBAAoB"}
|
|
@@ -48,7 +48,7 @@ const generate = async ({ uid, pg }) => {
|
|
|
48
48
|
.then((el) => el.rows?.[0] || {});
|
|
49
49
|
const { sufix } = config.auth?.["2fa"] || {};
|
|
50
50
|
if (sufix && !userData[sufix]) {
|
|
51
|
-
console.warn("2fa prefix not found at userData");
|
|
51
|
+
console.warn("⚠️ 2fa prefix not found at userData");
|
|
52
52
|
}
|
|
53
53
|
const otp = getOTP((sufix ? userData[sufix] : null) || userData.login || userData.code || uid, secret);
|
|
54
54
|
const qrCodeAsImageSource = await qrcode.toDataURL(otp);
|
|
@@ -17,5 +17,8 @@ import { FastifyReply } from "fastify";
|
|
|
17
17
|
* @returns {String|Object} error Опис помилки
|
|
18
18
|
* @returns {String|Object} message Повідомлення про успішну реєстрацію
|
|
19
19
|
*/
|
|
20
|
-
export default function registration(
|
|
20
|
+
export default function registration(req: any, reply: FastifyReply): Promise<{
|
|
21
|
+
message: string;
|
|
22
|
+
status: number;
|
|
23
|
+
}>;
|
|
21
24
|
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/core/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAavC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,YAAY,CACxC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,YAAY;;;GA2HpB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const q1 = 'select count(*) > 0 as "userExists" from admin.users where $1 in (email,login)';
|
|
2
2
|
const q2 = 'select count(*) > 0 as "contactExists" from crm_acc.crm_contact where email=$1';
|
|
3
3
|
const q3 = "select contact_id as uid from crm_acc.crm_contact where email=$1";
|
|
4
|
+
const qUser = "select * from admin.users where email = $1 and enabled";
|
|
4
5
|
import config from "../../../../../config.js";
|
|
5
6
|
import dataInsert from "../../../../plugins/crud/funcs/dataInsert.js";
|
|
6
7
|
import pgClients from "../../../../plugins/pg/pgClients.js";
|
|
8
|
+
import authorizeUser from "../../../../plugins/auth/funcs/authorizeUser.js";
|
|
7
9
|
/**
|
|
8
10
|
* АПІ призначене для реєстрації нового користувача на сайті
|
|
9
11
|
*
|
|
@@ -22,7 +24,8 @@ import pgClients from "../../../../plugins/pg/pgClients.js";
|
|
|
22
24
|
* @returns {String|Object} error Опис помилки
|
|
23
25
|
* @returns {String|Object} message Повідомлення про успішну реєстрацію
|
|
24
26
|
*/
|
|
25
|
-
export default async function registration(
|
|
27
|
+
export default async function registration(req, reply) {
|
|
28
|
+
const { pg = pgClients.client, body = {} } = req;
|
|
26
29
|
const { password, email } = body;
|
|
27
30
|
if (!password || (!email && !body.login)) {
|
|
28
31
|
return reply.status(400).send({
|
|
@@ -107,9 +110,15 @@ export default async function registration({ method, pg = pgClients.client, body
|
|
|
107
110
|
data,
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
const newUser = await pg
|
|
114
|
+
.query(qUser, [login])
|
|
115
|
+
.then((res) => res.rows?.[0]);
|
|
116
|
+
if (!newUser) {
|
|
117
|
+
return { message: "Помилка завершення реєстрації, спробуйте увійти", status: 500 };
|
|
113
118
|
}
|
|
114
|
-
|
|
119
|
+
const authType = "creds-" + (newUser.user_type === "admin" ? "admin" : "user");
|
|
120
|
+
const result = await authorizeUser(newUser, req, authType);
|
|
121
|
+
return req.method === "GET"
|
|
122
|
+
? reply.status(302).redirect(result)
|
|
123
|
+
: reply.status(200).send(result);
|
|
115
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/filter.ts"],"names":[],"mappings":"AAaA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;CAC3B;AAED,wBAA8B,SAAS,CACrC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,GAC5C,OAAO,CAAC,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,GAAG,CAAC,CAoSvE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import config from "../../../../config.js";
|
|
2
3
|
import logger from "../../../plugins/logger/getLogger.js";
|
|
3
4
|
import autoIndex from "../../../plugins/pg/funcs/autoIndex.js";
|
|
4
5
|
import getSelect from "../../../plugins/table/funcs/getSelect.js";
|
|
@@ -7,6 +8,7 @@ import pgClients from "../../../plugins/pg/pgClients.js";
|
|
|
7
8
|
import { applyHook } from "../../../../utils.js";
|
|
8
9
|
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
9
10
|
import getMeta from "../../../plugins/pg/funcs/getMeta.js";
|
|
11
|
+
const { prefix = "/api" } = config;
|
|
10
12
|
export default async function filterAPI(req, reply, iscalled) {
|
|
11
13
|
const time = Date.now();
|
|
12
14
|
const { params, pg = pgClients.client, user = {}, query = {} } = req;
|
|
@@ -73,6 +75,11 @@ export default async function filterAPI(req, reply, iscalled) {
|
|
|
73
75
|
title: el.title || el.ua,
|
|
74
76
|
extra: extraColumns.includes(el.id || el.name),
|
|
75
77
|
}));
|
|
78
|
+
(filters || [])
|
|
79
|
+
.filter((el) => el.data)
|
|
80
|
+
.forEach((el) => Object.assign(el, {
|
|
81
|
+
api: `${prefix}/suggest/${table}:${el.id}?sel=${el.data}`,
|
|
82
|
+
}));
|
|
76
83
|
await Promise.all(filters
|
|
77
84
|
.filter((el) => el.id &&
|
|
78
85
|
el.type !== "Autocomplete" &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/functions/getData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4EzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,GACtB,EAAE;IACD,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,EACD,MAAM,CAAC,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/functions/getData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4EzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,GACtB,EAAE;IACD,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,EACD,MAAM,CAAC,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,GAAG,gBAk0Bb"}
|
|
@@ -140,17 +140,6 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
140
140
|
if (!actions.includes("view") && !config?.local && !called) {
|
|
141
141
|
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
142
142
|
}
|
|
143
|
-
/* const filters = ((body?.filter_list || [])
|
|
144
|
-
.concat(body?.filterInline || [])
|
|
145
|
-
.concat(body?.filterCustom || [])
|
|
146
|
-
.concat(body?.filterState || [])
|
|
147
|
-
.concat(body?.filterList || [])
|
|
148
|
-
.concat(body?.filters || [])
|
|
149
|
-
).filter(el => el.id || el.name); */
|
|
150
|
-
if (body?.filter_list || body?.filterList) {
|
|
151
|
-
// console.warn('invalid filters in template: filter_list / filterList');
|
|
152
|
-
// logger.file('crud/warning', { msg: 'invalid filters', template: templateName });
|
|
153
|
-
}
|
|
154
143
|
const { list: filters = [] } = objectId
|
|
155
144
|
? {}
|
|
156
145
|
: (await getFilter({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/upload/index.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,GAAG,QAwFtC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import config from "../../../config.js";
|
|
2
|
+
const { chunkSize = 1048576 } = config;
|
|
3
|
+
import { prefix } from "../../plugins/upload/index.js";
|
|
4
|
+
import startUpload from "../../plugins/upload/startUpload.js";
|
|
5
|
+
import uploadChunk from "../../plugins/upload/uploadChunk.js";
|
|
6
|
+
import getUploadStatus from "../../plugins/upload/getUploadStatus.js";
|
|
7
|
+
const policy = "L0"; // public
|
|
8
|
+
export default function plugin(app) {
|
|
9
|
+
// provide server with metadata for chunked upload
|
|
10
|
+
app.post(`/${prefix}/start`, { config: { policy, description: "Init chunked upload" } }, async (req, reply) => {
|
|
11
|
+
const { fileName, size, subdir, id } = req.body || {};
|
|
12
|
+
if (!fileName || !size) {
|
|
13
|
+
return reply
|
|
14
|
+
.code(400)
|
|
15
|
+
.send({ error: "fileName and size required", code: 400 });
|
|
16
|
+
}
|
|
17
|
+
const result = await startUpload({ fileName, size, subdir, id });
|
|
18
|
+
if (result.code) {
|
|
19
|
+
return reply
|
|
20
|
+
.status(result.code)
|
|
21
|
+
.send({ error: result.error, code: result.code });
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
});
|
|
25
|
+
// disable default parser for PATCH /upload/:id
|
|
26
|
+
// allows accept all content types (req.body = raw buffer)
|
|
27
|
+
// limit body size to 50MB by default, depends on upload chunk size
|
|
28
|
+
app.addContentTypeParser("*", { parseAs: "buffer", bodyLimit: chunkSize * 50 }, (req, body, done) => {
|
|
29
|
+
done(null, body);
|
|
30
|
+
});
|
|
31
|
+
// upload chunks
|
|
32
|
+
app.patch(`/${prefix}/:id`, { config: { policy, description: "Upload chunk of data" } }, async (req, reply) => {
|
|
33
|
+
if (!req.headers["content-range"]) {
|
|
34
|
+
return reply
|
|
35
|
+
.status(411)
|
|
36
|
+
.send({ error: "Content-Range required", code: 411 });
|
|
37
|
+
}
|
|
38
|
+
const match = req.headers["content-range"].match(/bytes (\d+)-(\d+)\/(\d+)/);
|
|
39
|
+
if (!match) {
|
|
40
|
+
return { error: "Invalid Content-Range", code: 400 };
|
|
41
|
+
}
|
|
42
|
+
const offset = parseInt(match[1], 10);
|
|
43
|
+
const end = parseInt(match[2], 10);
|
|
44
|
+
const size = parseInt(match[3], 10);
|
|
45
|
+
const result = await uploadChunk({
|
|
46
|
+
id: req.params.id,
|
|
47
|
+
body: req.body,
|
|
48
|
+
offset,
|
|
49
|
+
end,
|
|
50
|
+
size,
|
|
51
|
+
});
|
|
52
|
+
if (result.code) {
|
|
53
|
+
return reply
|
|
54
|
+
.status(result.code)
|
|
55
|
+
.send({ error: result.error, code: result.code });
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
});
|
|
59
|
+
// check upload status
|
|
60
|
+
app.get(`/${prefix}/:id`, { config: { policy, description: "Check chunked upload status" } }, async (req) => {
|
|
61
|
+
const { id } = req.params;
|
|
62
|
+
const status = await getUploadStatus({ id });
|
|
63
|
+
return status;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../server/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,oBA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AC5B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACtE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -80,6 +80,10 @@ export { default as getAdminAccess } from "./server/plugins/access/funcs/getAdmi
|
|
|
80
80
|
export { default as sendNotification } from "./server/plugins/auth/funcs/sendNotification.js";
|
|
81
81
|
export { default as addUserNotification } from "./server/plugins/notifications/addNotification.js";
|
|
82
82
|
export { addUserCls, editUserCls, deleteUserCls, getUserCls, } from "./server/plugins/usercls/index.js";
|
|
83
|
+
export { prefix as uploadChunkApiPrefix, fileDir as uploadChunkFileDir, uploadChunkDirectory, } from "./server/plugins/upload/index.js";
|
|
84
|
+
export { default as getUploadStatus } from "./server/plugins/upload/getUploadStatus.js";
|
|
85
|
+
export { default as startUpload } from "./server/plugins/upload/startUpload.js";
|
|
86
|
+
export { default as uploadChunk } from "./server/plugins/upload/uploadChunk.js";
|
|
83
87
|
export { default as s3Client } from "./server/plugins/file/providers/s3/client.js";
|
|
84
88
|
declare const _default: null;
|
|
85
89
|
export default _default;
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BA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M,kDAAkD,CAAC;AAGhG,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAE3F,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iDAAiD,CAAC;AAE5F,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,iDAAiD,CAAC;AAE9F,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAEnG,OAAO,EACL,UAAU,EACV,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,MAAM,IAAI,oBAAoB,EAC9B,OAAO,IAAI,kBAAkB,EAC7B,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,8CAA8C,CAAC;;AAEnF,wBAAoB"}
|
package/dist/utils.js
CHANGED
|
@@ -97,5 +97,9 @@ export { default as getAdminAccess } from "./server/plugins/access/funcs/getAdmi
|
|
|
97
97
|
export { default as sendNotification } from "./server/plugins/auth/funcs/sendNotification.js"; // email
|
|
98
98
|
export { default as addUserNotification } from "./server/plugins/notifications/addNotification.js"; // popup, widget, interface etc.
|
|
99
99
|
export { addUserCls, editUserCls, deleteUserCls, getUserCls, } from "./server/plugins/usercls/index.js";
|
|
100
|
+
export { prefix as uploadChunkApiPrefix, fileDir as uploadChunkFileDir, uploadChunkDirectory, } from "./server/plugins/upload/index.js";
|
|
101
|
+
export { default as getUploadStatus } from "./server/plugins/upload/getUploadStatus.js";
|
|
102
|
+
export { default as startUpload } from "./server/plugins/upload/startUpload.js";
|
|
103
|
+
export { default as uploadChunk } from "./server/plugins/upload/uploadChunk.js";
|
|
100
104
|
export { default as s3Client } from "./server/plugins/file/providers/s3/client.js";
|
|
101
105
|
export default null;
|