@opengis/fastify-table 2.2.2 → 2.2.4
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/server/plugins/file/isFileExists.d.ts +1 -1
- package/dist/server/plugins/file/isFileExists.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/fs.d.ts +1 -0
- package/dist/server/plugins/file/providers/fs.d.ts.map +1 -1
- package/dist/server/plugins/file/providers/fs.js +1 -0
- package/dist/server/routes/file/controllers/files.d.ts +4 -1
- package/dist/server/routes/file/controllers/files.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/files.js +15 -1
- package/dist/server/routes/file/controllers/resize.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/resize.js +8 -1
- package/dist/server/routes/file/controllers/resizeAll.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/resizeAll.js +2 -1
- package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
- package/dist/server/routes/table/functions/getData.js +8 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFileExists.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/isFileExists.ts"],"names":[],"mappings":"AAGA,iBAAe,YAAY,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"isFileExists.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/isFileExists.ts"],"names":[],"mappings":"AAGA,iBAAe,YAAY,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,gBAclC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/file/providers/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAuGzB,MAAM,CAAC,OAAO,UAAU,SAAS
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/file/providers/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAuGzB,MAAM,CAAC,OAAO,UAAU,SAAS;;qBAtFG,MAAM;uBAsB7B,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;qBAyBpC,MAAM,QAAQ,GAAG;2BALX,GAAG,QAAO,GAAG;qBAgCI,MAAM;mBAlER,MAAM,gBAAgB,MAAM;4BAqEnB,GAAG;yBAGN,GAAG;wBAGJ,GAAG;EAgBzC"}
|
|
@@ -75,6 +75,7 @@ const getMDate = () => async (filepath) => new Date((await fsp.stat(getPath(file
|
|
|
75
75
|
const readdir = () => async (filepath) => fsp.readdir(getPath(filepath) || "");
|
|
76
76
|
export default function fsStorage() {
|
|
77
77
|
return {
|
|
78
|
+
name: "fs",
|
|
78
79
|
deleteFile: deleteFile(),
|
|
79
80
|
downloadFile: downloadFile(),
|
|
80
81
|
uploadFile: uploadFile(),
|
|
@@ -17,10 +17,13 @@ import type { FastifyReply } from "fastify";
|
|
|
17
17
|
* @returns {Object} headers Заголовки HTTP
|
|
18
18
|
* @returns {String} pipe Шлях до файла для скачування або відображення
|
|
19
19
|
*/
|
|
20
|
-
export default function getFile({ params, user }: {
|
|
20
|
+
export default function getFile({ params, query, user, }: {
|
|
21
21
|
params: {
|
|
22
22
|
"*": string;
|
|
23
23
|
};
|
|
24
|
+
query: {
|
|
25
|
+
debug: string;
|
|
26
|
+
};
|
|
24
27
|
user?: Record<string, any>;
|
|
25
28
|
}, reply: FastifyReply): Promise<any>;
|
|
26
29
|
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkB5C;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAA8B,OAAO,CACnC,EACE,MAAM,EACN,KAAK,EACL,IAAI,GACL,EAAE;IACD,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,EACD,KAAK,EAAE,YAAY,gBA+DpB"}
|
|
@@ -2,8 +2,10 @@ import path from "node:path";
|
|
|
2
2
|
import mime from "../../../plugins/file/providers/mime/index.js";
|
|
3
3
|
// import isFileExists from "../../../plugins/file/isFileExists.js";
|
|
4
4
|
import downloadFile from "../../../plugins/file/downloadFile.js";
|
|
5
|
+
import config from "../../../../config.js";
|
|
5
6
|
import logger from "../../../plugins/logger/getLogger.js";
|
|
6
7
|
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
8
|
+
import providers from "../../../plugins/file/providers/index.js";
|
|
7
9
|
const grayGif = Buffer.from("R0lGODdhAwADAIEAAICAgAAAAAAAAAAAACwAAAAAAwADAAAIBwABCBw4MCAAOw==", "base64");
|
|
8
10
|
/**
|
|
9
11
|
* Апі використовується для отримання різних файлів і можливістю змінювати їх
|
|
@@ -23,7 +25,7 @@ const grayGif = Buffer.from("R0lGODdhAwADAIEAAICAgAAAAAAAAAAAACwAAAAAAwADAAAIBwA
|
|
|
23
25
|
* @returns {Object} headers Заголовки HTTP
|
|
24
26
|
* @returns {String} pipe Шлях до файла для скачування або відображення
|
|
25
27
|
*/
|
|
26
|
-
export default async function getFile({ params, user }, reply) {
|
|
28
|
+
export default async function getFile({ params, query, user, }, reply) {
|
|
27
29
|
if (!params?.["*"]) {
|
|
28
30
|
return reply.status(400).send({ error: "not enough params", code: 400 });
|
|
29
31
|
}
|
|
@@ -43,6 +45,18 @@ export default async function getFile({ params, user }, reply) {
|
|
|
43
45
|
if (hookData)
|
|
44
46
|
return hookData;
|
|
45
47
|
const filepath = path.join("files", relpath);
|
|
48
|
+
if ((config.local || user?.user_type?.includes?.("admin")) && query.debug) {
|
|
49
|
+
const fp = providers();
|
|
50
|
+
const existsS3 = fp.name === "s3"
|
|
51
|
+
? await fp
|
|
52
|
+
.fileExists(filepath, { fallback: false })
|
|
53
|
+
.catch(() => false)
|
|
54
|
+
.then((el) => !!el)
|
|
55
|
+
: undefined;
|
|
56
|
+
const { fileExists } = providers({ provider: "fs" });
|
|
57
|
+
const existsFS = await fileExists(filepath);
|
|
58
|
+
return reply.status(200).send({ provider: fp.name, existsS3, existsFS });
|
|
59
|
+
}
|
|
46
60
|
const fileStream = await downloadFile(filepath).catch();
|
|
47
61
|
if (!fileStream) {
|
|
48
62
|
// return reply.status(404).send({ error: "Файл не знайдено", code: 404 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/resize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/resize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAyC5C;;GAEG;AAEH,wBAA8B,MAAM,CAClC,EACE,KAAK,GACN,EAAE;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;CACH,EACD,KAAK,EAAE,YAAY,kBAoJpB"}
|
|
@@ -7,6 +7,7 @@ import { config, downloadFile,
|
|
|
7
7
|
isFileExists, getFolder, } from "../../../../utils.js";
|
|
8
8
|
import grpc from "../../../plugins/grpc/grpc.js";
|
|
9
9
|
import getMimeType from "../../../plugins/file/providers/mime/index.js";
|
|
10
|
+
import { mkdir } from "node:fs/promises";
|
|
10
11
|
const defaultWidth = 400;
|
|
11
12
|
const defaultHeight = 240;
|
|
12
13
|
const maxWidth = 2000;
|
|
@@ -107,13 +108,19 @@ export default async function resize({ query, }, reply) {
|
|
|
107
108
|
quality: resizeQuality,
|
|
108
109
|
});
|
|
109
110
|
// await uploadFile(resizePath, Buffer.from(result, "base64"));
|
|
111
|
+
await mkdir(path.dirname(path.join(rootDir, resizePath)), {
|
|
112
|
+
recursive: true,
|
|
113
|
+
});
|
|
110
114
|
await writeFile(path.join(rootDir, resizePath), Buffer.from(result, "base64"));
|
|
111
115
|
if (format === "webp") {
|
|
112
116
|
const buffer = await sharp(Buffer.from(result, "base64"))
|
|
113
117
|
.webp({ quality: resizeQuality })
|
|
114
118
|
.toBuffer({ resolveWithObject: false });
|
|
115
|
-
await writeFile(path.join(rootDir, resizePath2), buffer);
|
|
116
119
|
// await uploadFile(resizePath2, buffer);
|
|
120
|
+
await mkdir(path.dirname(path.join(rootDir, resizePath2)), {
|
|
121
|
+
recursive: true,
|
|
122
|
+
});
|
|
123
|
+
await writeFile(path.join(rootDir, resizePath2), buffer);
|
|
117
124
|
return reply.headers({ "Content-Type": "image/webp" }).send(buffer);
|
|
118
125
|
}
|
|
119
126
|
return reply
|
|
@@ -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":"AA0HA,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAsH3D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { writeFile, mkdir } from "node:fs/promises";
|
|
4
4
|
import { imageSize } from "image-size";
|
|
5
5
|
import { config, pgClients, eventStream, logger, isFileExists, downloadFile, uploadFile, getFolder, } from "../../../../utils.js";
|
|
6
6
|
import grpc from "../../../plugins/grpc/grpc.js";
|
|
@@ -59,6 +59,7 @@ async function resizeOne({ relpath: relpath1, resizeQuality = 80, maxWidth = 204
|
|
|
59
59
|
quality: resizeQuality,
|
|
60
60
|
});
|
|
61
61
|
// await uploadFile(relpath1, Buffer.from(result, "base64"));
|
|
62
|
+
await mkdir(path.dirname(path.join(rootDir, relpath1)), { recursive: true });
|
|
62
63
|
await writeFile(path.join(rootDir, relpath1), Buffer.from(result, "base64"));
|
|
63
64
|
send(`resize ${relpath1} success`);
|
|
64
65
|
success.push(relpath1);
|
|
@@ -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;AAkFzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,YAAY,EACrB,QAAgB,GACjB,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,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,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,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;AAkFzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,YAAY,EACrB,QAAgB,GACjB,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,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,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,EACD,MAAM,CAAC,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,GAAG,gBA23Bb"}
|
|
@@ -391,6 +391,7 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
391
391
|
id: row.id,
|
|
392
392
|
table: templateName,
|
|
393
393
|
form: loadTable?.form,
|
|
394
|
+
resource,
|
|
394
395
|
obj: tokenData?.obj || hookData?.obj,
|
|
395
396
|
}),
|
|
396
397
|
],
|
|
@@ -502,7 +503,12 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
502
503
|
});
|
|
503
504
|
const token = item.form && item.table
|
|
504
505
|
? setToken({
|
|
505
|
-
ids: [
|
|
506
|
+
ids: [
|
|
507
|
+
JSON.stringify({
|
|
508
|
+
...item,
|
|
509
|
+
resource,
|
|
510
|
+
}),
|
|
511
|
+
],
|
|
506
512
|
uid,
|
|
507
513
|
array: 1,
|
|
508
514
|
})[0]
|
|
@@ -654,6 +660,7 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
654
660
|
const addTokens = setToken({
|
|
655
661
|
ids: [
|
|
656
662
|
JSON.stringify({
|
|
663
|
+
resource,
|
|
657
664
|
table: templateName,
|
|
658
665
|
form: loadTable?.form,
|
|
659
666
|
obj: tokenData?.obj || hookData?.obj,
|