@opengis/fastify-table 2.5.42 → 2.5.44

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.
Files changed (52) hide show
  1. package/dist/helper.d.ts +20 -0
  2. package/dist/helper.d.ts.map +1 -1
  3. package/dist/helper.js +26 -0
  4. package/dist/index.js +1 -1
  5. package/dist/server/plugins/access/funcs/getResources.d.ts +2 -1
  6. package/dist/server/plugins/access/funcs/getResources.d.ts.map +1 -1
  7. package/dist/server/plugins/access/funcs/getResources.js +5 -1
  8. package/dist/server/plugins/crud/funcs/getOpt.d.ts +1 -1
  9. package/dist/server/plugins/crud/funcs/getOpt.d.ts.map +1 -1
  10. package/dist/server/plugins/crud/funcs/getOpt.js +1 -1
  11. package/dist/server/plugins/crud/funcs/setOpt.d.ts +1 -1
  12. package/dist/server/plugins/crud/funcs/setOpt.d.ts.map +1 -1
  13. package/dist/server/plugins/crud/funcs/setOpt.js +1 -1
  14. package/dist/server/plugins/crud/funcs/setToken.d.ts +1 -1
  15. package/dist/server/plugins/crud/funcs/setToken.d.ts.map +1 -1
  16. package/dist/server/plugins/file/utils/inspectContent.d.ts.map +1 -1
  17. package/dist/server/plugins/file/utils/inspectContent.js +7 -0
  18. package/dist/server/plugins/table/funcs/getData.d.ts +32 -0
  19. package/dist/server/plugins/table/funcs/getData.d.ts.map +1 -0
  20. package/dist/server/plugins/table/funcs/getData.js +703 -0
  21. package/dist/server/plugins/table/funcs/getFilterSQLParametrized/index.d.ts +2 -1
  22. package/dist/server/plugins/table/funcs/getFilterSQLParametrized/index.d.ts.map +1 -1
  23. package/dist/server/plugins/table/funcs/getFilterSQLParametrized/index.js +2 -2
  24. package/dist/server/routes/crud/controllers/table.d.ts +1 -2
  25. package/dist/server/routes/crud/controllers/table.d.ts.map +1 -1
  26. package/dist/server/routes/crud/controllers/table.js +1 -1
  27. package/dist/server/routes/crud/crud.route.d.ts +3 -0
  28. package/dist/server/routes/crud/crud.route.d.ts.map +1 -0
  29. package/dist/server/routes/crud/crud.route.js +161 -0
  30. package/dist/server/routes/crud/crud.schema.d.ts +114 -0
  31. package/dist/server/routes/crud/crud.schema.d.ts.map +1 -0
  32. package/dist/server/routes/crud/crud.schema.js +64 -0
  33. package/dist/server/routes/crud/functions/createTableRelation.d.ts +13 -0
  34. package/dist/server/routes/crud/functions/createTableRelation.d.ts.map +1 -0
  35. package/dist/server/routes/crud/functions/createTableRelation.js +93 -0
  36. package/dist/server/routes/crud/functions/deleteTableRelation.d.ts +11 -0
  37. package/dist/server/routes/crud/functions/deleteTableRelation.d.ts.map +1 -0
  38. package/dist/server/routes/crud/functions/deleteTableRelation.js +74 -0
  39. package/dist/server/routes/crud/functions/readTableRelations.d.ts +25 -0
  40. package/dist/server/routes/crud/functions/readTableRelations.d.ts.map +1 -0
  41. package/dist/server/routes/crud/functions/readTableRelations.js +76 -0
  42. package/dist/server/routes/crud/functions/updateTableRelation.d.ts +14 -0
  43. package/dist/server/routes/crud/functions/updateTableRelation.d.ts.map +1 -0
  44. package/dist/server/routes/crud/functions/updateTableRelation.js +117 -0
  45. package/dist/server/routes/file/schema.js +6 -6
  46. package/dist/server/routes/table/functions/getData.d.ts +3 -2
  47. package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
  48. package/dist/server/routes/table/functions/getData.js +2 -14
  49. package/dist/server/routes/table/schema.d.ts +5 -4
  50. package/dist/server/routes/table/schema.d.ts.map +1 -1
  51. package/dist/server/routes/table/schema.js +13 -13
  52. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ // import config from "../../../../config.js";
2
+ import pgClients from "../../../plugins/pg/pgClients.js";
3
+ import getAccess from "../../../plugins/crud/funcs/getAccess.js";
4
+ import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
5
+ import getData from "../../../plugins/table/funcs/getData.js";
6
+ import { resourcesObject } from "../../../plugins/access/funcs/getResources.js";
7
+ import { BadRequestError, ForbiddenError, NotFoundError, } from "../../../../errors.js";
8
+ export default async function readTableRelations({ table: paramsTable, id, relname, relationId, uid, userType, referer, limit = 10, page = 1, called = false, }, pg = pgClients.client) {
9
+ if (!paramsTable) {
10
+ throw BadRequestError("not enough params: table ");
11
+ }
12
+ const resource = resourcesObject[paramsTable]?.table
13
+ ? paramsTable
14
+ : undefined;
15
+ const templateName = resourcesObject[paramsTable]?.table || paramsTable;
16
+ const loadTable = await getTemplate("table", templateName);
17
+ if (!loadTable && !(pg.pk?.[templateName] && called)) {
18
+ throw NotFoundError("table not found");
19
+ }
20
+ const { relations = {} } = loadTable || {};
21
+ if (!relations[relname]) {
22
+ throw NotFoundError("table relation not found");
23
+ }
24
+ const { table: relationTable, form: relationForm,
25
+ // localKey = relations[relname]?.localKey,
26
+ foreignKey = relations[relname]?.foreignKey, } = relations[relname]?.resource
27
+ ? resourcesObject[relations[relname].resource]
28
+ : relations[relname];
29
+ if (!foreignKey) {
30
+ throw new Error("invalid relation: foreignKey not set");
31
+ }
32
+ // check if user has permission to modify main object/row
33
+ const { actions = [], message: accessMessage } = (await getAccess({
34
+ resource,
35
+ table: templateName,
36
+ form: loadTable?.form,
37
+ id,
38
+ user: { uid, user_type: userType },
39
+ method: "GET",
40
+ }, pg)) || {};
41
+ if (accessMessage) {
42
+ throw ForbiddenError(accessMessage);
43
+ }
44
+ if (!actions.includes("edit") && !called) {
45
+ throw ForbiddenError("access restricted: actions");
46
+ }
47
+ const relationTableTemplate = await getTemplate("table", relationTable);
48
+ const formData = await getTemplate("form", relationTableTemplate?.form || relationForm);
49
+ const schema = formData?.schema || formData || {};
50
+ const { count, filtered, total, rows } = await getData({
51
+ table: relationTable,
52
+ id: relationId,
53
+ page: relationId ? undefined : page,
54
+ limit: relationId ? undefined : limit,
55
+ uid,
56
+ userType,
57
+ referer,
58
+ columns: Object.keys(schema).concat([foreignKey]),
59
+ contextQuery: `${foreignKey}=$1`,
60
+ args: [id],
61
+ called: true,
62
+ }, pg);
63
+ if (relationId) {
64
+ return { id: relationId, data: rows[0], schema };
65
+ }
66
+ const data = {
67
+ count,
68
+ filtered,
69
+ total,
70
+ limit,
71
+ page,
72
+ rows,
73
+ schema,
74
+ };
75
+ return data;
76
+ }
@@ -0,0 +1,14 @@
1
+ export default function updateTableRelation({ table: paramsTable, id: paramsId, form: paramsForm, relname, relationId, body, uid, userType, referer, ignoreCheck, called, }: {
2
+ table: string;
3
+ id: string;
4
+ form?: string;
5
+ relname: string;
6
+ relationId: string;
7
+ body: Record<string, any>;
8
+ uid?: string;
9
+ userType?: string;
10
+ referer?: string;
11
+ ignoreCheck?: boolean;
12
+ called?: boolean;
13
+ }, pg?: any): Promise<any>;
14
+ //# sourceMappingURL=updateTableRelation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateTableRelation.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/functions/updateTableRelation.ts"],"names":[],"mappings":"AAqBA,wBAA8B,mBAAmB,CAC/C,EACE,KAAK,EAAE,WAAW,EAClB,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,UAAU,EAChB,OAAO,EACP,UAAU,EACV,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,OAAO,EACP,WAAmB,EACnB,MAAc,GACf,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,EACD,EAAE,MAAmB,gBA+JtB"}
@@ -0,0 +1,117 @@
1
+ // import config from "../../../../config.js";
2
+ import pgClients from "../../../plugins/pg/pgClients.js";
3
+ import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
4
+ import dataUpdate from "../../../plugins/crud/funcs/dataUpdate.js";
5
+ import getAccess from "../../../plugins/crud/funcs/getAccess.js";
6
+ import checkXSS from "../../../plugins/policy/funcs/checkXSS.js";
7
+ import validateData from "../../../plugins/crud/funcs/validateData.js";
8
+ import logger from "../../../plugins/logger/getLogger.js";
9
+ import { resourcesObject } from "../../../plugins/access/funcs/getResources.js";
10
+ import { BadRequestError, ConflictError, ForbiddenError, NotFoundError, UnauthorizedError, } from "../../../../errors.js";
11
+ export default async function updateTableRelation({ table: paramsTable, id: paramsId, form: paramsForm, relname, relationId, body, uid, userType, referer, ignoreCheck = false, called = false, }, pg = pgClients.client) {
12
+ if (!uid) {
13
+ throw UnauthorizedError("unauthorized");
14
+ }
15
+ if (!relationId) {
16
+ throw BadRequestError("not enough params: relationId");
17
+ }
18
+ const resource = resourcesObject[paramsTable] ? paramsTable : undefined;
19
+ const mainTable = resourcesObject[paramsTable]?.table || paramsTable;
20
+ const id = paramsId;
21
+ const { actions = [], message: accessMessage } = (await getAccess({
22
+ resource,
23
+ table: mainTable,
24
+ form: resourcesObject[paramsTable]?.form || paramsForm,
25
+ id: paramsId,
26
+ user: { uid, user_type: userType },
27
+ method: "PUT",
28
+ }, pg)) || {};
29
+ if (accessMessage && !called) {
30
+ throw ForbiddenError(accessMessage);
31
+ }
32
+ if (!actions.includes("edit") && !called) {
33
+ throw ForbiddenError("access restricted: actions");
34
+ }
35
+ const loadTemplate = await getTemplate("table", mainTable);
36
+ if (!loadTemplate) {
37
+ throw NotFoundError(`table not found: ${mainTable}`);
38
+ }
39
+ const { relations = {} } = loadTemplate || {};
40
+ if (!relations[relname]) {
41
+ throw NotFoundError(`table relation not found: ${relname}`);
42
+ }
43
+ const { table: relationTable, form: relationForm,
44
+ // localKey = relations[relname]?.localKey,
45
+ foreignKey = relations[relname]?.foreignKey, } = relations[relname]?.resource
46
+ ? resourcesObject[relations[relname].resource]
47
+ : relations[relname];
48
+ if (!foreignKey) {
49
+ throw new Error("invalid relation: foreignKey not set");
50
+ }
51
+ const pks = await pg
52
+ .query(`
53
+ SELECT
54
+ connamespace::regnamespace::text,
55
+ conrelid::regclass,
56
+ (
57
+ SELECT attname FROM pg_attribute WHERE attrelid = c.conrelid AND attnum = c.conkey[1]
58
+ ) as pk
59
+ FROM pg_constraint c
60
+ WHERE contype = 'p'
61
+ AND connamespace::regnamespace::text NOT IN ('sde')`)
62
+ .then((r) => r.rows || []);
63
+ const pkList = pks.reduce((acc, curr) => ({
64
+ ...acc,
65
+ [curr.connamespace === "public"
66
+ ? `${curr.connamespace}.${curr.conrelid}`
67
+ : curr.conrelid]: curr.pk,
68
+ }), {});
69
+ const relationTableTemplate = await getTemplate("table", relationTable);
70
+ const relationPk = pkList[relationTableTemplate?.table || relationTable];
71
+ if (!relationPk) {
72
+ throw NotFoundError("invalid relation: primary key column not found");
73
+ }
74
+ const existsAndRelated = await pg
75
+ .query(`select 1 from ${relationTableTemplate?.table || relationTable} where ${foreignKey}=$1 and ${relationPk}=$2`, [paramsId, relationId])
76
+ .then((r) => r.rowCount > 0);
77
+ if (!existsAndRelated) {
78
+ throw NotFoundError(`relation row not found: ${relationId}`);
79
+ }
80
+ const formData = await getTemplate("form", relationTableTemplate?.form || relationForm);
81
+ const schema = formData?.schema || formData;
82
+ // skip non-present fields in form schema
83
+ if (!ignoreCheck) {
84
+ Object.keys(body || {})
85
+ .filter((key) => !Object.keys(schema || {}).includes(key))
86
+ .forEach((key) => delete body[key]);
87
+ }
88
+ const xssCheck = checkXSS({ body, schema });
89
+ if (xssCheck.error && formData?.xssCheck !== false) {
90
+ logger.file("injection/xss", {
91
+ msg: xssCheck.error,
92
+ table: relationTable,
93
+ form: relationForm,
94
+ uid,
95
+ });
96
+ throw ConflictError("Дані не пройшли валідацію. Приберіть некоректні дані та спробуйте ще раз");
97
+ }
98
+ const fieldCheck = validateData({ body, schema, update: true });
99
+ if (fieldCheck.error) {
100
+ logger.file("injection/formdata", {
101
+ table: relationTable,
102
+ form: relationForm,
103
+ uid,
104
+ ...fieldCheck,
105
+ });
106
+ throw ConflictError("Дані не пройшли валідацію. Приберіть некоректні дані та спробуйте ще раз");
107
+ }
108
+ const res = await dataUpdate({
109
+ pg,
110
+ table: relationTableTemplate?.table || relationTable,
111
+ id: relationId,
112
+ data: body,
113
+ uid,
114
+ referer,
115
+ });
116
+ return res;
117
+ }
@@ -3,13 +3,13 @@ const resizeSchema = {
3
3
  type: "object",
4
4
  properties: {
5
5
  filepath: { type: "string" },
6
- quality: { type: "number", exclusiveMinimum: 0, maximum: 100 },
6
+ quality: { type: "integer", exclusiveMinimum: 0, maximum: 100 },
7
7
  size: {
8
8
  type: "string",
9
9
  pattern: "^((\\d{1,4})x(\\d{1,4})|(\\d{1,4})x|x(\\d{1,4}))$",
10
10
  },
11
- w: { type: "number", minimum: 1, maximum: 2048 },
12
- h: { type: "number", minimum: 1, maximum: 2048 },
11
+ w: { type: "integer", minimum: 1, maximum: 2048 },
12
+ h: { type: "integer", minimum: 1, maximum: 2048 },
13
13
  },
14
14
  },
15
15
  };
@@ -17,9 +17,9 @@ const exportSchema = {
17
17
  querystring: {
18
18
  type: "object",
19
19
  properties: {
20
- limit: { type: "number", minimum: 1 },
21
- batchLimit: { type: "number", minimum: 1 },
22
- page: { type: "number", minimum: 1 },
20
+ limit: { type: "integer", minimum: 1 },
21
+ batchLimit: { type: "integer", minimum: 1 },
22
+ page: { type: "integer", minimum: 1 },
23
23
  key: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
24
24
  },
25
25
  },
@@ -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, searchColumn, sufix, filterList, actions: actionsParam, accessQuery: accessQueryParam, columns: columnsParam, isExport, }: {
3
+ export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, searchColumn, sufix, filterList, actions: actionsParam, accessQuery: accessQueryParam, columns: columnsParam, isExport, called: isCalled, }: {
4
4
  pg?: ExtendedPG;
5
5
  params?: {
6
6
  id?: string;
@@ -20,5 +20,6 @@ export default function dataAPI({ pg, params, table, id, headers, query, user, c
20
20
  accessQuery?: string;
21
21
  columns?: string[];
22
22
  isExport?: boolean;
23
- }, reply?: FastifyReply, called?: any): Promise<any>;
23
+ called?: boolean;
24
+ }, _?: FastifyReply, called1?: any): Promise<any>;
24
25
  //# 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;AAuGzD,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,KAAK,CAAC,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,GAAG,gBAk5Bb"}
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;AAuFzD,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,EAChB,MAAM,EAAE,QAAQ,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;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,EACD,CAAC,CAAC,EAAE,YAAY,EAChB,OAAO,CAAC,EAAE,GAAG,gBAo5Bd"}
@@ -25,19 +25,6 @@ const components = {
25
25
  "vs-widget-file": "select 'vs-widget-file' as component, count(*) from crm.files where entity_id=$1 and file_status<>3",
26
26
  "vs-widget-comments": "select 'vs-widget-comments' as component, count(*) from crm.communications where entity_id=$1",
27
27
  };
28
- const mockReply = {
29
- response: {},
30
- // redirect: (txt) => txt,
31
- redirect: (txt) => Object.assign(mockReply.response, {
32
- body: txt,
33
- statusCode: mockReply.response.statusCode || 200,
34
- }),
35
- status: (statusCode) => {
36
- Object.assign(mockReply.response, { status: statusCode });
37
- return mockReply;
38
- },
39
- send: (txt) => Object.assign(mockReply.response, txt),
40
- };
41
28
  function getOrder({ queryOrder, queryDesc, defaultOrder, columnList, cols, sqlColumns, iscalled = false, }) {
42
29
  if (iscalled && queryOrder) {
43
30
  return `order by ${queryOrder}`;
@@ -59,7 +46,8 @@ function getOrder({ queryOrder, queryDesc, defaultOrder, columnList, cols, sqlCo
59
46
  const checkInline = {};
60
47
  const maxLimit = 100;
61
48
  const defaultLimit = 20;
62
- export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, searchColumn, sufix = true, filterList, actions: actionsParam, accessQuery: accessQueryParam, columns: columnsParam, isExport = false, }, reply, called) {
49
+ export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, searchColumn, sufix = true, filterList, actions: actionsParam, accessQuery: accessQueryParam, columns: columnsParam, isExport = false, called: isCalled, }, _, called1) {
50
+ const called = called1 || isCalled;
63
51
  const time = Date.now();
64
52
  const timeArr = [Date.now()];
65
53
  const { uid } = user;
@@ -134,7 +134,7 @@ declare const searchSchema: {
134
134
  };
135
135
  sql: {
136
136
  type: string;
137
- pattern: string;
137
+ enum: number[];
138
138
  };
139
139
  };
140
140
  };
@@ -170,14 +170,15 @@ declare const suggestSchema: {
170
170
  };
171
171
  sql: {
172
172
  type: string;
173
+ enum: number[];
173
174
  };
174
175
  count: {
175
176
  type: string;
177
+ enum: number[];
176
178
  };
177
179
  json: {
178
180
  type: string;
179
- minimum: number;
180
- maximum: number;
181
+ enum: number[];
181
182
  };
182
183
  };
183
184
  };
@@ -223,7 +224,7 @@ declare const cardTabDataSchema: {
223
224
  properties: {
224
225
  sql: {
225
226
  type: string;
226
- pattern: string;
227
+ enum: number[];
227
228
  };
228
229
  };
229
230
  };
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/schema.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBpB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhB,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAajB,CAAC;AAEF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBlB,CAAC;AAEF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;CAQf,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;CAOjB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAatB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;CAQtB,CAAC;AAEF,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,iBAAiB,GAClB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/schema.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBpB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhB,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAajB,CAAC;AAEF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBlB,CAAC;AAEF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;CAQf,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;CAOjB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAatB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;CAQtB,CAAC;AAEF,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,iBAAiB,GAClB,CAAC"}
@@ -2,8 +2,8 @@ const tableDataSchema = {
2
2
  type: "object",
3
3
  properties: {
4
4
  querystring: {
5
- limit: { type: "number", minimum: 1 },
6
- page: { type: "number", minimum: 1 },
5
+ limit: { type: "integer", minimum: 1 },
6
+ page: { type: "integer", minimum: 1 },
7
7
  // filter: { type: 'string', pattern: '^([\\w\\d_-]+)=([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
8
8
  // search: { type: 'string', pattern: '^([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
9
9
  order: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
@@ -13,7 +13,7 @@ const tableDataSchema = {
13
13
  bbox: { type: "string", pattern: "^([\\d\\s,.-]+)$" },
14
14
  polyline: { type: "string", pattern: "^([\\d\\w|@{}~_`]+)$" },
15
15
  // key: { type: 'string', pattern: '^([\\d\\w_]+)$' },
16
- sql: { type: "number" },
16
+ sql: { type: "integer" },
17
17
  },
18
18
  },
19
19
  params: {
@@ -28,8 +28,8 @@ const tableSchema = {
28
28
  querystring: {
29
29
  type: "object",
30
30
  properties: {
31
- limit: { type: "number", minimum: 1 },
32
- page: { type: "number", minimum: 1 },
31
+ limit: { type: "integer", minimum: 1 },
32
+ page: { type: "integer", minimum: 1 },
33
33
  // filter: { type: 'string', pattern: '^([\\w\\d_-]+)=([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
34
34
  // search: { type: 'string', pattern: '^([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
35
35
  order: { type: "string", pattern: "^$|^[\\d\\w_.-]+$" },
@@ -40,7 +40,7 @@ const tableSchema = {
40
40
  // polyline: { type: 'string', pattern: '^([\\d\\w\\|@\\/\\{\\}~_`]+)$' },
41
41
  key: { type: "string", pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_.-]+)$" },
42
42
  uid: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
43
- sql: { type: "number" },
43
+ sql: { type: "integer" },
44
44
  },
45
45
  },
46
46
  params: {
@@ -55,13 +55,13 @@ const searchSchema = {
55
55
  querystring: {
56
56
  type: "object",
57
57
  properties: {
58
- page: { type: "number", minimum: 1 },
59
- limit: { type: "number", minimum: 1 },
58
+ page: { type: "integer", minimum: 1 },
59
+ limit: { type: "integer", minimum: 1 },
60
60
  order: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
61
61
  desc: { type: "string", pattern: "^(\\d+)$" },
62
62
  key: { type: "string", pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_.-]+)$" },
63
63
  table: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
64
- sql: { type: "string", pattern: "^(\\d)$" },
64
+ sql: { type: "integer", enum: [1] },
65
65
  },
66
66
  },
67
67
  };
@@ -76,9 +76,9 @@ const suggestSchema = {
76
76
  name: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
77
77
  key: { type: "string", pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_.-]+)$" },
78
78
  val: { type: "string", pattern: "([\\d\\w]+)$" },
79
- sql: { type: "number" },
80
- count: { type: "number" },
81
- json: { type: "number", minimum: 1, maximum: 1 }, // dummy schema param to avoid crash caused by frontend calls w/ useless json param
79
+ sql: { type: "integer", enum: [1] },
80
+ count: { type: "integer", enum: [1] },
81
+ json: { type: "integer", enum: [1] }, // dummy schema param to avoid crash caused by frontend calls w/ useless json param
82
82
  },
83
83
  },
84
84
  params: {
@@ -109,7 +109,7 @@ const cardTabDataSchema = {
109
109
  querystring: {
110
110
  type: "object",
111
111
  properties: {
112
- sql: { type: "string", pattern: "^(\\d)$" },
112
+ sql: { type: "integer", enum: [1] },
113
113
  },
114
114
  },
115
115
  params: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.5.42",
3
+ "version": "2.5.44",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [