@opengis/fastify-table 2.5.31 → 2.5.33
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/policy/funcs/checkPolicy.js +1 -1
- package/dist/server/plugins/policy/index.js +1 -1
- package/dist/server/plugins/table/funcs/getFilterSQLParametrized/formatValue.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getFilterSQLParametrized/formatValue.js +48 -1
- package/dist/server/routes/access/schema.d.ts +40 -0
- package/dist/server/routes/access/schema.d.ts.map +1 -1
- package/dist/server/routes/access/schema.js +38 -30
- package/dist/server/routes/table/schema.d.ts +5 -0
- package/dist/server/routes/table/schema.d.ts.map +1 -1
- package/dist/server/routes/table/schema.js +1 -0
- package/package.json +1 -1
|
@@ -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:
|
|
48
|
+
throw ForbiddenError("access restricted: role");
|
|
49
49
|
}
|
|
50
50
|
// ! invalid file extension
|
|
51
51
|
if (path.includes("files/") && allowExtPublic.includes(ext)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatValue.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/table/funcs/getFilterSQLParametrized/formatValue.ts"],"names":[],"mappings":"
|
|
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 =
|
|
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
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
},
|
|
@@ -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
|
|
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"}
|
|
@@ -78,6 +78,7 @@ const suggestSchema = {
|
|
|
78
78
|
val: { type: "string", pattern: "([\\d\\w]+)$" },
|
|
79
79
|
sql: { type: "number" },
|
|
80
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
|
|
81
82
|
},
|
|
82
83
|
},
|
|
83
84
|
params: {
|