@opengis/fastify-table 2.5.68 → 2.5.70
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/index.d.ts.map +1 -1
- package/dist/index.js +18 -6
- package/dist/module/core/select/core.user_mentioned.json +3 -0
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.js +1 -0
- package/dist/server/routes/table/controllers/suggest.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/suggest.js +11 -6
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAgGA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAgGA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,iBAiQjC;;AACD,wBAEG"}
|
package/dist/index.js
CHANGED
|
@@ -175,12 +175,24 @@ async function plugin(fastify) {
|
|
|
175
175
|
fastify.register(dblistRoutes, opt);
|
|
176
176
|
}
|
|
177
177
|
fastify.addHook("preValidation", async (request) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
.
|
|
178
|
+
if (request.method === "PUT") {
|
|
179
|
+
// if put request => "" => null === update x=null
|
|
180
|
+
Object.keys(request.query || {})
|
|
181
|
+
.filter((key) => request.query[key] === "")
|
|
182
|
+
.forEach((key) => Object.assign(request.query, { [key]: null }));
|
|
183
|
+
Object.keys(request.body || {})
|
|
184
|
+
.filter((key) => request.body[key] === "")
|
|
185
|
+
.forEach((key) => Object.assign(request.body, { [key]: null }));
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// if post request => "" => delete
|
|
189
|
+
Object.keys(request.query || {})
|
|
190
|
+
.filter((key) => request.query[key] === "")
|
|
191
|
+
.forEach((key) => delete request.query[key]);
|
|
192
|
+
Object.keys(request.body || {})
|
|
193
|
+
.filter((key) => request.body[key] === "")
|
|
194
|
+
.forEach((key) => delete request.body[key]);
|
|
195
|
+
}
|
|
184
196
|
});
|
|
185
197
|
fastify.addHook("preHandler", async (request, reply) => {
|
|
186
198
|
const q = request.query;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,
|
|
1
|
+
{"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,gBAoIA"}
|
|
@@ -94,6 +94,7 @@ export default async function getSelectMeta({ name, startsWith, key, nocache, pa
|
|
|
94
94
|
searchQuery,
|
|
95
95
|
table: tableNew.join(","),
|
|
96
96
|
time: new Date().toISOString(),
|
|
97
|
+
access: cls.public === false ? "user" : "public",
|
|
97
98
|
};
|
|
98
99
|
selectMeta[name] = data;
|
|
99
100
|
// on demand - search by "start with these characters"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAgCpD,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,GAAG,EACH,EAAqB,GACtB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB;;;;;;UAyGA;AAED,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBAqe7C"}
|
|
@@ -131,12 +131,11 @@ export default async function suggest(req) {
|
|
|
131
131
|
const table2 = table1 || query.token;
|
|
132
132
|
const table = resources[table2] || table2;
|
|
133
133
|
const column = column1 || query.column;
|
|
134
|
-
const { body: hookBody } =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
: {};
|
|
134
|
+
const { body: hookBody } = (await applyHook("preSuggest", {
|
|
135
|
+
pg: pg1,
|
|
136
|
+
table, // old hook support
|
|
137
|
+
data: params.data, // in case of need for additional security checks
|
|
138
|
+
})) || {};
|
|
140
139
|
if (params.data === "list" &&
|
|
141
140
|
(user?.user_type === "admin" || process.platform === "win32")) {
|
|
142
141
|
const cls = await getTemplate("cls", "list");
|
|
@@ -154,6 +153,9 @@ export default async function suggest(req) {
|
|
|
154
153
|
};
|
|
155
154
|
}
|
|
156
155
|
const body = await getTemplate("table", table);
|
|
156
|
+
if (body && !user?.uid && body.public !== true) {
|
|
157
|
+
throw ForbiddenError("authorization required");
|
|
158
|
+
}
|
|
157
159
|
if (table && !hookBody?.table && !body?.table) {
|
|
158
160
|
throw ForbiddenError("invalid params: table");
|
|
159
161
|
}
|
|
@@ -185,6 +187,9 @@ export default async function suggest(req) {
|
|
|
185
187
|
lang: query.lang,
|
|
186
188
|
parent,
|
|
187
189
|
});
|
|
190
|
+
if (meta?.access === "user" && !user?.uid) {
|
|
191
|
+
throw ForbiddenError("authorization required");
|
|
192
|
+
}
|
|
188
193
|
if (meta?.minLength && query.key && query.key.length < meta?.minLength) {
|
|
189
194
|
throw BadRequestError(`min length: ${meta.minLength}`);
|
|
190
195
|
}
|