@opengis/fastify-table 2.0.114 → 2.0.116
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 +14 -3
- package/dist/module/core/pt/schemaItem.pt.hbs +1 -1
- package/dist/script/migrate.d.ts.map +1 -1
- package/dist/script/migrate.js +4 -0
- package/dist/script/migrate.ts +10 -0
- package/dist/server/routes/table/controllers/suggest.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/suggest.js +2 -3
- 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":"AA2FA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA2FA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QA4K3B;;AACD,wBAA0B"}
|
package/dist/index.js
CHANGED
|
@@ -68,9 +68,16 @@ function plugin(fastify) {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
if (!fastify.hasRoute({ method: "GET", url: "/api/list" })) {
|
|
71
|
-
fastify.get(`${opt.prefix}/list`, { config: { role: "admin" } }, () =>
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
fastify.get(`${opt.prefix}/list`, { config: { role: "admin" } }, ({ query }) => {
|
|
72
|
+
const { package: packageName, subdir } = query;
|
|
73
|
+
if (packageName) {
|
|
74
|
+
return { rows: routes.filter((r) => r.package === packageName) };
|
|
75
|
+
}
|
|
76
|
+
if (subdir) {
|
|
77
|
+
return { rows: routes.filter((r) => r.subdir === subdir) };
|
|
78
|
+
}
|
|
79
|
+
return { rows: routes };
|
|
80
|
+
});
|
|
74
81
|
}
|
|
75
82
|
fastify.addHook("onRoute", (r) => {
|
|
76
83
|
if (r.method === "HEAD")
|
|
@@ -82,9 +89,13 @@ function plugin(fastify) {
|
|
|
82
89
|
[curr]: r.schema?.querystring?.properties?.[curr]?.type,
|
|
83
90
|
}), {})
|
|
84
91
|
: undefined;
|
|
92
|
+
r.config = r.config || {};
|
|
93
|
+
r.config.package = r.config.package || "fastify-table";
|
|
85
94
|
routes.push({
|
|
86
95
|
method,
|
|
87
96
|
route: r.url,
|
|
97
|
+
subdir: r.config?.subdir,
|
|
98
|
+
package: r.config?.package,
|
|
88
99
|
description: r.config?.description,
|
|
89
100
|
query,
|
|
90
101
|
roles: r.config?.role?.split?.("|"),
|
|
@@ -11,7 +11,7 @@ CREATE TABLE if not exists {{nspname}}.{{relname}}
|
|
|
11
11
|
{{column_name}} {{data_type}} {{#unless is_nullable}}NOT NULL{{/unless}}{{#if column_default}}DEFAULT {{column_default}}{{/if}}{{#ifCond @index '!=' (_math ../columns.length '-' 1)}},{{/ifCond}} -- {{{coalesce description '-'}}}
|
|
12
12
|
{{/each}}{{#if constraints.length}},{{/if}}
|
|
13
13
|
{{#each constraints}}
|
|
14
|
-
CONSTRAINT {{constraint_name}} {{#ifCond constraint_type '==' 'c'}} {{check_definition}} {{/ifCond}} {{#ifCond constraint_type '==' 'f'}}FOREIGN KEY ({{foreign_column}}) REFERENCES {{foreign_table}} ({{foreign_column}}) MATCH {{select confmatchtype data="constraint_matchtype"}} ON UPDATE {{select confupdtype data="constraint_action"}} ON DELETE {{select confdeltype data="constraint_action"}}{{^}}{{select constraint_type data="constraint_type_full"}} ({{column_name}}){{/ifCond}}{{#ifCond @index '!=' (_math ../constraints.length '-' 1)}},{{/ifCond}}
|
|
14
|
+
CONSTRAINT {{constraint_name}} {{#ifCond constraint_type '==' 'c'}} {{check_definition}} {{/ifCond}} {{#ifCond constraint_type '==' 'f'}}FOREIGN KEY ({{foreign_column}}) REFERENCES {{foreign_table}} ({{foreign_column}}) MATCH {{select confmatchtype data="constraint_matchtype"}} ON UPDATE {{select confupdtype data="constraint_action"}} ON DELETE {{select confdeltype data="constraint_action"}}{{^}}{{#ifCond constraint_type '!=' 'c'}}{{select constraint_type data="constraint_type_full"}} ({{column_name}}){{/ifCond}}{{/ifCond}}{{#ifCond @index '!=' (_math ../constraints.length '-' 1)}},{{/ifCond}}
|
|
15
15
|
{{/each}}
|
|
16
16
|
);
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../script/migrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../script/migrate.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,OAAO,UAAU,OAAO,SAuB9B"}
|
package/dist/script/migrate.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import Fastify from "fastify";
|
|
2
3
|
import config from "../config.js";
|
|
3
4
|
import plugin from "../index.js";
|
|
5
|
+
import execMigrations from "../server/plugins/migration/exec.migrations.js";
|
|
6
|
+
import pgClients from "../server/plugins/pg/pgClients.js";
|
|
4
7
|
const timeoutMs = +(config.migrationTimeout || 5000);
|
|
5
8
|
const port = process.env.PORT || config.port || 3000;
|
|
6
9
|
if (import.meta.main) {
|
|
@@ -11,6 +14,7 @@ export default function migrate() {
|
|
|
11
14
|
app.register(plugin, config);
|
|
12
15
|
app.listen({ host: "0.0.0.0", port }, (err) => {
|
|
13
16
|
console.log(`Server started via port: ${port}`);
|
|
17
|
+
execMigrations(path.join(process.cwd(), "server/migrations"), pgClients.client).catch((err) => console.error(err.toString()));
|
|
14
18
|
setTimeout(() => {
|
|
15
19
|
console.log("Server closed after timeout", timeoutMs);
|
|
16
20
|
app.close();
|
package/dist/script/migrate.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import Fastify from "fastify";
|
|
2
3
|
|
|
3
4
|
import config from "../config.js";
|
|
4
5
|
import plugin from "../index.js";
|
|
5
6
|
|
|
7
|
+
import execMigrations from "../server/plugins/migration/exec.migrations.js";
|
|
8
|
+
import pgClients from "../server/plugins/pg/pgClients.js";
|
|
9
|
+
|
|
6
10
|
const timeoutMs = +(config.migrationTimeout || 5000);
|
|
7
11
|
|
|
8
12
|
const port = process.env.PORT || config.port || 3000;
|
|
@@ -18,6 +22,12 @@ export default function migrate() {
|
|
|
18
22
|
|
|
19
23
|
app.listen({ host: "0.0.0.0", port }, (err: any) => {
|
|
20
24
|
console.log(`Server started via port: ${port}`);
|
|
25
|
+
|
|
26
|
+
execMigrations(
|
|
27
|
+
path.join(process.cwd(), "server/migrations"),
|
|
28
|
+
pgClients.client
|
|
29
|
+
).catch((err) => console.error(err.toString()));
|
|
30
|
+
|
|
21
31
|
setTimeout(() => {
|
|
22
32
|
console.log("Server closed after timeout", timeoutMs);
|
|
23
33
|
app.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AA+DA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AA+DA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAqXzD"}
|
|
@@ -231,9 +231,8 @@ export default async function suggest(req, reply) {
|
|
|
231
231
|
}
|
|
232
232
|
// query
|
|
233
233
|
const { rows: dataNew } = await pg.query(sqlSuggest, query.key ? [query.key.toLowerCase()] : []);
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
const data = dataNew.filter((el) => el.id && el.text);
|
|
234
|
+
// in case id / text = Boolean
|
|
235
|
+
const data = dataNew.filter((el) => Object.hasOwn(el, "id") && Object.hasOwn(el, "text"));
|
|
237
236
|
if (tableName && column) {
|
|
238
237
|
const { name = query.sel || column, type = "select" } = getColumnCLS(tableName, column) || {};
|
|
239
238
|
await metaFormat({
|