@opengis/gis 0.2.176 → 0.2.178
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/README.md +181 -181
- package/dist/{CardIcon-c1Q2M3wQ.js → CardIcon-CMRD1LLh.js} +1 -1
- package/dist/{EntityTablePage-B5gpkH4S.js → EntityTablePage-XNNCltAN.js} +2 -2
- package/dist/{ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-DnGSvmMU.js → ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-BqUjKTDY.js} +1 -1
- package/dist/{HeaderActions.vue_vue_type_script_setup_true_lang-C2B61JP6.js → HeaderActions.vue_vue_type_script_setup_true_lang-BXQ3hKwa.js} +1 -1
- package/dist/{MapSettings-6-Xru5Q8.js → MapSettings-P3h-vHn3.js} +2 -2
- package/dist/{RastersTablePage-CXNOcTy-.js → RastersTablePage-DnhGZLiH.js} +2 -2
- package/dist/{cartocss-BFVqWvfP.js → cartocss-BkrOeQg4.js} +6 -6
- package/dist/{import-utils-uxk4LdUJ.js → import-utils-BCATsbB5.js} +1 -1
- package/dist/{index-CahlV-Xs.js → index-cUagVqgA.js} +39 -39
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/{raster-CEi56f0P.js → raster-CP0tUp3j.js} +3 -3
- package/dist/{register-NFAGBNa3.js → register-Cr-uQcby.js} +3 -3
- package/dist/{service-BYspag8U.js → service-DwJaKrOd.js} +6 -6
- package/dist/{vs-datatable-CHcBr6zy.js → vs-datatable-B9WoVk-b.js} +2 -2
- package/module/gis/cls/service_type.json +42 -42
- package/module/gis/form/gis.registers.form.json +127 -127
- package/module/test/map/addr.json +302 -302
- package/module/test/map/addr1.yml +23 -23
- package/module/test/select/address.str_id.sql +3 -3
- package/package.json +77 -77
- package/plugin.js +64 -64
- package/server/migrations/array_intersect.sql +13 -13
- package/server/migrations/cartocss.sql +27 -27
- package/server/migrations/group_list.sql +74 -74
- package/server/migrations/maps.sql +30 -30
- package/server/migrations/metadata.sql +415 -415
- package/server/migrations/ogc.sql +106 -106
- package/server/migrations/rasters.sql +265 -265
- package/server/migrations/services.sql +247 -247
- package/server/migrations/services_users_rel.sql +22 -22
- package/server/migrations/widgets.sql +20 -20
- package/server/plugins/crons.js +21 -21
- package/server/plugins/mapnik/funcs/checkRasterFile.js +107 -107
- package/server/plugins/mapnik/funcs/mapnik.js +151 -151
- package/server/plugins/mapnik/funcs/rootFolder.mjs +8 -8
- package/server/plugins/mapnik/map.proto +437 -437
- package/server/plugins/vite.js +74 -74
- package/server/routes/cartocss/cartocss.route.js +31 -31
- package/server/routes/cartocss/cartocss.route.test.js +78 -78
- package/server/routes/cartocss/cartocss.schema.js +73 -73
- package/server/routes/cartocss/functions/add.cartocss.js +39 -39
- package/server/routes/cartocss/functions/get.cartocss.js +57 -57
- package/server/routes/gis/functions/checkXML.js +107 -107
- package/server/routes/gis/functions/dashboard.js +24 -24
- package/server/routes/gis/gis.route.js +26 -26
- package/server/routes/gis/gis.route.test.js +33 -33
- package/server/routes/map/functions/clearTiles.js +35 -35
- package/server/routes/map/functions/geojson.js +187 -187
- package/server/routes/map/functions/gis.convert.js +65 -65
- package/server/routes/map/functions/gis.icon.js +220 -220
- package/server/routes/map/functions/jsonData.js +206 -206
- package/server/routes/map/functions/layerList.js +102 -102
- package/server/routes/map/functions/map.js +122 -122
- package/server/routes/map/functions/mapCatalog.js +72 -72
- package/server/routes/map/functions/mapCatalogAttribute.js +53 -53
- package/server/routes/map/functions/mapFeatures.js +133 -133
- package/server/routes/map/functions/mapFormat.js +232 -232
- package/server/routes/map/functions/mapTiles.js +162 -162
- package/server/routes/map/functions/maps.js +15 -15
- package/server/routes/map/functions/marker_icon.js +43 -43
- package/server/routes/map/functions/parseGeoFile.js +85 -85
- package/server/routes/map/functions/pointHeight.js +51 -51
- package/server/routes/map/functions/vtile.js +174 -174
- package/server/routes/map/functions/vtile1.js +185 -185
- package/server/routes/map/map.route.js +280 -280
- package/server/routes/map/map.route.test.js +503 -503
- package/server/routes/map/map.schema.js +356 -356
- package/server/routes/map/pin/circle1.svg +76 -76
- package/server/routes/map/pin/circle2.svg +18 -18
- package/server/routes/map/pin/none.svg +12 -12
- package/server/routes/map/pin/pin.svg +14 -14
- package/server/routes/map/pin/pin1.svg +16 -16
- package/server/routes/map/pin/pin2.svg +7 -7
- package/server/routes/map/pin/pin3.svg +34 -34
- package/server/routes/map/pin/pin4.svg +14 -14
- package/server/routes/map/pin/pin5.svg +7 -7
- package/server/routes/map/pin/pin6.svg +12 -12
- package/server/routes/map/pin/pin7.svg +12 -12
- package/server/routes/mapnik/functions/cartoBounds.js +32 -32
- package/server/routes/mapnik/functions/clearTiles.js +103 -103
- package/server/routes/mapnik/functions/convertBoundToTile.js +27 -27
- package/server/routes/mapnik/functions/createXml.js +76 -76
- package/server/routes/mapnik/functions/createXmlMulti.js +72 -72
- package/server/routes/mapnik/functions/fileSearch.js +35 -35
- package/server/routes/mapnik/functions/fileStat.js +28 -28
- package/server/routes/mapnik/functions/pretile.js +138 -138
- package/server/routes/mapnik/functions/rasterInfo.js +66 -66
- package/server/routes/mapnik/functions/readDir.js +22 -22
- package/server/routes/mapnik/functions/rtile.js +164 -164
- package/server/routes/mapnik/functions/uploadRaster.js +152 -152
- package/server/routes/mapnik/functions/uploadXML.js +140 -140
- package/server/routes/mapnik/mapnik.route.js +102 -102
- package/server/routes/mapnik/mapnik.route.test.js +370 -370
- package/server/routes/mapnik/mapnik.schema.mjs +195 -195
- package/server/routes/mapnik.prefixless/functions/mapnikLogger.js +31 -31
- package/server/routes/mapnik.prefixless/functions/mapnikStat.js +21 -21
- package/server/routes/mapnik.prefixless/mapnik.prefixless.route.js +20 -20
- package/server/routes/mapnik.prefixless/mapnik.prefixless.route.test.js +91 -91
- package/server/routes/mapnik.prefixless/mapnik.prefixless.schema.mjs +27 -27
- package/server/routes/maps/functions/add.map.js +42 -42
- package/server/routes/maps/functions/del.map.js +17 -17
- package/server/routes/maps/functions/get.map.js +119 -119
- package/server/routes/maps/maps.route.js +58 -58
- package/server/routes/maps/maps.route.test.js +231 -231
- package/server/routes/maps/maps.schema.js +9 -9
- package/server/routes/metadata/functions/editMetadata.js +35 -35
- package/server/routes/metadata/functions/metadataXML.js +19 -19
- package/server/routes/metadata/metadata.route.js +26 -26
- package/server/routes/metadata/metadata.route.test.js +46 -46
- package/server/routes/metadata/metadata.schema.js +53 -53
- package/server/routes/ogc/functions/map.info.point.js +117 -117
- package/server/routes/ogc/ogc.route.js +21 -21
- package/server/routes/ogc/ogc.route.test.js +53 -53
- package/server/routes/ogc/ogc.schema.js +16 -16
- package/server/routes/permissions/functions/catalog.permissions.edit.js +20 -20
- package/server/routes/permissions/functions/catalog.permissions.js +12 -12
- package/server/routes/permissions/functions/get.permissions.js +59 -59
- package/server/routes/permissions/functions/gis.catalog.js +80 -80
- package/server/routes/permissions/permissions.route.js +35 -35
- package/server/routes/permissions/permissions.route.test.js +35 -35
- package/server/routes/permissions/permissions.schema.js +43 -43
- package/server/routes/registers/functions/add.registry.js +37 -37
- package/server/routes/registers/functions/classifiers.js +100 -100
- package/server/routes/registers/functions/columns.js +3 -3
- package/server/routes/registers/functions/content.type.js +9 -9
- package/server/routes/registers/functions/del.registry.js +14 -14
- package/server/routes/registers/functions/get.info.js +93 -93
- package/server/routes/registers/functions/getFilterSQLParametrized/formatValue.js +312 -0
- package/server/routes/registers/functions/getFilterSQLParametrized/getFilterQuery.js +126 -0
- package/server/routes/registers/functions/getFilterSQLParametrized/getRangeQuery.js +353 -0
- package/server/routes/registers/functions/getFilterSQLParametrized/index.js +81 -0
- package/server/routes/registers/functions/getTableColumnMeta.js +125 -0
- package/server/routes/registers/functions/gis.export.js +159 -159
- package/server/routes/registers/functions/gis.registry.js +71 -71
- package/server/routes/registers/functions/gis.registry.list.js +61 -61
- package/server/routes/registers/functions/gis.suggest.js +275 -0
- package/server/routes/registers/functions/handleRegistryRequest.js +175 -147
- package/server/routes/registers/functions/map.registry.js +87 -87
- package/server/routes/registers/registers.route.js +91 -80
- package/server/routes/registers/registers.route.test.js +173 -144
- package/server/routes/registers/registers.schema.js +275 -246
- package/server/routes/root.mjs +3 -3
- package/server/routes/services/functions/add.service.js +62 -62
- package/server/routes/services/functions/create.route.js +93 -93
- package/server/routes/services/functions/del.service.js +12 -12
- package/server/routes/services/functions/get.layer.geom.js +27 -27
- package/server/routes/services/functions/get.service.users.js +76 -76
- package/server/routes/services/functions/get.services.col.js +34 -34
- package/server/routes/services/functions/get.services.js +89 -89
- package/server/routes/services/functions/legend.auto.js +77 -77
- package/server/routes/services/services.route.js +76 -76
- package/server/routes/services/services.route.test.js +167 -167
- package/server/routes/services/services.schema.js +285 -278
- package/server/routes/widgets/functions/add.widget.js +38 -38
- package/server/routes/widgets/functions/del.widget.js +17 -17
- package/server/routes/widgets/functions/get.widget.js +41 -41
- package/server/routes/widgets/widgets.route.js +61 -61
- package/server/routes/widgets/widgets.route.test.js +144 -144
- package/server/routes/widgets/widgets.schema.js +24 -24
- package/server/shared/listFiles.js +14 -14
- package/utils.js +13 -13
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import getMap from './functions/get.map.js';
|
|
2
|
-
import addMap from './functions/add.map.js';
|
|
3
|
-
import delMap from './functions/del.map.js';
|
|
4
|
-
|
|
5
|
-
import { schemaInfo } from './maps.schema.js';
|
|
6
|
-
|
|
7
|
-
const publicParams = {
|
|
8
|
-
config: { policy: 'L0' },
|
|
9
|
-
schema: schemaInfo,
|
|
10
|
-
package: 'gis',
|
|
11
|
-
}; // * L0 === public
|
|
12
|
-
const privilegedParams = {
|
|
13
|
-
config: { policy: 'L1', role: 'admin' },
|
|
14
|
-
schema: schemaInfo,
|
|
15
|
-
package: 'gis',
|
|
16
|
-
}; // ? just auth or admin
|
|
17
|
-
|
|
18
|
-
export default function (app) {
|
|
19
|
-
if (!app.hasRoute({ method: 'GET', url: '/gis-map/:id?' })) {
|
|
20
|
-
app.get('/gis-map/:id?', publicParams, async ({ params, pg }) => {
|
|
21
|
-
const result = await getMap({
|
|
22
|
-
id: params.id,
|
|
23
|
-
}, pg);
|
|
24
|
-
return result;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
if (!app.hasRoute({ method: 'POST', url: '/gis-map/:id?' })) {
|
|
28
|
-
app.post('/gis-map/:id?', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
29
|
-
const result = await addMap({
|
|
30
|
-
method,
|
|
31
|
-
id: params.id,
|
|
32
|
-
body,
|
|
33
|
-
uid: user?.uid,
|
|
34
|
-
}, pg);
|
|
35
|
-
return result;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
if (!app.hasRoute({ method: 'PUT', url: '/gis-map/:id' })) {
|
|
39
|
-
app.put('/gis-map/:id', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
40
|
-
const result = await addMap({
|
|
41
|
-
method,
|
|
42
|
-
id: params.id,
|
|
43
|
-
body,
|
|
44
|
-
uid: user?.uid,
|
|
45
|
-
}, pg);
|
|
46
|
-
return result;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (!app.hasRoute({ method: 'DELETE', url: '/gis-map/:id' })) {
|
|
50
|
-
app.delete('/gis-map/:id', privilegedParams, async ({ params, user, pg }) => {
|
|
51
|
-
const result = await delMap({
|
|
52
|
-
id: params.id,
|
|
53
|
-
uid: user?.uid,
|
|
54
|
-
}, pg);
|
|
55
|
-
return result;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
import getMap from './functions/get.map.js';
|
|
2
|
+
import addMap from './functions/add.map.js';
|
|
3
|
+
import delMap from './functions/del.map.js';
|
|
4
|
+
|
|
5
|
+
import { schemaInfo } from './maps.schema.js';
|
|
6
|
+
|
|
7
|
+
const publicParams = {
|
|
8
|
+
config: { policy: 'L0' },
|
|
9
|
+
schema: schemaInfo,
|
|
10
|
+
package: 'gis',
|
|
11
|
+
}; // * L0 === public
|
|
12
|
+
const privilegedParams = {
|
|
13
|
+
config: { policy: 'L1', role: 'admin' },
|
|
14
|
+
schema: schemaInfo,
|
|
15
|
+
package: 'gis',
|
|
16
|
+
}; // ? just auth or admin
|
|
17
|
+
|
|
18
|
+
export default function (app) {
|
|
19
|
+
if (!app.hasRoute({ method: 'GET', url: '/gis-map/:id?' })) {
|
|
20
|
+
app.get('/gis-map/:id?', publicParams, async ({ params, pg }) => {
|
|
21
|
+
const result = await getMap({
|
|
22
|
+
id: params.id,
|
|
23
|
+
}, pg);
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (!app.hasRoute({ method: 'POST', url: '/gis-map/:id?' })) {
|
|
28
|
+
app.post('/gis-map/:id?', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
29
|
+
const result = await addMap({
|
|
30
|
+
method,
|
|
31
|
+
id: params.id,
|
|
32
|
+
body,
|
|
33
|
+
uid: user?.uid,
|
|
34
|
+
}, pg);
|
|
35
|
+
return result;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (!app.hasRoute({ method: 'PUT', url: '/gis-map/:id' })) {
|
|
39
|
+
app.put('/gis-map/:id', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
40
|
+
const result = await addMap({
|
|
41
|
+
method,
|
|
42
|
+
id: params.id,
|
|
43
|
+
body,
|
|
44
|
+
uid: user?.uid,
|
|
45
|
+
}, pg);
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (!app.hasRoute({ method: 'DELETE', url: '/gis-map/:id' })) {
|
|
50
|
+
app.delete('/gis-map/:id', privilegedParams, async ({ params, user, pg }) => {
|
|
51
|
+
const result = await delMap({
|
|
52
|
+
id: params.id,
|
|
53
|
+
uid: user?.uid,
|
|
54
|
+
}, pg);
|
|
55
|
+
return result;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,231 +1,231 @@
|
|
|
1
|
-
/* eslint-disable indent */
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
describe, test, expect, beforeAll, afterAll,
|
|
6
|
-
} from 'vitest';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
getPGAsync, dataInsert,
|
|
10
|
-
} from '@opengis/fastify-table/utils.js';
|
|
11
|
-
|
|
12
|
-
import { build, injectWithHeaders } from '../../../test/helper.js';
|
|
13
|
-
|
|
14
|
-
const user = { uid: '1', user_type: 'admin' };
|
|
15
|
-
const testKey = 'unittest';
|
|
16
|
-
|
|
17
|
-
let pg;
|
|
18
|
-
|
|
19
|
-
const obj = {};
|
|
20
|
-
|
|
21
|
-
describe('maps api test', () => {
|
|
22
|
-
beforeAll(async () => {
|
|
23
|
-
await build();
|
|
24
|
-
pg = await getPGAsync();
|
|
25
|
-
// ensure not exists in case previous test fails / timeouts
|
|
26
|
-
const { rowCount } = await pg.query('delete from gis.maps where array[$1] && keywords', [testKey]);
|
|
27
|
-
console.log('clean up before: ', rowCount);
|
|
28
|
-
await pg.query(
|
|
29
|
-
'insert into gis.maps (map_id, name, keywords, created_by, center) values($1, $1, array[$1], $2, $3) on conflict (map_id) do nothing returning *',
|
|
30
|
-
[testKey, user.uid, [30, 50]],
|
|
31
|
-
);
|
|
32
|
-
console.log('insert before success');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
afterAll(async () => {
|
|
36
|
-
const { rowCount: maps } = await pg.query('delete from gis.maps where array[$1] && keywords', [testKey]);
|
|
37
|
-
console.log('clean up maps after: ', maps);
|
|
38
|
-
const { rowCount: widgets } = await pg.query('delete from gis.widgets where map_id in ($1,$2)', [testKey, name]);
|
|
39
|
-
console.log('clean up widgets after: ', widgets);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('GET /gis-map', async () => {
|
|
43
|
-
const res = await injectWithHeaders({
|
|
44
|
-
method: 'GET',
|
|
45
|
-
url: '/api/gis-map',
|
|
46
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
47
|
-
});
|
|
48
|
-
expect(res.statusCode).toBe(200);
|
|
49
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
50
|
-
const json = res.json();
|
|
51
|
-
Object.assign(obj, { 'GET/gis-map': json });
|
|
52
|
-
expect(json).toHaveProperty('rows');
|
|
53
|
-
expect(json.rows.length).toBeTruthy();
|
|
54
|
-
expect(json.rows[0]).toHaveProperty('map_id');
|
|
55
|
-
expect(json.rows[0]).toHaveProperty('name');
|
|
56
|
-
expect(json.rows[0]).toHaveProperty('map_key');
|
|
57
|
-
expect(json).toHaveProperty('fields');
|
|
58
|
-
expect(json.fields[0]).toHaveProperty('name');
|
|
59
|
-
expect(json.fields[0]).toHaveProperty('type');
|
|
60
|
-
expect(json.fields[0]).toHaveProperty('label');
|
|
61
|
-
}, 15000);
|
|
62
|
-
|
|
63
|
-
test('GET /gis-map/:id', async () => {
|
|
64
|
-
const res = await injectWithHeaders({
|
|
65
|
-
method: 'GET',
|
|
66
|
-
url: `/api/gis-map/${testKey}`,
|
|
67
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
68
|
-
});
|
|
69
|
-
expect(res.statusCode).toBe(200);
|
|
70
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
71
|
-
const json = res.json();
|
|
72
|
-
Object.assign(obj, { 'GET/gis-map/:id': json });
|
|
73
|
-
expect(json).toHaveProperty('map_id');
|
|
74
|
-
expect(json.map_id).toBe(testKey);
|
|
75
|
-
expect(json).toHaveProperty('name');
|
|
76
|
-
expect(json).toHaveProperty('map_key');
|
|
77
|
-
expect(json).toHaveProperty('widgets');
|
|
78
|
-
expect(json).toHaveProperty('layers');
|
|
79
|
-
expect(json).toHaveProperty('center');
|
|
80
|
-
expect(Array.isArray(json.center)).toBeTruthy();
|
|
81
|
-
expect(json.center[0]).toBe(30);
|
|
82
|
-
expect(json.center[1]).toBe(50);
|
|
83
|
-
// expect(json.fields[0]).toHaveProperty('name');
|
|
84
|
-
// expect(json.fields[0]).toHaveProperty('type');
|
|
85
|
-
// expect(json.fields[0]).toHaveProperty('label');
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const name = [testKey, randomUUID()].join('-');
|
|
89
|
-
|
|
90
|
-
test('POST /gis-map', async () => {
|
|
91
|
-
const res = await injectWithHeaders({
|
|
92
|
-
method: 'POST',
|
|
93
|
-
url: '/api/gis-map',
|
|
94
|
-
payload: {
|
|
95
|
-
name,
|
|
96
|
-
map_key: name,
|
|
97
|
-
keywords: [testKey],
|
|
98
|
-
widgets: [{
|
|
99
|
-
type: 'legend',
|
|
100
|
-
position: 'bottom-right',
|
|
101
|
-
}],
|
|
102
|
-
layers: ['dbcb186818e3', '3c95e341465d'],
|
|
103
|
-
},
|
|
104
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
105
|
-
});
|
|
106
|
-
expect(res.statusCode).toBe(200);
|
|
107
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
108
|
-
const json = res.json();
|
|
109
|
-
Object.assign(obj, { 'POST/gis-map': json });
|
|
110
|
-
expect(json).toHaveProperty('map_id');
|
|
111
|
-
expect(json).toHaveProperty('widgets');
|
|
112
|
-
expect(Array.isArray(json.widgets)).toBeTruthy();
|
|
113
|
-
expect(json.widgets[0]).toHaveProperty('type');
|
|
114
|
-
expect(json.widgets[0].type).toBe('legend');
|
|
115
|
-
expect(json).toHaveProperty('layers');
|
|
116
|
-
expect(Array.isArray(json.layers)).toBeTruthy();
|
|
117
|
-
expect(json.layers[0]).toBe('dbcb186818e3');
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test('GET /gis-widget/:map/:id', async () => {
|
|
121
|
-
const res = await injectWithHeaders({
|
|
122
|
-
method: 'GET',
|
|
123
|
-
url: `/api/gis-widget/${testKey}`,
|
|
124
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
125
|
-
});
|
|
126
|
-
expect(res.statusCode).toBe(200);
|
|
127
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
128
|
-
const json = res.json();
|
|
129
|
-
Object.assign(obj, { 'GET/gis-widget/:map': json });
|
|
130
|
-
expect(json).toHaveProperty('rows');
|
|
131
|
-
expect(json).toHaveProperty('fields');
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('GET /gis-widget/:map/:id', async () => {
|
|
135
|
-
await dataInsert({
|
|
136
|
-
table: 'gis.widgets',
|
|
137
|
-
id: name,
|
|
138
|
-
data: {
|
|
139
|
-
widget_id: name,
|
|
140
|
-
map_id: testKey,
|
|
141
|
-
type: 'card',
|
|
142
|
-
title: name,
|
|
143
|
-
config: {
|
|
144
|
-
items: [{
|
|
145
|
-
label: 'Карта тимчасових споруд',
|
|
146
|
-
url: '/map/ts',
|
|
147
|
-
}],
|
|
148
|
-
},
|
|
149
|
-
position: 'top-right',
|
|
150
|
-
},
|
|
151
|
-
uid: '1',
|
|
152
|
-
});
|
|
153
|
-
const res = await injectWithHeaders({
|
|
154
|
-
method: 'GET',
|
|
155
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
156
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
157
|
-
});
|
|
158
|
-
expect(res.statusCode).toBe(200);
|
|
159
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
160
|
-
const json = res.json();
|
|
161
|
-
Object.assign(obj, { 'GET/gis-widget/:map/:id': json });
|
|
162
|
-
expect(json).toHaveProperty('widget_id');
|
|
163
|
-
expect(json).toHaveProperty('type');
|
|
164
|
-
expect(json).toHaveProperty('title');
|
|
165
|
-
expect(json).toHaveProperty('config');
|
|
166
|
-
expect(json).toHaveProperty('position');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test('PUT /gis-widget/:map/:id', async () => {
|
|
170
|
-
const res = await injectWithHeaders({
|
|
171
|
-
method: 'PUT',
|
|
172
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
173
|
-
payload: {
|
|
174
|
-
type: 'card1',
|
|
175
|
-
},
|
|
176
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
177
|
-
});
|
|
178
|
-
expect(res.statusCode).toBe(200);
|
|
179
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
180
|
-
const json = res.json();
|
|
181
|
-
Object.assign(obj, { 'PUT/gis-widget/:map/:id': json });
|
|
182
|
-
expect(json).toHaveProperty('map_id');
|
|
183
|
-
expect(json.map_id).toBe(testKey);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
test('DELETE /gis-widget/:map/:id', async () => {
|
|
187
|
-
const res = await injectWithHeaders({
|
|
188
|
-
method: 'DELETE',
|
|
189
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
190
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
191
|
-
});
|
|
192
|
-
expect(res.statusCode).toBe(200);
|
|
193
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
194
|
-
const json = res.json();
|
|
195
|
-
Object.assign(obj, { 'DELETE/gis-widget/:map/:id': json });
|
|
196
|
-
expect(json).toHaveProperty('map_id');
|
|
197
|
-
expect(json.map_id).toBe(testKey);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('PUT /gis-map/:id', async () => {
|
|
201
|
-
const res = await injectWithHeaders({
|
|
202
|
-
method: 'PUT',
|
|
203
|
-
url: `/api/gis-map/${testKey}`,
|
|
204
|
-
payload: {
|
|
205
|
-
keywords: [testKey],
|
|
206
|
-
description: testKey,
|
|
207
|
-
},
|
|
208
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
209
|
-
});
|
|
210
|
-
expect(res.statusCode).toBe(200);
|
|
211
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
212
|
-
const json = res.json();
|
|
213
|
-
Object.assign(obj, { 'PUT/gis-map/:id': json });
|
|
214
|
-
expect(json).toHaveProperty('map_id');
|
|
215
|
-
expect(json.map_id).toBe(testKey);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test('DELETE /gis-map/:id', async () => {
|
|
219
|
-
const res = await injectWithHeaders({
|
|
220
|
-
method: 'DELETE',
|
|
221
|
-
url: `/api/gis-map/${testKey}`,
|
|
222
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
223
|
-
});
|
|
224
|
-
expect(res.statusCode).toBe(200);
|
|
225
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
226
|
-
const json = res.json();
|
|
227
|
-
Object.assign(obj, { 'DELETE/gis-map/:id': json });
|
|
228
|
-
expect(json).toHaveProperty('map_id');
|
|
229
|
-
expect(json.map_id).toBe(testKey);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
1
|
+
/* eslint-disable indent */
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
describe, test, expect, beforeAll, afterAll,
|
|
6
|
+
} from 'vitest';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
getPGAsync, dataInsert,
|
|
10
|
+
} from '@opengis/fastify-table/utils.js';
|
|
11
|
+
|
|
12
|
+
import { build, injectWithHeaders } from '../../../test/helper.js';
|
|
13
|
+
|
|
14
|
+
const user = { uid: '1', user_type: 'admin' };
|
|
15
|
+
const testKey = 'unittest';
|
|
16
|
+
|
|
17
|
+
let pg;
|
|
18
|
+
|
|
19
|
+
const obj = {};
|
|
20
|
+
|
|
21
|
+
describe('maps api test', () => {
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
await build();
|
|
24
|
+
pg = await getPGAsync();
|
|
25
|
+
// ensure not exists in case previous test fails / timeouts
|
|
26
|
+
const { rowCount } = await pg.query('delete from gis.maps where array[$1] && keywords', [testKey]);
|
|
27
|
+
console.log('clean up before: ', rowCount);
|
|
28
|
+
await pg.query(
|
|
29
|
+
'insert into gis.maps (map_id, name, keywords, created_by, center) values($1, $1, array[$1], $2, $3) on conflict (map_id) do nothing returning *',
|
|
30
|
+
[testKey, user.uid, [30, 50]],
|
|
31
|
+
);
|
|
32
|
+
console.log('insert before success');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterAll(async () => {
|
|
36
|
+
const { rowCount: maps } = await pg.query('delete from gis.maps where array[$1] && keywords', [testKey]);
|
|
37
|
+
console.log('clean up maps after: ', maps);
|
|
38
|
+
const { rowCount: widgets } = await pg.query('delete from gis.widgets where map_id in ($1,$2)', [testKey, name]);
|
|
39
|
+
console.log('clean up widgets after: ', widgets);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('GET /gis-map', async () => {
|
|
43
|
+
const res = await injectWithHeaders({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
url: '/api/gis-map',
|
|
46
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
47
|
+
});
|
|
48
|
+
expect(res.statusCode).toBe(200);
|
|
49
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
50
|
+
const json = res.json();
|
|
51
|
+
Object.assign(obj, { 'GET/gis-map': json });
|
|
52
|
+
expect(json).toHaveProperty('rows');
|
|
53
|
+
expect(json.rows.length).toBeTruthy();
|
|
54
|
+
expect(json.rows[0]).toHaveProperty('map_id');
|
|
55
|
+
expect(json.rows[0]).toHaveProperty('name');
|
|
56
|
+
expect(json.rows[0]).toHaveProperty('map_key');
|
|
57
|
+
expect(json).toHaveProperty('fields');
|
|
58
|
+
expect(json.fields[0]).toHaveProperty('name');
|
|
59
|
+
expect(json.fields[0]).toHaveProperty('type');
|
|
60
|
+
expect(json.fields[0]).toHaveProperty('label');
|
|
61
|
+
}, 15000);
|
|
62
|
+
|
|
63
|
+
test('GET /gis-map/:id', async () => {
|
|
64
|
+
const res = await injectWithHeaders({
|
|
65
|
+
method: 'GET',
|
|
66
|
+
url: `/api/gis-map/${testKey}`,
|
|
67
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
68
|
+
});
|
|
69
|
+
expect(res.statusCode).toBe(200);
|
|
70
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
71
|
+
const json = res.json();
|
|
72
|
+
Object.assign(obj, { 'GET/gis-map/:id': json });
|
|
73
|
+
expect(json).toHaveProperty('map_id');
|
|
74
|
+
expect(json.map_id).toBe(testKey);
|
|
75
|
+
expect(json).toHaveProperty('name');
|
|
76
|
+
expect(json).toHaveProperty('map_key');
|
|
77
|
+
expect(json).toHaveProperty('widgets');
|
|
78
|
+
expect(json).toHaveProperty('layers');
|
|
79
|
+
expect(json).toHaveProperty('center');
|
|
80
|
+
expect(Array.isArray(json.center)).toBeTruthy();
|
|
81
|
+
expect(json.center[0]).toBe(30);
|
|
82
|
+
expect(json.center[1]).toBe(50);
|
|
83
|
+
// expect(json.fields[0]).toHaveProperty('name');
|
|
84
|
+
// expect(json.fields[0]).toHaveProperty('type');
|
|
85
|
+
// expect(json.fields[0]).toHaveProperty('label');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const name = [testKey, randomUUID()].join('-');
|
|
89
|
+
|
|
90
|
+
test('POST /gis-map', async () => {
|
|
91
|
+
const res = await injectWithHeaders({
|
|
92
|
+
method: 'POST',
|
|
93
|
+
url: '/api/gis-map',
|
|
94
|
+
payload: {
|
|
95
|
+
name,
|
|
96
|
+
map_key: name,
|
|
97
|
+
keywords: [testKey],
|
|
98
|
+
widgets: [{
|
|
99
|
+
type: 'legend',
|
|
100
|
+
position: 'bottom-right',
|
|
101
|
+
}],
|
|
102
|
+
layers: ['dbcb186818e3', '3c95e341465d'],
|
|
103
|
+
},
|
|
104
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
105
|
+
});
|
|
106
|
+
expect(res.statusCode).toBe(200);
|
|
107
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
108
|
+
const json = res.json();
|
|
109
|
+
Object.assign(obj, { 'POST/gis-map': json });
|
|
110
|
+
expect(json).toHaveProperty('map_id');
|
|
111
|
+
expect(json).toHaveProperty('widgets');
|
|
112
|
+
expect(Array.isArray(json.widgets)).toBeTruthy();
|
|
113
|
+
expect(json.widgets[0]).toHaveProperty('type');
|
|
114
|
+
expect(json.widgets[0].type).toBe('legend');
|
|
115
|
+
expect(json).toHaveProperty('layers');
|
|
116
|
+
expect(Array.isArray(json.layers)).toBeTruthy();
|
|
117
|
+
expect(json.layers[0]).toBe('dbcb186818e3');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('GET /gis-widget/:map/:id', async () => {
|
|
121
|
+
const res = await injectWithHeaders({
|
|
122
|
+
method: 'GET',
|
|
123
|
+
url: `/api/gis-widget/${testKey}`,
|
|
124
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
125
|
+
});
|
|
126
|
+
expect(res.statusCode).toBe(200);
|
|
127
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
128
|
+
const json = res.json();
|
|
129
|
+
Object.assign(obj, { 'GET/gis-widget/:map': json });
|
|
130
|
+
expect(json).toHaveProperty('rows');
|
|
131
|
+
expect(json).toHaveProperty('fields');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('GET /gis-widget/:map/:id', async () => {
|
|
135
|
+
await dataInsert({
|
|
136
|
+
table: 'gis.widgets',
|
|
137
|
+
id: name,
|
|
138
|
+
data: {
|
|
139
|
+
widget_id: name,
|
|
140
|
+
map_id: testKey,
|
|
141
|
+
type: 'card',
|
|
142
|
+
title: name,
|
|
143
|
+
config: {
|
|
144
|
+
items: [{
|
|
145
|
+
label: 'Карта тимчасових споруд',
|
|
146
|
+
url: '/map/ts',
|
|
147
|
+
}],
|
|
148
|
+
},
|
|
149
|
+
position: 'top-right',
|
|
150
|
+
},
|
|
151
|
+
uid: '1',
|
|
152
|
+
});
|
|
153
|
+
const res = await injectWithHeaders({
|
|
154
|
+
method: 'GET',
|
|
155
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
156
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
157
|
+
});
|
|
158
|
+
expect(res.statusCode).toBe(200);
|
|
159
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
160
|
+
const json = res.json();
|
|
161
|
+
Object.assign(obj, { 'GET/gis-widget/:map/:id': json });
|
|
162
|
+
expect(json).toHaveProperty('widget_id');
|
|
163
|
+
expect(json).toHaveProperty('type');
|
|
164
|
+
expect(json).toHaveProperty('title');
|
|
165
|
+
expect(json).toHaveProperty('config');
|
|
166
|
+
expect(json).toHaveProperty('position');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('PUT /gis-widget/:map/:id', async () => {
|
|
170
|
+
const res = await injectWithHeaders({
|
|
171
|
+
method: 'PUT',
|
|
172
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
173
|
+
payload: {
|
|
174
|
+
type: 'card1',
|
|
175
|
+
},
|
|
176
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
177
|
+
});
|
|
178
|
+
expect(res.statusCode).toBe(200);
|
|
179
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
180
|
+
const json = res.json();
|
|
181
|
+
Object.assign(obj, { 'PUT/gis-widget/:map/:id': json });
|
|
182
|
+
expect(json).toHaveProperty('map_id');
|
|
183
|
+
expect(json.map_id).toBe(testKey);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('DELETE /gis-widget/:map/:id', async () => {
|
|
187
|
+
const res = await injectWithHeaders({
|
|
188
|
+
method: 'DELETE',
|
|
189
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
190
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
191
|
+
});
|
|
192
|
+
expect(res.statusCode).toBe(200);
|
|
193
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
194
|
+
const json = res.json();
|
|
195
|
+
Object.assign(obj, { 'DELETE/gis-widget/:map/:id': json });
|
|
196
|
+
expect(json).toHaveProperty('map_id');
|
|
197
|
+
expect(json.map_id).toBe(testKey);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('PUT /gis-map/:id', async () => {
|
|
201
|
+
const res = await injectWithHeaders({
|
|
202
|
+
method: 'PUT',
|
|
203
|
+
url: `/api/gis-map/${testKey}`,
|
|
204
|
+
payload: {
|
|
205
|
+
keywords: [testKey],
|
|
206
|
+
description: testKey,
|
|
207
|
+
},
|
|
208
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
209
|
+
});
|
|
210
|
+
expect(res.statusCode).toBe(200);
|
|
211
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
212
|
+
const json = res.json();
|
|
213
|
+
Object.assign(obj, { 'PUT/gis-map/:id': json });
|
|
214
|
+
expect(json).toHaveProperty('map_id');
|
|
215
|
+
expect(json.map_id).toBe(testKey);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test('DELETE /gis-map/:id', async () => {
|
|
219
|
+
const res = await injectWithHeaders({
|
|
220
|
+
method: 'DELETE',
|
|
221
|
+
url: `/api/gis-map/${testKey}`,
|
|
222
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
223
|
+
});
|
|
224
|
+
expect(res.statusCode).toBe(200);
|
|
225
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
226
|
+
const json = res.json();
|
|
227
|
+
Object.assign(obj, { 'DELETE/gis-map/:id': json });
|
|
228
|
+
expect(json).toHaveProperty('map_id');
|
|
229
|
+
expect(json.map_id).toBe(testKey);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const schemaInfo = {
|
|
2
|
-
params: {
|
|
3
|
-
type: 'object',
|
|
4
|
-
properties: {
|
|
5
|
-
id: { type: "string", pattern: '^([\\d\\w._-]+)$' },
|
|
6
|
-
},
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
|
|
1
|
+
export const schemaInfo = {
|
|
2
|
+
params: {
|
|
3
|
+
type: 'object',
|
|
4
|
+
properties: {
|
|
5
|
+
id: { type: "string", pattern: '^([\\d\\w._-]+)$' },
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
10
|
export default null;
|