@opengis/fastify-table 2.4.19 → 2.5.1
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/migrations/users.sql +11 -1
- package/dist/server/plugins/auth/index.d.ts.map +1 -1
- package/dist/server/plugins/auth/index.js +5 -0
- package/dist/server/plugins/crud/funcs/utils/logChanges.d.ts.map +1 -1
- package/dist/server/plugins/crud/funcs/utils/logChanges.js +5 -2
- package/dist/server/plugins/file/uploadMultiPart.d.ts.map +1 -1
- package/dist/server/plugins/file/uploadMultiPart.js +3 -1
- package/dist/server/plugins/logger/createFileStream.d.ts +1 -1
- package/dist/server/plugins/logger/createFileStream.d.ts.map +1 -1
- package/dist/server/plugins/pg/funcs/getMeta.js +2 -2
- package/dist/server/plugins/policy/funcs/checkPolicy.d.ts.map +1 -1
- package/dist/server/plugins/policy/funcs/checkPolicy.js +4 -1
- package/dist/server/plugins/sqlite/funcs/getSqlite.d.ts.map +1 -1
- package/dist/server/plugins/sqlite/funcs/getSqlite.js +9 -6
- package/dist/server/plugins/sqlite/sqliteClients.d.ts.map +1 -1
- package/dist/server/plugins/sqlite/sqliteClients.js +10 -9
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.js +10 -5
- package/dist/server/plugins/table/funcs/getTemplate.js +2 -2
- package/dist/server/plugins/table/funcs/getTemplateSync.js +2 -2
- package/dist/server/plugins/util/funcs/eventStream.d.ts +1 -4
- package/dist/server/plugins/util/funcs/eventStream.d.ts.map +1 -1
- package/dist/server/routes/access/schema.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/euSign/authByData.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/euSign/authByData.js +1 -1
- package/dist/server/routes/file/controllers/export.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/export.js +5 -3
- package/dist/server/routes/file/controllers/resizeAll.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/resizeAll.js +4 -3
- package/dist/server/routes/file/index.d.ts.map +1 -1
- package/dist/server/routes/file/index.js +20 -5
- package/dist/server/routes/file/schema.d.ts +27 -4
- package/dist/server/routes/file/schema.d.ts.map +1 -1
- package/dist/server/routes/file/schema.js +23 -9
- package/dist/server/routes/table/controllers/search.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/search.js +19 -11
- package/dist/server/routes/table/controllers/suggest.js +1 -1
- package/dist/server/routes/table/functions/getData.d.ts +1 -1
- package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
- package/dist/server/routes/table/functions/getData.js +80 -46
- package/dist/server/routes/table/index.js +2 -1
- package/dist/server/routes/table/schema.d.ts +6 -10
- package/dist/server/routes/table/schema.d.ts.map +1 -1
- package/dist/server/routes/table/schema.js +50 -50
- package/dist/server/routes/templates/index.d.ts.map +1 -1
- package/dist/server/routes/templates/index.js +7 -1
- package/dist/server/routes/templates/schema.d.ts +3 -3
- package/dist/server/routes/templates/schema.d.ts.map +1 -1
- package/dist/server/routes/templates/schema.js +4 -4
- package/dist/server/types/core.d.ts.map +1 -1
- package/dist/server/types/core.js +0 -4
- package/package.json +98 -98
|
@@ -54,13 +54,11 @@ function getOrder(queryOrder, queryDesc, defaultOrder, columnList, sqlColumns, i
|
|
|
54
54
|
const checkInline = {};
|
|
55
55
|
const maxLimit = 100;
|
|
56
56
|
const defaultLimit = 20;
|
|
57
|
-
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, },
|
|
57
|
+
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) {
|
|
58
58
|
const time = Date.now();
|
|
59
59
|
const timeArr = [Date.now()];
|
|
60
60
|
const { uid } = user;
|
|
61
|
-
const reply = reply1 || mockReply;
|
|
62
61
|
const method = "GET";
|
|
63
|
-
const checkQuery = (item) => user?.user_type === "superadmin" ? !item.includes("{{uid}}") : true;
|
|
64
62
|
const paramsTable = params?.table || table;
|
|
65
63
|
if (!paramsTable) {
|
|
66
64
|
throw BadRequestError("not enough params: table");
|
|
@@ -210,14 +208,14 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
210
208
|
!el.inline &&
|
|
211
209
|
el?.sql?.replace &&
|
|
212
210
|
!(isExport && el.export === false))
|
|
213
|
-
.map((el, i) => ` left join lateral (${el.sql.replace("{{uid}}", uid)}) ${el.name || `t${i}`} on 1=1 `)
|
|
211
|
+
.map((el, i) => ` left join lateral (${el.sql.replace("{{uid}}", `$${idx.uid}`)}) ${el.name || `t${i}`} on 1=1 `)
|
|
214
212
|
?.join("") || "";
|
|
215
213
|
const cardSqlFiltered = objectId
|
|
216
214
|
? cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) || []
|
|
217
215
|
: [];
|
|
218
216
|
const cardSqlTable = cardSqlFiltered.length
|
|
219
217
|
? cardSqlFiltered
|
|
220
|
-
.map((el, i) => ` left join lateral (${el.sql.replace("{{uid}}", uid)}) ct${i} on 1=1 `)
|
|
218
|
+
.map((el, i) => ` left join lateral (${el.sql.replace("{{uid}}", `$${idx.uid}`)}) ct${i} on 1=1 `)
|
|
221
219
|
.join("\n") || ""
|
|
222
220
|
: "";
|
|
223
221
|
const sqlInline = loadTable?.sql
|
|
@@ -277,21 +275,40 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
277
275
|
const keyQuery = query?.key && (loadTable?.key || tokenData?.key) && !objectId
|
|
278
276
|
? `${loadTable?.key || tokenData?.key}=$1`
|
|
279
277
|
: null;
|
|
278
|
+
const idx = {};
|
|
279
|
+
const args = (objectId ? [objectId] : null) ||
|
|
280
|
+
(query?.key && loadTable.key ? [query.key] : []);
|
|
281
|
+
if (args[0]) {
|
|
282
|
+
Object.assign(idx, { id: 1 });
|
|
283
|
+
}
|
|
284
|
+
const isSingle = !!idx.id;
|
|
280
285
|
const limit = (called
|
|
281
286
|
? query?.limit || defaultLimit
|
|
282
287
|
: Math.min(maxLimit, +(query?.limit || defaultLimit))) || defaultLimit;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
288
|
+
args.push(limit);
|
|
289
|
+
Object.assign(idx, { limit: idx.id ? 2 : 1 });
|
|
290
|
+
const offset = query?.page && query?.page > 0 && !objectId ? (query?.page - 1) * limit : 0;
|
|
291
|
+
args.push(offset);
|
|
292
|
+
Object.assign(idx, { offset: idx.id ? 3 : 2 });
|
|
286
293
|
const order = getOrder(query?.order, query?.desc, loadTable?.order, columnList, loadTable?.sqlColumns, !!called);
|
|
294
|
+
const isSearchable = Array.isArray(loadTable?.meta?.search) &&
|
|
295
|
+
loadTable.meta.search.length &&
|
|
296
|
+
query?.search &&
|
|
297
|
+
!isSingle;
|
|
298
|
+
if (isSearchable) {
|
|
299
|
+
args.push(`%${query.search.replace(/%/g, "\\%")}%`);
|
|
300
|
+
Object.assign(idx, { search: Object.keys(idx).length + 1 });
|
|
301
|
+
}
|
|
302
|
+
if (meta?.bbox && query?.polyline) {
|
|
303
|
+
args.push(query.polyline);
|
|
304
|
+
Object.assign(idx, { polyline: Object.keys(idx).length + 1 });
|
|
305
|
+
}
|
|
287
306
|
if (config.trace)
|
|
288
307
|
console.log(order);
|
|
289
|
-
const search =
|
|
308
|
+
const search = isSearchable
|
|
290
309
|
? `(${loadTable?.meta?.search
|
|
291
310
|
?.split(",")
|
|
292
|
-
?.map((el) => `${el} ilike
|
|
293
|
-
.replace(/%/g, "\\%")
|
|
294
|
-
.replace(/'/g, "''")}%'`)
|
|
311
|
+
?.map((el) => `${el} ilike $${idx.search}`)
|
|
295
312
|
.join(" or ")})`
|
|
296
313
|
: null;
|
|
297
314
|
const queryBbox = query?.bbox
|
|
@@ -301,7 +318,7 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
301
318
|
?.map((el) => el - 0)
|
|
302
319
|
: [];
|
|
303
320
|
const queryPolyline = meta?.bbox && query?.polyline
|
|
304
|
-
? `ST_Contains(ST_MakePolygon(ST_LineFromEncodedPolyline(
|
|
321
|
+
? `ST_Contains(ST_MakePolygon(ST_LineFromEncodedPolyline($${idx.polyline})),${meta.bbox})`
|
|
305
322
|
: undefined;
|
|
306
323
|
const bbox = meta?.bbox && queryBbox.filter((el) => !Number.isNaN(el))?.length === 4
|
|
307
324
|
? `${meta.bbox} && 'box(${queryBbox[0]} ${queryBbox[1]},${queryBbox[2]} ${queryBbox[3]})'::box2d `
|
|
@@ -318,7 +335,7 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
318
335
|
? await handlebars.compile(params?.query)({ user, uid })
|
|
319
336
|
: undefined;
|
|
320
337
|
const where = [
|
|
321
|
-
objectId ? ` "${pk}" =
|
|
338
|
+
objectId ? ` "${pk}" = $${idx.id}` : null,
|
|
322
339
|
keyQuery,
|
|
323
340
|
loadTable?.query,
|
|
324
341
|
tokenData?.query,
|
|
@@ -330,40 +347,36 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
330
347
|
queryPolyline,
|
|
331
348
|
interfaceQuery,
|
|
332
349
|
interfaceQuery1,
|
|
333
|
-
]
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
: columnsParam || sqlColumns || cols || "*"}
|
|
340
|
-
${metaCols}
|
|
341
|
-
${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry").length && !columnsParam
|
|
350
|
+
].filter(Boolean);
|
|
351
|
+
const q1 = `select ${pk ? `"${pk}" as id,` : ""}
|
|
352
|
+
${objectId || query?.key ? "*" : columnsParam || sqlColumns || cols || "*"}
|
|
353
|
+
${metaCols}
|
|
354
|
+
${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry")
|
|
355
|
+
.length && !columnsParam
|
|
342
356
|
? `,${dbColumns
|
|
343
357
|
.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry")
|
|
344
358
|
.map((el) => `st_asgeojson("${el.name.replace(/'/g, "''")}")::json as "${el.name.replace(/'/g, "''")}"`)
|
|
345
359
|
.join(",")}`
|
|
346
360
|
: ""}
|
|
347
|
-
|
|
361
|
+
from (select * ${sql
|
|
348
362
|
?.filter((el) => el.inline && !(isExport && el.export === false))
|
|
349
363
|
.map((el) => `,(${el.sql})`)
|
|
350
364
|
.join("") || ""} from ${viewSql ? `(${viewSql})` : table1} t ${sqlTable} ) t
|
|
351
365
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
366
|
+
${objectId ? cardSqlTable : ""}
|
|
367
|
+
where ${where.join(" and ") || "true"}
|
|
368
|
+
${order} limit $${idx.limit} offset $${idx.offset}`;
|
|
369
|
+
if (q1.includes("{{uid}}")) {
|
|
370
|
+
args.push(uid || "");
|
|
371
|
+
Object.assign(idx, { uid: Object.keys(idx).length + 1 });
|
|
372
|
+
}
|
|
373
|
+
const q = q1.replace(/{{uid}}/g, `$${idx.uid}`);
|
|
355
374
|
if (config.trace)
|
|
356
375
|
console.log(q);
|
|
357
376
|
if (query?.sql === "1") {
|
|
358
377
|
return q;
|
|
359
378
|
}
|
|
360
|
-
const
|
|
361
|
-
.query(q, (objectId ? [objectId] : null) ||
|
|
362
|
-
(query?.key && loadTable.key ? [query?.key] : []))
|
|
363
|
-
.catch((err) => {
|
|
364
|
-
console.error(err.toString());
|
|
365
|
-
throw err;
|
|
366
|
-
});
|
|
379
|
+
const rows = await pg.query(q, args).then((r) => r.rows || []);
|
|
367
380
|
if (!rows.length &&
|
|
368
381
|
headers?.referer?.includes?.("/card/") &&
|
|
369
382
|
headers?.referer?.includes?.(templateName)) {
|
|
@@ -395,17 +408,38 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
395
408
|
});
|
|
396
409
|
});
|
|
397
410
|
}
|
|
411
|
+
const idx1 = {};
|
|
412
|
+
const args1 = [];
|
|
413
|
+
if (idx.search) {
|
|
414
|
+
args1.push(args[idx.search - 1]);
|
|
415
|
+
Object.assign(idx1, { search: Object.keys(idx1).length + 1 });
|
|
416
|
+
}
|
|
417
|
+
if (idx.uid) {
|
|
418
|
+
args1.push(args[idx.uid - 1]);
|
|
419
|
+
Object.assign(idx1, { uid: Object.keys(idx1).length + 1 });
|
|
420
|
+
}
|
|
421
|
+
if (idx.polyline) {
|
|
422
|
+
args1.push(args[idx.polyline - 1]);
|
|
423
|
+
Object.assign(idx1, { polyline: Object.keys(idx1).length + 1 });
|
|
424
|
+
}
|
|
425
|
+
const search1 = idx.search
|
|
426
|
+
? `(${loadTable.meta.search
|
|
427
|
+
.split(",")
|
|
428
|
+
.map((el) => `${el} ilike $${idx1.search}`)
|
|
429
|
+
.join(" or ")})`
|
|
430
|
+
: null;
|
|
431
|
+
const queryPolyline1 = idx.polyline
|
|
432
|
+
? `ST_Contains(ST_MakePolygon(ST_LineFromEncodedPolyline($${idx1.polyline})),${meta.bbox})`
|
|
433
|
+
: undefined;
|
|
398
434
|
const filterWhere = [
|
|
399
435
|
fData.q,
|
|
400
|
-
|
|
436
|
+
search1,
|
|
401
437
|
bbox,
|
|
402
|
-
|
|
438
|
+
queryPolyline1,
|
|
403
439
|
interfaceQuery,
|
|
404
440
|
loadTable?.query,
|
|
405
441
|
tokenData?.query,
|
|
406
|
-
]
|
|
407
|
-
.filter(Boolean)
|
|
408
|
-
.filter((el) => checkQuery(el));
|
|
442
|
+
].filter(Boolean);
|
|
409
443
|
const aggColumns = columns
|
|
410
444
|
.filter((el) => el.agg)
|
|
411
445
|
.reduce((acc, curr) => Object.assign(acc, { [curr.name]: curr.agg }), {});
|
|
@@ -416,21 +450,20 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
416
450
|
}))
|
|
417
451
|
.filter((el) => ["numeric", "double precision"].includes(el.type) && aggColumns[el.name]);
|
|
418
452
|
const qCount = `select
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
453
|
+
count(*)::int as total,
|
|
454
|
+
count(*) FILTER(WHERE ${filterWhere.join(" and ") || "true"})::int as filtered
|
|
455
|
+
${aggregates.length
|
|
422
456
|
? `,${aggregates
|
|
423
457
|
.map((el) => `${aggColumns[el.name]}(${el.name}) FILTER(WHERE ${filterWhere.join(" and ") || "true"}) as ${el.name}`)
|
|
424
458
|
.join(",")}`
|
|
425
459
|
: ""}
|
|
426
|
-
|
|
460
|
+
from (select * ${sql
|
|
427
461
|
?.filter((el) => el.inline)
|
|
428
462
|
.map((el) => `,(${el.sql})`)
|
|
429
463
|
.join("") || ""} from ${viewSql ? `(${viewSql})` : table1} t ${sqlTable})t
|
|
430
|
-
|
|
464
|
+
where ${[loadTable?.query, tokenData?.query, accessQuery, contextQuery]
|
|
431
465
|
.filter(Boolean)
|
|
432
|
-
.
|
|
433
|
-
.join(" and ") || "true"} `.replace(/{{uid}}/g, uid);
|
|
466
|
+
.join(" and ") || "true"} `.replace(/{{uid}}/g, `$${idx1.uid}`);
|
|
434
467
|
if (query?.sql === "2") {
|
|
435
468
|
return qCount;
|
|
436
469
|
}
|
|
@@ -438,6 +471,7 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
438
471
|
? { total: rows.length, filtered: rows.length }
|
|
439
472
|
: await pg
|
|
440
473
|
.queryCache?.(qCount, {
|
|
474
|
+
args: args1,
|
|
441
475
|
table: loadTable?.table || tokenData?.table,
|
|
442
476
|
time: 5,
|
|
443
477
|
})
|
|
@@ -32,7 +32,8 @@ function plugin(app, opt = {}) {
|
|
|
32
32
|
},
|
|
33
33
|
schema: suggestSchema,
|
|
34
34
|
}, suggest);
|
|
35
|
-
app.get("/data/:table/:id?", { config: { tags, policy }, schema: tableSchema },
|
|
35
|
+
app.get("/data/:table/:id?", { config: { tags, policy, allowSql: true }, schema: tableSchema }, // query.polyline support w/ allowSql
|
|
36
|
+
data);
|
|
36
37
|
app.get("/table-data/:table", { config: { tags, auth: "creds", policy: "L2" }, schema: tableDataSchema }, data);
|
|
37
38
|
app.get("/table-data/:table/:id", { config: { tags, policy }, schema: tableDataIdSchema }, cardData);
|
|
38
39
|
app.get("/data-info/:id?", { config: { tags, policy }, schema: tableSchema }, dataInfo);
|
|
@@ -4,11 +4,11 @@ declare const tableDataSchema: {
|
|
|
4
4
|
querystring: {
|
|
5
5
|
limit: {
|
|
6
6
|
type: string;
|
|
7
|
-
|
|
7
|
+
minimum: number;
|
|
8
8
|
};
|
|
9
9
|
page: {
|
|
10
10
|
type: string;
|
|
11
|
-
|
|
11
|
+
minimum: number;
|
|
12
12
|
};
|
|
13
13
|
order: {
|
|
14
14
|
type: string;
|
|
@@ -36,7 +36,6 @@ declare const tableDataSchema: {
|
|
|
36
36
|
};
|
|
37
37
|
sql: {
|
|
38
38
|
type: string;
|
|
39
|
-
pattern: string;
|
|
40
39
|
};
|
|
41
40
|
};
|
|
42
41
|
params: {
|
|
@@ -57,11 +56,11 @@ declare const tableSchema: {
|
|
|
57
56
|
querystring: {
|
|
58
57
|
limit: {
|
|
59
58
|
type: string;
|
|
60
|
-
|
|
59
|
+
minimum: number;
|
|
61
60
|
};
|
|
62
61
|
page: {
|
|
63
62
|
type: string;
|
|
64
|
-
|
|
63
|
+
minimum: number;
|
|
65
64
|
};
|
|
66
65
|
order: {
|
|
67
66
|
type: string;
|
|
@@ -85,7 +84,6 @@ declare const tableSchema: {
|
|
|
85
84
|
};
|
|
86
85
|
sql: {
|
|
87
86
|
type: string;
|
|
88
|
-
pattern: string;
|
|
89
87
|
};
|
|
90
88
|
};
|
|
91
89
|
params: {
|
|
@@ -106,11 +104,11 @@ declare const searchSchema: {
|
|
|
106
104
|
querystring: {
|
|
107
105
|
page: {
|
|
108
106
|
type: string;
|
|
109
|
-
|
|
107
|
+
minimum: number;
|
|
110
108
|
};
|
|
111
109
|
limit: {
|
|
112
110
|
type: string;
|
|
113
|
-
|
|
111
|
+
minimum: number;
|
|
114
112
|
};
|
|
115
113
|
order: {
|
|
116
114
|
type: string;
|
|
@@ -161,11 +159,9 @@ declare const suggestSchema: {
|
|
|
161
159
|
};
|
|
162
160
|
sql: {
|
|
163
161
|
type: string;
|
|
164
|
-
pattern: string;
|
|
165
162
|
};
|
|
166
163
|
count: {
|
|
167
164
|
type: string;
|
|
168
|
-
pattern: string;
|
|
169
165
|
};
|
|
170
166
|
};
|
|
171
167
|
params: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/schema.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/schema.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBhB,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAajB,CAAC;AAEF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBlB,CAAC;AAEF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;CAQf,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;CAOjB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAUtB,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,76 +1,76 @@
|
|
|
1
1
|
const tableDataSchema = {
|
|
2
|
-
type:
|
|
2
|
+
type: "object",
|
|
3
3
|
properties: {
|
|
4
4
|
querystring: {
|
|
5
|
-
limit: { type:
|
|
6
|
-
page: { type:
|
|
5
|
+
limit: { type: "number", minimum: 1 },
|
|
6
|
+
page: { type: "number", minimum: 1 },
|
|
7
7
|
// filter: { type: 'string', pattern: '^([\\w\\d_-]+)=([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
|
|
8
8
|
// search: { type: 'string', pattern: '^([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
|
|
9
|
-
order: { type:
|
|
10
|
-
desc: { type:
|
|
11
|
-
state: { type:
|
|
12
|
-
custom: { type:
|
|
13
|
-
bbox: { type:
|
|
14
|
-
polyline: { type:
|
|
9
|
+
order: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
10
|
+
desc: { type: "string", pattern: "^(\\d+)$" },
|
|
11
|
+
state: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
12
|
+
custom: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
13
|
+
bbox: { type: "string", pattern: "^([\\d\\s,.-]+)$" },
|
|
14
|
+
polyline: { type: "string", pattern: "^([\\d\\w|@{}~_`]+)$" },
|
|
15
15
|
// key: { type: 'string', pattern: '^([\\d\\w_]+)$' },
|
|
16
|
-
sql: { type:
|
|
16
|
+
sql: { type: "number" },
|
|
17
17
|
},
|
|
18
18
|
params: {
|
|
19
|
-
id: { type:
|
|
20
|
-
table: { type:
|
|
19
|
+
id: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
20
|
+
table: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
const tableSchema = {
|
|
25
|
-
type:
|
|
25
|
+
type: "object",
|
|
26
26
|
properties: {
|
|
27
27
|
querystring: {
|
|
28
|
-
limit: { type:
|
|
29
|
-
page: { type:
|
|
28
|
+
limit: { type: "number", minimum: 1 },
|
|
29
|
+
page: { type: "number", minimum: 1 },
|
|
30
30
|
// filter: { type: 'string', pattern: '^([\\w\\d_-]+)=([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
|
|
31
31
|
// search: { type: 'string', pattern: '^([А-Яа-яҐґЄєІіЇї\\d\\w\\s\\/\\[\\]\\(\\)\\{\\}\\|,.!?;:—_=-@%#$&^*+=`~]+)$' },
|
|
32
|
-
order: { type:
|
|
33
|
-
desc: { type:
|
|
32
|
+
order: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
33
|
+
desc: { type: "string", pattern: "^(\\d+)$" },
|
|
34
34
|
// state: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
35
35
|
// custom: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
36
|
-
bbox: { type:
|
|
36
|
+
bbox: { type: "string", pattern: "^([\\d\\s,.-]+)$" },
|
|
37
37
|
// polyline: { type: 'string', pattern: '^([\\d\\w\\|@\\/\\{\\}~_`]+)$' },
|
|
38
|
-
key: { type:
|
|
39
|
-
uid: { type:
|
|
40
|
-
sql: { type:
|
|
38
|
+
key: { type: "string", pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_.-]+)$" },
|
|
39
|
+
uid: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
40
|
+
sql: { type: "number" },
|
|
41
41
|
},
|
|
42
42
|
params: {
|
|
43
|
-
id: { type:
|
|
44
|
-
table: { type:
|
|
43
|
+
id: { type: "string", pattern: "^([\\d\\w]+)$" },
|
|
44
|
+
table: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
const searchSchema = {
|
|
49
|
-
type:
|
|
49
|
+
type: "object",
|
|
50
50
|
properties: {
|
|
51
51
|
querystring: {
|
|
52
|
-
page: { type:
|
|
53
|
-
limit: { type:
|
|
54
|
-
order: { type:
|
|
55
|
-
desc: { type:
|
|
56
|
-
key: { type:
|
|
57
|
-
table: { type:
|
|
58
|
-
sql: { type:
|
|
52
|
+
page: { type: "number", minimum: 1 },
|
|
53
|
+
limit: { type: "number", minimum: 1 },
|
|
54
|
+
order: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
55
|
+
desc: { type: "string", pattern: "^(\\d+)$" },
|
|
56
|
+
key: { type: "string", pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_.-]+)$" },
|
|
57
|
+
table: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
58
|
+
sql: { type: "string", pattern: "^(\\d)$" },
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
const suggestSchema = {
|
|
63
|
-
type:
|
|
63
|
+
type: "object",
|
|
64
64
|
properties: {
|
|
65
65
|
querystring: {
|
|
66
|
-
lang: { type:
|
|
67
|
-
parent: { type:
|
|
68
|
-
sel: { type:
|
|
69
|
-
name: { type:
|
|
66
|
+
lang: { type: "string", pattern: "^([\\w]+)$" },
|
|
67
|
+
parent: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
68
|
+
sel: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
69
|
+
name: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
70
70
|
// key: { type: 'string', pattern: '^([\\d\\w_.-]+)$' },
|
|
71
|
-
val: { type:
|
|
72
|
-
sql: { type:
|
|
73
|
-
count: { type:
|
|
71
|
+
val: { type: "string", pattern: "([\\d\\w]+)$" },
|
|
72
|
+
sql: { type: "number" },
|
|
73
|
+
count: { type: "number" },
|
|
74
74
|
},
|
|
75
75
|
params: {
|
|
76
76
|
// data: { type: 'string', pattern: '^([\\d\\w]+)$' },
|
|
@@ -78,39 +78,39 @@ const suggestSchema = {
|
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
const formSchema = {
|
|
81
|
-
type:
|
|
81
|
+
type: "object",
|
|
82
82
|
properties: {
|
|
83
83
|
params: {
|
|
84
|
-
name: { type:
|
|
85
|
-
id: { type:
|
|
84
|
+
name: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
85
|
+
id: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
86
86
|
},
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
const filterSchema = {
|
|
90
|
-
type:
|
|
90
|
+
type: "object",
|
|
91
91
|
properties: {
|
|
92
92
|
params: {
|
|
93
|
-
table: { type:
|
|
93
|
+
table: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
96
|
};
|
|
97
97
|
const cardTabDataSchema = {
|
|
98
|
-
type:
|
|
98
|
+
type: "object",
|
|
99
99
|
properties: {
|
|
100
100
|
querystring: {
|
|
101
|
-
sql: { type:
|
|
101
|
+
sql: { type: "string", pattern: "^(\\d)$" },
|
|
102
102
|
},
|
|
103
103
|
params: {
|
|
104
|
-
token: { type:
|
|
104
|
+
token: { type: "string", pattern: "^([\\d\\w]+)$" },
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
107
|
};
|
|
108
108
|
const tableDataIdSchema = {
|
|
109
|
-
type:
|
|
109
|
+
type: "object",
|
|
110
110
|
properties: {
|
|
111
111
|
params: {
|
|
112
|
-
id: { type:
|
|
113
|
-
name: { type:
|
|
112
|
+
id: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
113
|
+
name: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
114
114
|
},
|
|
115
115
|
},
|
|
116
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/templates/index.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/templates/index.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAQpD"}
|
|
@@ -3,5 +3,11 @@ import { getTemplateSchema } from "./schema.js";
|
|
|
3
3
|
const policy = "L0";
|
|
4
4
|
const tags = ["core", "templates"];
|
|
5
5
|
export default function route(app, opt = {}) {
|
|
6
|
-
app.
|
|
6
|
+
app.route({
|
|
7
|
+
method: "GET",
|
|
8
|
+
url: "/template/:type/:name",
|
|
9
|
+
config: { tags, policy },
|
|
10
|
+
schema: getTemplateSchema,
|
|
11
|
+
handler: getTemplateApi,
|
|
12
|
+
});
|
|
7
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/templates/schema.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB;;;;;;;;;;CAQtB,CAAC;;AAEF,wBAAoB;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/templates/schema.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB;;;;;;;;;;CAQtB,CAAC;;AAEF,wBAAoB;AAEpB,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const getTemplateSchema = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
name: { type:
|
|
2
|
+
params: {
|
|
3
|
+
type: "object",
|
|
4
|
+
properties: {
|
|
5
|
+
name: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
6
6
|
// type: { type: 'string' },
|
|
7
7
|
},
|
|
8
8
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../server/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAM1B,QAAA,IAAI,QAAQ,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../server/types/core.ts"],"names":[],"mappings":"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"}
|