@opengis/fastify-table 2.5.56 → 2.5.58
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/functions.d.ts.map +1 -1
- package/dist/functions.js +10 -7
- package/dist/server/plugins/table/funcs/getSelect.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelect.js +2 -2
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts +2 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.js +13 -2
- package/dist/server/routes/table/controllers/suggest.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/suggest.js +1 -0
- 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 +2 -1
- package/package.json +1 -1
package/dist/functions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../functions.ts"],"names":[],"mappings":"AAoCA,wBAAsB,SAAS,kBAkH9B;AAED,wBAAsB,SAAS,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../functions.ts"],"names":[],"mappings":"AAoCA,wBAAsB,SAAS,kBAkH9B;AAED,wBAAsB,SAAS,kBAqJ9B;AAED,wBAAsB,SAAS,kBAkM9B;AAED,wBAAsB,WAAW,CAAC,EAChC,IAAI,EACJ,IAAI,EACJ,IAAS,GACV,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B;;eAqBA;AAED,wBAAsB,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,gBASxE;AAED,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CA;AAED,wBAAsB,OAAO,kBAmC5B"}
|
package/dist/functions.js
CHANGED
|
@@ -104,9 +104,11 @@ export async function onListen2() {
|
|
|
104
104
|
if (!cls?.length)
|
|
105
105
|
return;
|
|
106
106
|
try {
|
|
107
|
-
const hashes =
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const hashes = process.env.disableCache === "true"
|
|
108
|
+
? []
|
|
109
|
+
: await rclient
|
|
110
|
+
.hgetall("cls-insert-hashes")
|
|
111
|
+
.then((obj) => Object.keys(obj));
|
|
110
112
|
const dbdata = await client
|
|
111
113
|
.query(`select json_object_agg(name, hash) from admin.cls where parent is null`)
|
|
112
114
|
.then((el) => el.rows?.[0]?.json_object_agg || {});
|
|
@@ -125,7 +127,8 @@ export async function onListen2() {
|
|
|
125
127
|
el.dbhash = dbdata[name];
|
|
126
128
|
// check for changes by redis hash / dropped from db / changed at git project
|
|
127
129
|
el.update =
|
|
128
|
-
|
|
130
|
+
process.env.disableCache === "true" ||
|
|
131
|
+
!hashes.includes(el.hash) ||
|
|
129
132
|
!names.includes(name) ||
|
|
130
133
|
el.hash !== el.dbhash;
|
|
131
134
|
if (type === "select" &&
|
|
@@ -138,9 +141,9 @@ export async function onListen2() {
|
|
|
138
141
|
}
|
|
139
142
|
else if (type === "cls" && loadTemplate?.length && el.update) {
|
|
140
143
|
clsQuery.push(`insert into admin.cls(name,type, module,hash) values('${name}','json', '${module?.replace(/'/g, "''")}','${el.hash}');
|
|
141
|
-
insert into admin.cls(code,name,parent,icon,color,data)
|
|
142
|
-
select value->>'id',value->>'text','${name}',value->>'icon',value->>'color',value->>'data'
|
|
143
|
-
from json_array_elements('${JSON.stringify(loadTemplate).replace(/'/g, "''")}'::json) on conflict (code,parent) do update set color=excluded.color;`);
|
|
144
|
+
insert into admin.cls(code,name,parent,icon,color,data,en,ua)
|
|
145
|
+
select value->>'id',value->>'text','${name}',value->>'icon',value->>'color',value->>'data',value->>'en',value->>'ua'
|
|
146
|
+
from json_array_elements('${JSON.stringify(loadTemplate).replace(/'/g, "''")}'::json) on conflict (code,parent) do update set color=excluded.color, name=excluded.name, ua=excluded.ua, en=excluded.en;`);
|
|
144
147
|
if (config.trace)
|
|
145
148
|
console.log(name, type, "insert fresh cls");
|
|
146
149
|
return el.hash;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelect.ts"],"names":[],"mappings":"AAYA,wBAA8B,SAAS,CACrC,IAAI,EAAE,GAAG,EACT,EAAE,MAAmB,EACrB,OAAO,UAAQ,
|
|
1
|
+
{"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelect.ts"],"names":[],"mappings":"AAYA,wBAA8B,SAAS,CACrC,IAAI,EAAE,GAAG,EACT,EAAE,MAAmB,EACrB,OAAO,UAAQ,gBAoChB"}
|
|
@@ -5,14 +5,14 @@ const loadCls = {};
|
|
|
5
5
|
const sqls = {
|
|
6
6
|
sql: "select data from admin.user_cls where name=$1 union all select data from admin.cls where name=$1",
|
|
7
7
|
json: `select json_agg(json_build_object('id', code, 'text', name, 'icon', icon, 'color', color)) as data from admin.user_cls where parent=$1
|
|
8
|
-
union all select json_agg(json_build_object('id', code, 'text', name, 'icon', icon, 'color', color)) as data from admin.cls where parent=$1`,
|
|
8
|
+
union all select json_agg(json_build_object('id', code, 'text', name, 'icon', icon, 'color', color, 'ua', ua, 'en', en)) as data from admin.cls where parent=$1`,
|
|
9
9
|
};
|
|
10
10
|
export default async function getSelect(name, pg = pgClients.client, nocache = false) {
|
|
11
11
|
if (loadCls[name] && !config.local && !nocache) {
|
|
12
12
|
return loadCls[name];
|
|
13
13
|
}
|
|
14
14
|
const clsDataGIT = await getTemplate(["cls", "select"], name);
|
|
15
|
-
const { type } = pg.pk?.["admin.user_cls"]
|
|
15
|
+
const { type } = pg.pk?.["admin.user_cls"] && pg.pk?.["admin.cls"]
|
|
16
16
|
? await pg
|
|
17
17
|
.query("select type from admin.user_cls where parent is null and name=$1 and type<>'sql' union all select type from admin.cls where parent is null and name=$1 and type<>'sql' limit 1", [name])
|
|
18
18
|
.then((r) => r.rows?.[0] || {})
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ExtendedPG } from "../../../types/core.js";
|
|
2
|
-
export default function getSelectMeta({ name, startsWith, key, nocache, parent, pg, }: {
|
|
2
|
+
export default function getSelectMeta({ name, startsWith, key, nocache, parent, lang, pg, }: {
|
|
3
3
|
name: string;
|
|
4
4
|
startsWith?: boolean;
|
|
5
5
|
key?: string;
|
|
6
6
|
nocache?: any;
|
|
7
7
|
parent?: string;
|
|
8
|
+
lang?: string;
|
|
8
9
|
pg?: ExtendedPG;
|
|
9
10
|
}): Promise<any>;
|
|
10
11
|
//# sourceMappingURL=getSelectMeta.d.ts.map
|
|
@@ -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,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,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,gBAmIA"}
|
|
@@ -5,9 +5,10 @@ import pgClients from "../../pg/pgClients.js";
|
|
|
5
5
|
import getSelect from "./getSelect.js";
|
|
6
6
|
const limit = 50;
|
|
7
7
|
const selectMeta = {};
|
|
8
|
-
export default async function getSelectMeta({ name, startsWith, key, nocache, parent, pg = pgClients.client, }) {
|
|
9
|
-
if (selectMeta[name] && !startsWith && !nocache)
|
|
8
|
+
export default async function getSelectMeta({ name, startsWith, key, nocache, parent, lang, pg = pgClients.client, }) {
|
|
9
|
+
if (selectMeta[name] && !startsWith && !nocache) {
|
|
10
10
|
return selectMeta[name];
|
|
11
|
+
}
|
|
11
12
|
if (selectMeta[name] && startsWith && key && !nocache) {
|
|
12
13
|
const searchQuery = `(${selectMeta[name].searchColumn
|
|
13
14
|
.split(",")
|
|
@@ -21,6 +22,16 @@ export default async function getSelectMeta({ name, startsWith, key, nocache, pa
|
|
|
21
22
|
: pg;
|
|
22
23
|
if (!cls)
|
|
23
24
|
return null;
|
|
25
|
+
if (cls.arr && lang) {
|
|
26
|
+
return {
|
|
27
|
+
arr: cls.arr.map((el) => ({
|
|
28
|
+
...el,
|
|
29
|
+
text: el[lang] || el.text,
|
|
30
|
+
en: undefined,
|
|
31
|
+
ua: undefined,
|
|
32
|
+
})),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
24
35
|
if (cls.arr)
|
|
25
36
|
return cls;
|
|
26
37
|
if (!cls.sql)
|
|
@@ -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;AA+BpD,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;;;;;UAwFA;AAED,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,
|
|
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;AA+BpD,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;;;;;UAwFA;AAED,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBA6d7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/table/schema.ts"],"names":[],"mappings":"AAKA,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":"AAKA,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBpB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhB,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAajB,CAAC;AAEF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBlB,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const keySchema = {
|
|
2
2
|
type: "string",
|
|
3
|
-
pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_
|
|
3
|
+
pattern: "^([А-Яа-яҐґЄєІіЇї\\d\\w\\s_.-:—!?%@#$,'; ]+)$",
|
|
4
4
|
};
|
|
5
5
|
const tableDataSchema = {
|
|
6
6
|
type: "object",
|
|
@@ -75,6 +75,7 @@ const suggestSchema = {
|
|
|
75
75
|
additionalProperties: false,
|
|
76
76
|
properties: {
|
|
77
77
|
lang: { type: "string", pattern: "^([\\w]+)$" },
|
|
78
|
+
limit: { type: "integer", minimum: 1, maximum: 200 },
|
|
78
79
|
parent: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
79
80
|
sel: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|
|
80
81
|
name: { type: "string", pattern: "^([\\d\\w_.-]+)$" },
|