@opengis/fastify-table 2.5.31 → 2.5.32

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.
@@ -45,7 +45,7 @@ export default function checkPolicy(req, jwt) {
45
45
  body,
46
46
  uid: user?.uid,
47
47
  });
48
- throw ForbiddenError("access restricted: 0");
48
+ throw ForbiddenError("access restricted: role");
49
49
  }
50
50
  // ! invalid file extension
51
51
  if (path.includes("files/") && allowExtPublic.includes(ext)) {
@@ -29,7 +29,7 @@ function plugin(fastify) {
29
29
  if (!isApi) {
30
30
  return null;
31
31
  }
32
- if (request.query?.sql) {
32
+ if (request.query?.sql && process.platform !== "win32") {
33
33
  logger.file("alert", {
34
34
  message: "database structure disclosure attempt",
35
35
  url: request.url,
@@ -1 +1 @@
1
- {"version":3,"file":"formatValue.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/table/funcs/getFilterSQLParametrized/formatValue.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,EACE,KAAK,EACL,MAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,GAAS,EACT,QAAQ,EACR,IAAI,EAAE,UAAU,GACjB,EAAE,GAAG,EACN,EAAE,MAAmB,OAyPtB"}
1
+ {"version":3,"file":"formatValue.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/table/funcs/getFilterSQLParametrized/formatValue.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,EACE,KAAK,EACL,MAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,GAAS,EACT,QAAQ,EACR,IAAI,EAAE,UAAU,GACjB,EAAE,GAAG,EACN,EAAE,MAAmB,OAkTtB"}
@@ -10,6 +10,10 @@ const selectFilterTypes = [
10
10
  "select",
11
11
  "button",
12
12
  ];
13
+ const matchNullObj = {
14
+ null: "is null",
15
+ notnull: "is not null",
16
+ };
13
17
  export default function formatValue({ table, filter = {}, name, value, dataTypeID, uid = "1", optimize, args: argsParams, }, pg = pgClients.client) {
14
18
  const { extra, sql, select, strict, options, optionsFromColumns } = filter;
15
19
  const pk = pg?.pk && table ? pg.pk[table] : undefined;
@@ -57,7 +61,22 @@ export default function formatValue({ table, filter = {}, name, value, dataTypeI
57
61
  args.push(uid);
58
62
  return { op: "=", query: `${name}::text = $${args.length}`, values: [uid] };
59
63
  }
60
- const matchNull = { null: "is null", notnull: "is not null" }[value];
64
+ const matchNull = matchNullObj[value];
65
+ const includesNull = !matchNull &&
66
+ value &&
67
+ value.includes(",") &&
68
+ (value.startsWith("null") ||
69
+ value.includes(",null") ||
70
+ value.startsWith("notnull") ||
71
+ value.includes(",notnull"));
72
+ const includesNull1 = includesNull
73
+ ? value
74
+ .split(",")
75
+ .map((el) => matchNullObj[el])
76
+ .filter(Boolean)
77
+ : undefined;
78
+ // skip if requested both: is null and not null
79
+ const includesNullQuery = includesNull1 && includesNull1.length > 1 ? undefined : includesNull1?.[0];
61
80
  // geometry
62
81
  if (["geometry"].includes(fieldType || "")) {
63
82
  if (matchNull) {
@@ -111,6 +130,34 @@ export default function formatValue({ table, filter = {}, name, value, dataTypeI
111
130
  const query = `${name} IS ${value === "true" ? "TRUE" : "FALSE"}`;
112
131
  return { op, query };
113
132
  }
133
+ // boolean + nullable
134
+ const value1 = ["true", "false"].find((el) => value.includes(el));
135
+ const values = ["true", "false"].filter((el) => value.includes(el));
136
+ // boolean: both true and false => not null
137
+ if (fieldType === "boolean" && values.length === 2) {
138
+ return { op, query: "is not null" };
139
+ }
140
+ // boolean: not null over any value
141
+ if (fieldType === "boolean" &&
142
+ value1 &&
143
+ includesNullQuery === "is not null") {
144
+ const query = `${name} ${includesNullQuery}`;
145
+ return { op, query };
146
+ }
147
+ // boolean: true or null
148
+ if (fieldType === "boolean" &&
149
+ value1 &&
150
+ includesNullQuery === "is null" &&
151
+ value1 === "true") {
152
+ return { op, query: `${name} IS NOT FALSE` };
153
+ }
154
+ // boolean: false or null
155
+ if (fieldType === "boolean" &&
156
+ value1 &&
157
+ includesNullQuery === "is null" &&
158
+ value1 === "false") {
159
+ return { op, query: `${name} IS NOT TRUE` };
160
+ }
114
161
  // select / cls - any filter type w/ out sql subquery
115
162
  if (value &&
116
163
  select &&
@@ -65,6 +65,26 @@ declare const accessGroupPostSchema: {
65
65
  };
66
66
  routes: {
67
67
  type: string;
68
+ items: {
69
+ type: string;
70
+ properties: {
71
+ path: {
72
+ type: string;
73
+ pattern: string;
74
+ };
75
+ resource: {
76
+ type: string;
77
+ pattern: string;
78
+ };
79
+ actions: {
80
+ type: string;
81
+ items: {
82
+ type: string;
83
+ enum: string[];
84
+ };
85
+ };
86
+ };
87
+ };
68
88
  };
69
89
  };
70
90
  };
@@ -97,6 +117,26 @@ declare const accessUserPostSchema: {
97
117
  };
98
118
  routes: {
99
119
  type: string;
120
+ items: {
121
+ type: string;
122
+ properties: {
123
+ path: {
124
+ type: string;
125
+ pattern: string;
126
+ };
127
+ resource: {
128
+ type: string;
129
+ pattern: string;
130
+ };
131
+ actions: {
132
+ type: string;
133
+ items: {
134
+ type: string;
135
+ enum: string[];
136
+ };
137
+ };
138
+ };
139
+ };
100
140
  };
101
141
  };
102
142
  };
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/schema.ts"],"names":[],"mappings":";AAAA,wBAAoB;AAEpB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;CAQtB,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;;;;;;;;CAQrB,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;CAQ1B,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4C1B,CAAC;AAEF,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CzB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/schema.ts"],"names":[],"mappings":";AAAA,wBAAoB;AAEpB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;CAQtB,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;;;;;;;;CAQrB,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;CAQ1B,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgD1B,CAAC;AAEF,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDzB,CAAC"}
@@ -52,22 +52,26 @@ const accessGroupPostSchema = {
52
52
  },
53
53
  routes: {
54
54
  type: "array",
55
- /*items: {
56
- type: 'object',
57
- properties: {
58
- path: {
59
- type: 'string',
60
- pattern: '^([\\d\\w._-]+)$',
61
- },
62
- actions: {
63
- type: 'array',
64
- items: {
65
- type: 'string',
66
- enum: ['get', 'add', 'edit', 'del'],
67
- },
68
- },
55
+ items: {
56
+ type: "object",
57
+ properties: {
58
+ path: {
59
+ type: "string",
60
+ pattern: "^([\\d\\w._-]+)$",
61
+ },
62
+ resource: {
63
+ type: "string",
64
+ pattern: "^([\\d\\w._-]+)$",
65
+ },
66
+ actions: {
67
+ type: "array",
68
+ items: {
69
+ type: "string",
70
+ enum: ["read", "create", "update", "delete"],
69
71
  },
70
- },*/
72
+ },
73
+ },
74
+ },
71
75
  },
72
76
  },
73
77
  },
@@ -97,22 +101,26 @@ const accessUserPostSchema = {
97
101
  },
98
102
  routes: {
99
103
  type: "array",
100
- /*items: {
101
- type: 'object',
102
- properties: {
103
- path: {
104
- type: 'string',
105
- pattern: '^([\\d\\w._-]+)$',
106
- },
107
- actions: {
108
- type: 'array',
109
- items: {
110
- type: 'string',
111
- enum: ['get', 'add', 'edit', 'del'],
112
- },
113
- },
104
+ items: {
105
+ type: "object",
106
+ properties: {
107
+ path: {
108
+ type: "string",
109
+ pattern: "^([\\d\\w._-]+)$",
110
+ },
111
+ resource: {
112
+ type: "string",
113
+ pattern: "^([\\d\\w._-]+)$",
114
+ },
115
+ actions: {
116
+ type: "array",
117
+ items: {
118
+ type: "string",
119
+ enum: ["read", "create", "update", "delete"],
114
120
  },
115
- },*/
121
+ },
122
+ },
123
+ },
116
124
  },
117
125
  },
118
126
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.5.31",
3
+ "version": "2.5.32",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [