@opengis/fastify-table 1.1.129 → 1.1.131

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/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "@opengis/fastify-table",
3
- "version": "1.1.129",
4
- "type": "module",
5
- "description": "core-plugins",
6
- "keywords": [
7
- "fastify",
8
- "table",
9
- "crud",
10
- "pg",
11
- "backend"
12
- ],
13
- "main": "index.js",
14
- "files": [
15
- "server/*",
16
- "index.js",
17
- "utils.js",
18
- "config.js"
19
- ],
20
- "scripts": {
21
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
22
- "test": "node --test",
23
- "docs:dev": "vitepress dev docs",
24
- "docs:build": "vitepress build docs",
25
- "docs:preview": "vitepress preview docs",
26
- "compress": "node compress.js"
27
- },
28
- "dependencies": {
29
- "@fastify/sensible": "^5.0.0",
30
- "@fastify/url-data": "^5.4.0",
31
- "@opengis/fastify-hb": "^1.4.8",
32
- "fastify": "^4.26.1",
33
- "fastify-plugin": "^4.0.0",
34
- "ioredis": "^5.3.2",
35
- "js-yaml": "^4.1.0",
36
- "pg": "^8.11.3",
37
- "pino": "^9.5.0",
38
- "pino-abstract-transport": "^2.0.0",
39
- "uglify-js": "^3.19.3"
40
- },
41
- "devDependencies": {
42
- "@panzoom/panzoom": "^4.5.1",
43
- "eslint": "^8.49.0",
44
- "eslint-config-airbnb": "^19.0.4",
45
- "markdown-it-abbr": "^2.0.0",
46
- "mermaid": "^10.9.3",
47
- "sass": "1.72.0",
48
- "vitepress": "^1.3.4",
49
- "vitepress-plugin-mermaid": "^2.0.16",
50
- "vitepress-plugin-tabs": "^0.5.0",
51
- "vitepress-sidebar": "^1.25.0",
52
- "vue": "^3.4.27"
53
- },
54
- "author": "Softpro",
55
- "license": "ISC"
1
+ {
2
+ "name": "@opengis/fastify-table",
3
+ "version": "1.1.131",
4
+ "type": "module",
5
+ "description": "core-plugins",
6
+ "keywords": [
7
+ "fastify",
8
+ "table",
9
+ "crud",
10
+ "pg",
11
+ "backend"
12
+ ],
13
+ "main": "index.js",
14
+ "files": [
15
+ "server/*",
16
+ "index.js",
17
+ "utils.js",
18
+ "config.js"
19
+ ],
20
+ "scripts": {
21
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
22
+ "test": "node --test",
23
+ "docs:dev": "vitepress dev docs",
24
+ "docs:build": "vitepress build docs",
25
+ "docs:preview": "vitepress preview docs",
26
+ "compress": "node compress.js"
27
+ },
28
+ "dependencies": {
29
+ "@fastify/sensible": "^5.0.0",
30
+ "@fastify/url-data": "^5.4.0",
31
+ "@opengis/fastify-hb": "^1.4.8",
32
+ "fastify": "^4.26.1",
33
+ "fastify-plugin": "^4.0.0",
34
+ "ioredis": "^5.3.2",
35
+ "js-yaml": "^4.1.0",
36
+ "pg": "^8.11.3",
37
+ "pino": "^9.5.0",
38
+ "pino-abstract-transport": "^2.0.0",
39
+ "uglify-js": "^3.19.3"
40
+ },
41
+ "devDependencies": {
42
+ "@panzoom/panzoom": "^4.5.1",
43
+ "eslint": "^8.49.0",
44
+ "eslint-config-airbnb": "^19.0.4",
45
+ "markdown-it-abbr": "^2.0.0",
46
+ "mermaid": "^10.9.3",
47
+ "sass": "1.72.0",
48
+ "vitepress": "^1.3.4",
49
+ "vitepress-plugin-mermaid": "^2.0.16",
50
+ "vitepress-plugin-tabs": "^0.5.0",
51
+ "vitepress-sidebar": "^1.25.0",
52
+ "vue": "^3.4.27"
53
+ },
54
+ "author": "Softpro",
55
+ "license": "ISC"
56
56
  }
@@ -5,7 +5,7 @@ CREATE TABLE if not exists admin.users();
5
5
  ALTER TABLE admin.users add column if not exists uid text NOT NULL DEFAULT next_id();
6
6
  ALTER TABLE admin.users DROP CONSTRAINT if exists admin_user_uid_pkey cascade;
7
7
  ALTER TABLE admin.users DROP CONSTRAINT if exists user_pk cascade;
8
- ALTER TABLE admin.users DROP CONSTRAINT if exists admin_user_user_rnokpp cascade;
8
+ ALTER TABLE admin.users DROP CONSTRAINT if exists admin_user_user_rnokpp;
9
9
 
10
10
  ALTER TABLE admin.users add column if not exists login text;
11
11
  ALTER TABLE admin.users add column if not exists password text NOT NULL DEFAULT ''::text;
@@ -98,6 +98,7 @@ ALTER TABLE admin.users_social_auth add column if not exists users_social_auth_i
98
98
  ALTER TABLE admin.users_social_auth alter column users_social_auth_id set DEFAULT next_id();
99
99
  ALTER TABLE admin.users_social_auth DROP CONSTRAINT if exists users_social_auth_pk cascade;
100
100
  ALTER TABLE admin.users_social_auth DROP CONSTRAINT if exists users_social_auth_users_fk cascade;
101
+ ALTER TABLE admin.users_social_auth DROP CONSTRAINT if exists users_social_auth_social_id_email_unique;
101
102
 
102
103
  ALTER TABLE admin.users_social_auth add column if not exists uid text not null;
103
104
  ALTER TABLE admin.users_social_auth add column if not exists user_name text;
@@ -121,6 +122,7 @@ ALTER TABLE admin.users_social_auth add column if not exists editor_date timesta
121
122
  ALTER TABLE admin.users_social_auth add column if not exists social_auth_url text;
122
123
  ALTER TABLE admin.users_social_auth add CONSTRAINT users_social_auth_pk PRIMARY KEY (users_social_auth_id);
123
124
  ALTER TABLE admin.users_social_auth add CONSTRAINT users_social_auth_users_fk FOREIGN KEY (uid) REFERENCES admin.users (uid) MATCH SIMPLE on delete cascade;
125
+ ALTER TABLE admin.users_social_auth add CONSTRAINT users_social_auth_social_id_email_unique UNIQUE (social_auth_id,email);
124
126
 
125
127
  COMMENT ON COLUMN admin.users_social_auth.uid IS 'id пользователя';
126
128
  COMMENT ON COLUMN admin.users_social_auth.user_name IS 'Имя пользователя';
@@ -1,33 +1,33 @@
1
- import getPG from './getPG.js';
2
-
3
- const data = {};
4
-
5
- // decorator
6
- export default async function getMeta(opt) {
7
- const pg = opt?.pg || getPG({ name: 'client' });
8
- const table = opt?.table || opt;
9
-
10
- if (data[table]) return data[table];
11
-
12
- if (!pg.tlist?.includes(table?.replace?.(/"/g, ''))) {
13
- return { error: `${table} - not found`, status: 400 };
14
- }
15
-
16
- const { fields = [] } = await pg.query(`select * from ${table} limit 0`);
17
- const { pks1 = {} } = await pg.query(`SELECT json_object_agg(c.conrelid::regclass, a.attname) as pks1
18
- FROM pg_constraint c
19
- left join pg_attribute a on c.conrelid=a.attrelid and a.attnum = c.conkey[1]
20
- WHERE c.contype='p'::"char" and c.conrelid::regclass = $1::regclass`, [table]).then(el => el.rows?.[0] || {});
21
-
22
- const pk = table.startsWith('public.')
23
- ? (pks1[table.replace('public.', '')] || pks1[table.replace('public.', '').replace(/"/g, '')])
24
- : (pks1[table] || pks1[table.replace(/"/g, '')]);
25
-
26
- const geomAttr = fields.find((el) => pg.pgType?.[el.dataTypeID] === 'geometry')?.name; // change geometry text to geometry code
27
-
28
- const res = {
29
- pk, columns: fields, geom: geomAttr, view: pg.relkinds?.[table] === 'v',
30
- };
31
- data[table] = res;
32
- return res;
33
- }
1
+ import getPG from './getPG.js';
2
+
3
+ const data = {};
4
+
5
+ // decorator
6
+ export default async function getMeta(opt) {
7
+ const pg = opt?.pg || getPG({ name: 'client' });
8
+ const table = opt?.table || opt;
9
+
10
+ if (data[table]) return data[table];
11
+
12
+ if (!pg.tlist?.includes(table?.replace?.(/"/g, ''))) {
13
+ return { error: `${table} - not found`, status: 400 };
14
+ }
15
+
16
+ const { fields = [] } = await pg.query(`select * from ${table} limit 0`);
17
+ const pks1 = await pg.query(`SELECT json_object_agg(c.conrelid::regclass, a.attname) as pks1
18
+ FROM pg_constraint c
19
+ left join pg_attribute a on c.conrelid=a.attrelid and a.attnum = c.conkey[1]
20
+ WHERE c.contype='p'::"char" and c.conrelid::regclass = $1::regclass`, [table]).then(el => el.rows[0].pks1 || {});
21
+
22
+ const pk = table.startsWith('public.')
23
+ ? (pks1[table.replace('public.', '')] || pks1[table.replace('public.', '').replace(/"/g, '')])
24
+ : (pks1[table] || pks1[table.replace(/"/g, '')]);
25
+
26
+ const geomAttr = fields.find((el) => pg.pgType?.[el.dataTypeID] === 'geometry')?.name; // change geometry text to geometry code
27
+
28
+ const res = {
29
+ pk, columns: fields, geom: geomAttr, view: pg.relkinds?.[table] === 'v',
30
+ };
31
+ data[table] = res;
32
+ return res;
33
+ }