@opengis/fastify-table 2.0.117 → 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.
@@ -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,QAQpB;AAED,OAAO,EAEL,MAAM,EACN,MAAM,EACN,SAAS,GACV,CAAC"}
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
  }
@@ -1,2 +1,2 @@
1
- select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
1
+ select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
2
2
  where enabled order by coalesce(sur_name,'')||coalesce(' '||user_name,'')
@@ -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,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  export default function fsStorage(): {
3
3
  deleteFile: (fp: string) => Promise<void>;
4
- downloadFile: (fp: string, options?: Record<string, any>) => Promise<NonSharedBuffer | fs.ReadStream | {
4
+ downloadFile: (fp: string, options?: Record<string, any>) => Promise<Buffer<ArrayBufferLike> | fs.ReadStream | {
5
5
  original: string;
6
6
  full: string | null;
7
7
  } | null>;
@@ -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;AAmC1C,iBAAS,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,GAAE,GAAQ,QAiFlD;AAED,eAAe,MAAM,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":"AAiHA,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAoH3D"}
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 = () => { }, unittest, }) {
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 = {}, unittest } = req;
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 = unittest ? console.log : eventStream(reply);
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})q
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.117",
3
+ "version": "2.0.118",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -90,4 +90,4 @@
90
90
  },
91
91
  "author": "Softpro",
92
92
  "license": "ISC"
93
- }
93
+ }