@opengis/fastify-table 2.0.82 → 2.0.84

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.
@@ -1,12 +1,12 @@
1
- import { access } from "node:fs/promises";
1
+ import { stat } from "node:fs/promises";
2
2
  import getPath from "./getPath.js";
3
3
  const isFileExists = async (filepath) => {
4
4
  const fullPath = getPath(filepath, { check: true });
5
5
  if (!fullPath)
6
6
  return false;
7
7
  try {
8
- await access(fullPath);
9
- return true;
8
+ const stats = await stat(fullPath);
9
+ return stats.isFile();
10
10
  }
11
11
  catch (err) {
12
12
  return false;
@@ -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;AAU5C;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAA8B,OAAO,CACnC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACvC,KAAK,EAAE,YAAY,gBA+CpB"}
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;AAU5C;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAA8B,OAAO,CACnC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACvC,KAAK,EAAE,YAAY,gBAgDpB"}
@@ -10,6 +10,7 @@ export default function resize({ query, unittest, }: {
10
10
  w?: string;
11
11
  h?: string;
12
12
  nocache?: any;
13
+ format?: string;
13
14
  };
14
15
  unittest?: any;
15
16
  }, reply: FastifyReply): Promise<never>;
@@ -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;AA6B5C;;GAEG;AAEH,wBAA8B,MAAM,CAClC,EACE,KAAK,EACL,QAAQ,GACT,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;KACf,CAAC;IACF,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,EACD,KAAK,EAAE,YAAY,kBAuGpB"}
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;AA+B5C;;GAEG;AAEH,wBAA8B,MAAM,CAClC,EACE,KAAK,EACL,QAAQ,GACT,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;KACjB,CAAC;IACF,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,EACD,KAAK,EAAE,YAAY,kBAsHpB"}
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import sharp from "sharp";
2
3
  import { imageSize } from "image-size";
3
4
  import { config, downloadFile, uploadFile, isFileExists, } from "../../../../utils.js";
4
5
  import grpc from "../../../plugins/grpc/grpc.js";
@@ -18,7 +19,7 @@ const { resizeImage } = grpc();
18
19
  * Апі використовується для зміни розміру фото за шляхом
19
20
  */
20
21
  export default async function resize({ query, unittest, }, reply) {
21
- const { filepath, quality, size, w, h, nocache } = query || {};
22
+ const { filepath, quality, size, w, h, nocache, format } = query || {};
22
23
  if (!filepath) {
23
24
  return reply.status(400).send("not enough query params: filepath");
24
25
  }
@@ -31,17 +32,23 @@ export default async function resize({ query, unittest, }, reply) {
31
32
  ? filepath.replace(basename, `${size}_resized_${basename}`)
32
33
  : filepath.replace(basename, `${w || defaultWidth}_${h || (w ? "" : defaultHeight)}_resized_${basename}`);
33
34
  // get Resize Data
34
- const fileExists = await isFileExists(resizePath1);
35
- const originalFileExists = await isFileExists(resizePath1.replace("files/", "files/original/")); // resize-all API compatibility
36
- const resizePath = originalFileExists
37
- ? resizePath1.replace("files/", "files/original/")
35
+ const resizePath2 = format === "webp"
36
+ ? resizePath1.replace(path.extname(resizePath1), ".webp")
38
37
  : resizePath1;
38
+ const fileExists = await isFileExists(resizePath2);
39
+ const originalFileExists = await isFileExists(resizePath2.replace("files/", "files/original/")); // resize-all API compatibility
40
+ const resizePath = originalFileExists
41
+ ? resizePath2.replace("files/", "files/original/")
42
+ : resizePath2;
39
43
  const resizeData = fileExists
40
44
  ? await downloadFile(resizePath, { buffer: true })
41
45
  : null;
42
46
  if (resizeData && !config.disableCache && !nocache && !unittest) {
43
47
  return reply
44
- .headers({ "Content-Type": mimeType, "Cache-control": "max-age=604800" })
48
+ .headers({
49
+ "Content-Type": format === "webp" ? "image/webp" : mimeType,
50
+ "Cache-control": "max-age=604800",
51
+ })
45
52
  .send(resizeData);
46
53
  }
47
54
  // get File Data
@@ -80,6 +87,13 @@ export default async function resize({ query, unittest, }, reply) {
80
87
  quality: resizeQuality,
81
88
  });
82
89
  await uploadFile(resizePath, Buffer.from(result, "base64"));
90
+ if (format === "webp") {
91
+ const buffer = await sharp(Buffer.from(result, "base64"))
92
+ .webp({ quality: resizeQuality })
93
+ .toBuffer({ resolveWithObject: false });
94
+ await uploadFile(resizePath2, buffer);
95
+ return reply.headers({ "Content-Type": "image/webp" }).send(buffer);
96
+ }
83
97
  return reply
84
98
  .headers({ "Content-Type": mimeType })
85
99
  .send(Buffer.from(result, "base64"));
@@ -1,6 +1,6 @@
1
1
  import type { FastifyReply } from "fastify";
2
2
  import type { ExtendedPG } from "../../../types/core.js";
3
- export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, sufix, filterList, actions: actionsParam, }: {
3
+ export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, sufix, filterList, actions: actionsParam, columns: columnsParam, }: {
4
4
  pg: ExtendedPG;
5
5
  params?: {
6
6
  id?: string;
@@ -16,5 +16,6 @@ export default function dataAPI({ pg, params, table, id, headers, query, user, c
16
16
  sufix?: boolean;
17
17
  filterList?: any[];
18
18
  actions?: string[];
19
+ columns?: string[];
19
20
  }, reply: FastifyReply, called?: any): Promise<any>;
20
21
  //# sourceMappingURL=getData.d.ts.map
@@ -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;AA4DzD,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,GACtB,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,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,MAA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G,CAAC,CAAC;IAC1B,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,KAAK,EAAE,YAAY,EACnB,MAAM,CAAC,EAAE,GAAG,gBA4zBb"}
@@ -39,7 +39,7 @@ function getOrder(queryOrder, queryDesc, defaultOrder, columnList, iscalled = fa
39
39
  const checkInline = {};
40
40
  const maxLimit = 100;
41
41
  const defaultLimit = 20;
42
- export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam, }, reply, called) {
42
+ export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam, columns: columnsParam, }, reply, called) {
43
43
  const time = Date.now();
44
44
  const timeArr = [Date.now()];
45
45
  const { uid } = user;
@@ -286,10 +286,11 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
286
286
  .filter(Boolean)
287
287
  .filter((el) => checkQuery(el));
288
288
  const q = `select ${pk ? `"${pk}" as id,` : ""}
289
- ${objectId || query.key ? "*" : sqlColumns || cols || "*"}
290
- ${metaCols}
291
-
292
- ${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry").length
289
+ ${objectId || query.key
290
+ ? "*"
291
+ : columnsParam || sqlColumns || cols || "*"}
292
+ ${metaCols}
293
+ ${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry").length && !columnsParam
293
294
  ? `,${dbColumns
294
295
  .filter((el) => pg.pgType?.[el.dataTypeID] === "geometry")
295
296
  .map((el) => `st_asgeojson("${el.name.replace(/'/g, "''")}")::json as "${el.name.replace(/'/g, "''")}"`)
package/package.json CHANGED
@@ -1,88 +1,89 @@
1
- {
2
- "name": "@opengis/fastify-table",
3
- "version": "2.0.82",
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
- "prepublishOnly": "npm run build",
25
- "clean": "tsc -b --clean",
26
- "build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist",
27
- "prod": "NODE_ENV=production bun dist/server",
28
- "patch": "npm version patch && git push && npm publish",
29
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
30
- "test": "bun test",
31
- "compress": "node compress.js",
32
- "dev1": "bun --hot dist/server",
33
- "dev": "NODE_ENV=production bun start",
34
- "start": "LOG_LEVEL=trace bun server"
35
- },
36
- "dependencies": {
37
- "@aws-sdk/client-s3": "3.879.0",
38
- "@aws-sdk/lib-storage": "3.879.0",
39
- "@fastify/cookie": "11.0.2",
40
- "@fastify/http-proxy": "11.1.2",
41
- "@fastify/multipart": "9.0.3",
42
- "@fastify/passport": "3.0.2",
43
- "@fastify/rate-limit": "10.3.0",
44
- "@fastify/session": "11.1.0",
45
- "@grpc/grpc-js": "1.10.11",
46
- "@grpc/proto-loader": "0.7.15",
47
- "apache-crypt": "1.2.6",
48
- "better-sqlite3": "12.2.0",
49
- "dotenv": "16.5.0",
50
- "fastify": "5.3.3",
51
- "fastify-plugin": "5.0.1",
52
- "fastify-session-redis-store": "7.1.2",
53
- "handlebars": "4.7.8",
54
- "image-size": "1.2.0",
55
- "ioredis": "5.3.2",
56
- "js-yaml": "4.1.0",
57
- "markdown-it": "14.1.0",
58
- "nodemailer": "7.0.6",
59
- "otplib": "12.0.1",
60
- "pg": "8.11.6",
61
- "pino": "9.5.0",
62
- "pino-abstract-transport": "2.0.0",
63
- "promised-handlebars": "2.0.1",
64
- "qrcode": "1.5.4",
65
- "uglify-js": "3.19.3",
66
- "undici": "7.16.0"
67
- },
68
- "devDependencies": {
69
- "@types/better-sqlite3": "^7.6.13",
70
- "@types/bun": "^1.2.21",
71
- "@types/js-yaml": "^4.0.9",
72
- "@types/markdown-it": "^14.1.2",
73
- "@types/node": "^24.3.1",
74
- "@types/nodemailer": "^7.0.1",
75
- "@types/passport": "^1.0.17",
76
- "@types/passport-local": "^1.0.38",
77
- "@types/pg": "^8.15.5",
78
- "@types/qrcode": "^1.5.5",
79
- "copyfiles": "^2.4.1",
80
- "eslint": "^9.35.0",
81
- "eslint-config-airbnb-extended": "^2.3.1",
82
- "ts-migrate": "^0.1.35",
83
- "typescript": "^5.9.2",
84
- "vitest": "^3.2.4"
85
- },
86
- "author": "Softpro",
87
- "license": "ISC"
88
- }
1
+ {
2
+ "name": "@opengis/fastify-table",
3
+ "version": "2.0.84",
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
+ "prepublishOnly": "npm run build",
25
+ "clean": "tsc -b --clean",
26
+ "build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist",
27
+ "prod": "NODE_ENV=production bun dist/server",
28
+ "patch": "npm version patch && git push && npm publish",
29
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
30
+ "test": "bun test",
31
+ "compress": "node compress.js",
32
+ "dev1": "bun --hot dist/server",
33
+ "dev": "NODE_ENV=production bun start",
34
+ "start": "LOG_LEVEL=trace bun server"
35
+ },
36
+ "dependencies": {
37
+ "@aws-sdk/client-s3": "3.879.0",
38
+ "@aws-sdk/lib-storage": "3.879.0",
39
+ "@fastify/cookie": "11.0.2",
40
+ "@fastify/http-proxy": "11.1.2",
41
+ "@fastify/multipart": "9.0.3",
42
+ "@fastify/passport": "3.0.2",
43
+ "@fastify/rate-limit": "10.3.0",
44
+ "@fastify/session": "11.1.0",
45
+ "@grpc/grpc-js": "1.10.11",
46
+ "@grpc/proto-loader": "0.7.15",
47
+ "apache-crypt": "1.2.6",
48
+ "better-sqlite3": "12.2.0",
49
+ "dotenv": "16.5.0",
50
+ "fastify": "5.3.3",
51
+ "fastify-plugin": "5.0.1",
52
+ "fastify-session-redis-store": "7.1.2",
53
+ "handlebars": "4.7.8",
54
+ "image-size": "1.2.0",
55
+ "ioredis": "5.3.2",
56
+ "js-yaml": "4.1.0",
57
+ "markdown-it": "14.1.0",
58
+ "nodemailer": "7.0.6",
59
+ "otplib": "12.0.1",
60
+ "pg": "8.11.6",
61
+ "pino": "9.5.0",
62
+ "pino-abstract-transport": "2.0.0",
63
+ "promised-handlebars": "2.0.1",
64
+ "qrcode": "1.5.4",
65
+ "sharp": "0.34.5",
66
+ "uglify-js": "3.19.3",
67
+ "undici": "7.16.0"
68
+ },
69
+ "devDependencies": {
70
+ "@types/better-sqlite3": "^7.6.13",
71
+ "@types/bun": "^1.2.21",
72
+ "@types/js-yaml": "^4.0.9",
73
+ "@types/markdown-it": "^14.1.2",
74
+ "@types/node": "^24.3.1",
75
+ "@types/nodemailer": "^7.0.1",
76
+ "@types/passport": "^1.0.17",
77
+ "@types/passport-local": "^1.0.38",
78
+ "@types/pg": "^8.15.5",
79
+ "@types/qrcode": "^1.5.5",
80
+ "copyfiles": "^2.4.1",
81
+ "eslint": "^9.35.0",
82
+ "eslint-config-airbnb-extended": "^2.3.1",
83
+ "ts-migrate": "^0.1.35",
84
+ "typescript": "^5.9.2",
85
+ "vitest": "^3.2.4"
86
+ },
87
+ "author": "Softpro",
88
+ "license": "ISC"
89
+ }