@opengis/fastify-table 2.0.98 → 2.0.100
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/helpers/funcs/contentList.js +2 -2
- package/dist/server/plugins/pg/funcs/getPGAsync.d.ts +1 -1
- package/dist/server/plugins/pg/funcs/getPGAsync.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getTemplate.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getTemplate.js +8 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Handlebars from "handlebars";
|
|
2
|
-
import
|
|
2
|
+
import getPGAsync from "../../plugins/pg/funcs/getPGAsync.js";
|
|
3
3
|
const maxLimit = 100;
|
|
4
4
|
/**
|
|
5
5
|
* Відображення даних з таблиці або запиту до БД на сторінці. За запитом отримуємо масив json із рядків бази даних.
|
|
@@ -27,7 +27,7 @@ export default async function contentList(options) {
|
|
|
27
27
|
return "Table undefined";
|
|
28
28
|
}
|
|
29
29
|
try {
|
|
30
|
-
const pg =
|
|
30
|
+
const pg = await getPGAsync();
|
|
31
31
|
const hasBrackets = table.trim().startsWith("(") && table.trim().endsWith(")");
|
|
32
32
|
const SQL = `select *,${pg.pk[table] || "1"}::text from ${hasBrackets ? `${table} t` : table} where ${query || "1=1"} ${order ? `order by ${order}` : ""} limit ${limit !== undefined && limit !== null ? Math.min(maxLimit, +limit) : 15}`;
|
|
33
33
|
const compiledSQL = Handlebars.compile(SQL)(options.data.root);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPGAsync.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/getPGAsync.ts"],"names":[],"mappings":"AAYA,iBAAe,UAAU,CAAC,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"getPGAsync.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/pg/funcs/getPGAsync.ts"],"names":[],"mappings":"AAYA,iBAAe,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,gBA6DpC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTemplate.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTemplate.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getTemplate.ts"],"names":[],"mappings":"AA+FA,wBAA8B,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,gBAyB7D"}
|
|
@@ -10,7 +10,7 @@ async function readFileData(file) {
|
|
|
10
10
|
if (ext === "yml") {
|
|
11
11
|
return yaml.load(data);
|
|
12
12
|
}
|
|
13
|
-
if (ext === "json") {
|
|
13
|
+
if (ext === "json" && data) {
|
|
14
14
|
return JSON.parse(data);
|
|
15
15
|
}
|
|
16
16
|
if (ext === "md") {
|
|
@@ -44,6 +44,13 @@ async function getTemplateData(template) {
|
|
|
44
44
|
// one file template: table, form
|
|
45
45
|
if (template.length === 1) {
|
|
46
46
|
const data = await readFileData(template[0][1]);
|
|
47
|
+
if (template[0][2] === "json" &&
|
|
48
|
+
path.basename(path.dirname(template[0][1])) === "table" &&
|
|
49
|
+
data?.parent) {
|
|
50
|
+
const parentTemplate = getTemplatePath("table").find((el) => el[0] === data.parent);
|
|
51
|
+
const parentData = await readFileData(parentTemplate[1]);
|
|
52
|
+
return { ...(parentData || {}), ...data };
|
|
53
|
+
}
|
|
47
54
|
return data;
|
|
48
55
|
}
|
|
49
56
|
// multi file template: select, etc
|