@opengis/gis 0.2.208 → 0.2.209
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-iGo8QJu9.js → CardIcon-B6rIgAoD.js} +1 -1
- package/dist/{EntityTablePage-BiVoVAhN.js → EntityTablePage-CfLq5znM.js} +2 -2
- package/dist/{ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-BdL5cQgN.js → ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-CB_4eJz9.js} +1 -1
- package/dist/{MapSettings-CXqiYxV4.js → MapSettings-fwcVWgdK.js} +2 -2
- package/dist/{MapToolbarRight.vue_vue_type_script_setup_true_lang-BHCChxmg.js → MapToolbarRight.vue_vue_type_script_setup_true_lang-BWqBARGq.js} +1 -1
- package/dist/{RastersTablePage-Dgk1wp3d.js → RastersTablePage-XHV40tf_.js} +2 -2
- package/dist/{cartocss-BIpgQU6F.js → cartocss-BjGlng_r.js} +526 -503
- package/dist/{import-utils-CfXKgZFd.js → import-utils-WfWvX9B5.js} +1 -1
- package/dist/{index-CM_DTEUa.js → index-CDy0MSfg.js} +3509 -3461
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +42 -48
- package/dist/{raster-D_vEBha8.js → raster-D2X_jR9m.js} +3 -3
- package/dist/{register-C5_Un1Ms.js → register-Ctn9pgUE.js} +3 -3
- package/dist/service-CiUwLEwY.js +3484 -0
- package/dist/{vs-datatable--K-DxayK.js → vs-datatable-BixMLOv-.js} +4 -3
- package/module/gis/card/gis.metadata.table/index.yml +22 -22
- package/module/gis/card/gis.rasters.table/index.yml +11 -11
- package/module/gis/card/gis.registers.table/index.yml +23 -23
- package/module/gis/card/gis.services.table/index.yml +25 -25
- package/module/gis/cls/bool.yes_no.json +12 -12
- package/module/gis/cls/encoding.json +14 -14
- package/module/gis/cls/geom_type.json +14 -14
- package/module/gis/cls/gis.column_type.json +34 -34
- package/module/gis/cls/gis.column_view_type.json +26 -26
- package/module/gis/cls/gis.filter_type.json +22 -22
- package/module/gis/cls/language.json +10 -10
- package/module/gis/cls/meta.service_type.json +42 -42
- package/module/gis/cls/ogc.service.json +21 -21
- package/module/gis/cls/service_type.json +42 -42
- package/module/gis/cls/source_type.json +10 -10
- package/module/gis/cls/standarts.json +6 -6
- package/module/gis/cls/topic_category.json +106 -106
- package/module/gis/cls/update_frequency.json +29 -29
- package/module/gis/cls/view.json +21 -21
- package/module/gis/form/feedback.answer.form.json +10 -10
- package/module/gis/form/gis.cartocss.form.json +64 -64
- package/module/gis/form/gis.group_list.form.json +17 -17
- package/module/gis/form/gis.maps.form.json +61 -61
- package/module/gis/form/gis.metadata.form.json +240 -240
- package/module/gis/form/gis.metadata_new.form.json +195 -195
- package/module/gis/form/gis.ogc_service.form.json +51 -51
- package/module/gis/form/gis.rasters.form.json +76 -76
- package/module/gis/form/gis.registers.form.json +127 -127
- package/module/gis/form/gis.registers_column.form.json +84 -84
- package/module/gis/form/gis.registers_filter.form.json +65 -65
- package/module/gis/form/gis.services.form.json +111 -111
- package/module/gis/form/gis.services_attributes.form.json +75 -75
- package/module/gis/form/gis.services_filter.form.json +65 -65
- package/module/gis/menu.json +43 -43
- package/module/gis/select/admin.cls.name.sql +9 -9
- package/module/gis/select/layer_list.sql +7 -7
- package/module/gis/select/layer_list_text.sql +7 -7
- package/module/gis/select/pg.column_name.geometry.sql +12 -12
- package/module/gis/select/pg.columns.parent.sql +6 -6
- package/module/gis/select/pg.table_name.sql +17 -17
- package/module/gis/select/service_id.sql +1 -1
- package/module/gis/select/srid.sql +7 -7
- package/module/gis/table/gis.cartocss.table.json +74 -74
- package/module/gis/table/gis.group_list.table.json +58 -58
- package/module/gis/table/gis.maps.table.json +110 -110
- package/module/gis/table/gis.metadata.table.json +70 -70
- package/module/gis/table/gis.metadata_new.table.json +137 -137
- package/module/gis/table/gis.ogc_service.table.json +100 -100
- package/module/gis/table/gis.rasters.table.json +113 -113
- package/module/gis/table/gis.registers.table.json +143 -143
- package/module/gis/table/gis.services.table.json +120 -120
- package/module/gis/table/site.gis.registers.table.json +88 -88
- package/module/gis/table/site.gis.services.table.json +106 -106
- package/module/gis/templates/ISO19136_2017_gml_template.xml +330 -330
- package/module/gis/tokens.yml +5 -5
- package/module/permissions/form/permissions.users.form.json +151 -151
- package/module/permissions/table/gis.permissions.table.json +97 -97
- 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 +79 -79
- 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 +248 -248
- 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 +76 -76
- 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/fonts/index.js +1933 -1933
- 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 +327 -327
- package/server/routes/map/functions/jsonData.js +206 -206
- package/server/routes/map/functions/layerList.js +144 -144
- 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 +246 -246
- 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 +191 -191
- package/server/routes/map/map.route.js +283 -283
- package/server/routes/map/map.route.test.js +693 -693
- 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 +328 -328
- package/server/routes/registers/functions/getFilterSQLParametrized/getFilterQuery.js +126 -126
- package/server/routes/registers/functions/getFilterSQLParametrized/getRangeQuery.js +353 -353
- package/server/routes/registers/functions/getFilterSQLParametrized/index.js +81 -81
- package/server/routes/registers/functions/getTableColumnMeta.js +148 -148
- 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 +310 -310
- package/server/routes/registers/functions/handleRegistryRequest.js +178 -178
- package/server/routes/registers/functions/map.registry.js +87 -87
- package/server/routes/registers/registers.route.js +92 -92
- package/server/routes/registers/registers.route.test.js +173 -173
- package/server/routes/registers/registers.schema.js +276 -276
- 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 +124 -124
- 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 +171 -171
- package/server/routes/services/services.schema.js +459 -459
- 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
- package/dist/service-JN82JN81.js +0 -3676
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { BadRequestError, UnauthorizedError } from "@opengis/fastify-table/errors.js";
|
|
2
|
-
import { dataInsert, dataUpdate, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
|
-
|
|
4
|
-
export default async function addWidget({
|
|
5
|
-
method, id, map, body, uid,
|
|
6
|
-
}, pg = pgClients.client) {
|
|
7
|
-
if (!uid) {
|
|
8
|
-
throw UnauthorizedError('unauthorized');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (!map) {
|
|
12
|
-
throw BadRequestError('not enough params: map id');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (method === 'PUT' && !id) {
|
|
16
|
-
throw BadRequestError('not enough params: id');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (method === 'POST') {
|
|
20
|
-
Object.assign(body, { map_id: map });
|
|
21
|
-
const row = await dataInsert({
|
|
22
|
-
pg,
|
|
23
|
-
id,
|
|
24
|
-
table: 'gis.widgets',
|
|
25
|
-
data: body,
|
|
26
|
-
uid,
|
|
27
|
-
}).then(r => r.rows[0]);
|
|
28
|
-
return row;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const row = await dataUpdate({
|
|
32
|
-
pg,
|
|
33
|
-
id,
|
|
34
|
-
table: 'gis.widgets',
|
|
35
|
-
data: body,
|
|
36
|
-
uid,
|
|
37
|
-
});
|
|
38
|
-
return row;
|
|
1
|
+
import { BadRequestError, UnauthorizedError } from "@opengis/fastify-table/errors.js";
|
|
2
|
+
import { dataInsert, dataUpdate, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
|
+
|
|
4
|
+
export default async function addWidget({
|
|
5
|
+
method, id, map, body, uid,
|
|
6
|
+
}, pg = pgClients.client) {
|
|
7
|
+
if (!uid) {
|
|
8
|
+
throw UnauthorizedError('unauthorized');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (!map) {
|
|
12
|
+
throw BadRequestError('not enough params: map id');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (method === 'PUT' && !id) {
|
|
16
|
+
throw BadRequestError('not enough params: id');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (method === 'POST') {
|
|
20
|
+
Object.assign(body, { map_id: map });
|
|
21
|
+
const row = await dataInsert({
|
|
22
|
+
pg,
|
|
23
|
+
id,
|
|
24
|
+
table: 'gis.widgets',
|
|
25
|
+
data: body,
|
|
26
|
+
uid,
|
|
27
|
+
}).then(r => r.rows[0]);
|
|
28
|
+
return row;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const row = await dataUpdate({
|
|
32
|
+
pg,
|
|
33
|
+
id,
|
|
34
|
+
table: 'gis.widgets',
|
|
35
|
+
data: body,
|
|
36
|
+
uid,
|
|
37
|
+
});
|
|
38
|
+
return row;
|
|
39
39
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { UnauthorizedError } from "@opengis/fastify-table/errors.js";
|
|
2
|
-
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
|
-
|
|
4
|
-
export default async function delWidget({
|
|
5
|
-
id, uid,
|
|
6
|
-
}, pg = pgClients.client) {
|
|
7
|
-
if (!uid) {
|
|
8
|
-
throw UnauthorizedError('unauthorized');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const row = await dataDelete({
|
|
12
|
-
pg,
|
|
13
|
-
id,
|
|
14
|
-
table: 'gis.widgets',
|
|
15
|
-
uid,
|
|
16
|
-
});
|
|
17
|
-
return row;
|
|
1
|
+
import { UnauthorizedError } from "@opengis/fastify-table/errors.js";
|
|
2
|
+
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
|
+
|
|
4
|
+
export default async function delWidget({
|
|
5
|
+
id, uid,
|
|
6
|
+
}, pg = pgClients.client) {
|
|
7
|
+
if (!uid) {
|
|
8
|
+
throw UnauthorizedError('unauthorized');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const row = await dataDelete({
|
|
12
|
+
pg,
|
|
13
|
+
id,
|
|
14
|
+
table: 'gis.widgets',
|
|
15
|
+
uid,
|
|
16
|
+
});
|
|
17
|
+
return row;
|
|
18
18
|
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { BadRequestError, NotFoundError } from "@opengis/fastify-table/errors.js";
|
|
2
|
-
import { getMeta, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
|
-
|
|
4
|
-
const table = 'gis.widgets';
|
|
5
|
-
|
|
6
|
-
const columnType = {
|
|
7
|
-
text: 'text',
|
|
8
|
-
date: 'date',
|
|
9
|
-
bool: 'yes/no',
|
|
10
|
-
numeric: 'number',
|
|
11
|
-
integer: 'number',
|
|
12
|
-
'timestamp without time zone': 'date',
|
|
13
|
-
'timestamp with time zone': 'date',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default async function getWidget({ map, id }, pg = pgClients.client) {
|
|
17
|
-
if (!map) {
|
|
18
|
-
throw BadRequestError('not enough params: map id');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { columns = [] } = await getMeta({ pg, table }) || {};
|
|
22
|
-
|
|
23
|
-
const fields = columns.map(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'], label: title || name }));
|
|
24
|
-
|
|
25
|
-
const rows = pg.pk?.['gis.maps'] && pg.pk?.['gis.widgets'] ? await pg.query(
|
|
26
|
-
`SELECT widget_id as id, * FROM gis.widgets where map_id=$1 and ${id ? 'widget_id=$2' : '1=1'}`,
|
|
27
|
-
[map, id].filter(Boolean),
|
|
28
|
-
).then(el => el.rows || []) : [];
|
|
29
|
-
|
|
30
|
-
if (id && !rows.length) {
|
|
31
|
-
throw NotFoundError('widget not found');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (id) {
|
|
35
|
-
return { ...rows[0], fields };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
rows,
|
|
40
|
-
fields,
|
|
41
|
-
};
|
|
1
|
+
import { BadRequestError, NotFoundError } from "@opengis/fastify-table/errors.js";
|
|
2
|
+
import { getMeta, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
|
+
|
|
4
|
+
const table = 'gis.widgets';
|
|
5
|
+
|
|
6
|
+
const columnType = {
|
|
7
|
+
text: 'text',
|
|
8
|
+
date: 'date',
|
|
9
|
+
bool: 'yes/no',
|
|
10
|
+
numeric: 'number',
|
|
11
|
+
integer: 'number',
|
|
12
|
+
'timestamp without time zone': 'date',
|
|
13
|
+
'timestamp with time zone': 'date',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default async function getWidget({ map, id }, pg = pgClients.client) {
|
|
17
|
+
if (!map) {
|
|
18
|
+
throw BadRequestError('not enough params: map id');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { columns = [] } = await getMeta({ pg, table }) || {};
|
|
22
|
+
|
|
23
|
+
const fields = columns.map(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'], label: title || name }));
|
|
24
|
+
|
|
25
|
+
const rows = pg.pk?.['gis.maps'] && pg.pk?.['gis.widgets'] ? await pg.query(
|
|
26
|
+
`SELECT widget_id as id, * FROM gis.widgets where map_id=$1 and ${id ? 'widget_id=$2' : '1=1'}`,
|
|
27
|
+
[map, id].filter(Boolean),
|
|
28
|
+
).then(el => el.rows || []) : [];
|
|
29
|
+
|
|
30
|
+
if (id && !rows.length) {
|
|
31
|
+
throw NotFoundError('widget not found');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (id) {
|
|
35
|
+
return { ...rows[0], fields };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
rows,
|
|
40
|
+
fields,
|
|
41
|
+
};
|
|
42
42
|
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import getWidget from './functions/get.widget.js';
|
|
2
|
-
import addWidget from './functions/add.widget.js';
|
|
3
|
-
import delWidget from './functions/del.widget.js';
|
|
4
|
-
|
|
5
|
-
import { schemaInfo } from './widgets.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-widget/:map/:id?' })) {
|
|
20
|
-
app.get('/gis-widget/:map/:id?', publicParams, async ({ params, pg }) => {
|
|
21
|
-
const result = await getWidget({
|
|
22
|
-
id: params.id,
|
|
23
|
-
map: params.map
|
|
24
|
-
}, pg);
|
|
25
|
-
return result;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if (!app.hasRoute({ method: 'POST', url: '/gis-widget/:map/:id?' })) {
|
|
29
|
-
app.post('/gis-widget/:map/:id?', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
30
|
-
const result = await addWidget({
|
|
31
|
-
method,
|
|
32
|
-
id: params.id,
|
|
33
|
-
map: params.map,
|
|
34
|
-
body,
|
|
35
|
-
uid: user?.uid
|
|
36
|
-
}, pg);
|
|
37
|
-
return result;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (!app.hasRoute({ method: 'PUT', url: '/gis-widget/:map/:id' })) {
|
|
41
|
-
app.put('/gis-widget/:map/:id', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
42
|
-
const result = await addWidget({
|
|
43
|
-
method,
|
|
44
|
-
id: params.id,
|
|
45
|
-
map: params.map,
|
|
46
|
-
body,
|
|
47
|
-
uid: user?.uid
|
|
48
|
-
}, pg);
|
|
49
|
-
return result;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (!app.hasRoute({ method: 'DELETE', url: '/gis-widget/:map/:id' })) {
|
|
53
|
-
app.delete('/gis-widget/:map/:id', privilegedParams, async ({ params, user, pg }) => {
|
|
54
|
-
const result = await delWidget({
|
|
55
|
-
id: params.id,
|
|
56
|
-
uid: user?.uid
|
|
57
|
-
}, pg);
|
|
58
|
-
return result;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
import getWidget from './functions/get.widget.js';
|
|
2
|
+
import addWidget from './functions/add.widget.js';
|
|
3
|
+
import delWidget from './functions/del.widget.js';
|
|
4
|
+
|
|
5
|
+
import { schemaInfo } from './widgets.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-widget/:map/:id?' })) {
|
|
20
|
+
app.get('/gis-widget/:map/:id?', publicParams, async ({ params, pg }) => {
|
|
21
|
+
const result = await getWidget({
|
|
22
|
+
id: params.id,
|
|
23
|
+
map: params.map
|
|
24
|
+
}, pg);
|
|
25
|
+
return result;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (!app.hasRoute({ method: 'POST', url: '/gis-widget/:map/:id?' })) {
|
|
29
|
+
app.post('/gis-widget/:map/:id?', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
30
|
+
const result = await addWidget({
|
|
31
|
+
method,
|
|
32
|
+
id: params.id,
|
|
33
|
+
map: params.map,
|
|
34
|
+
body,
|
|
35
|
+
uid: user?.uid
|
|
36
|
+
}, pg);
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (!app.hasRoute({ method: 'PUT', url: '/gis-widget/:map/:id' })) {
|
|
41
|
+
app.put('/gis-widget/:map/:id', privilegedParams, async ({ method, body, params, user, pg }) => {
|
|
42
|
+
const result = await addWidget({
|
|
43
|
+
method,
|
|
44
|
+
id: params.id,
|
|
45
|
+
map: params.map,
|
|
46
|
+
body,
|
|
47
|
+
uid: user?.uid
|
|
48
|
+
}, pg);
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!app.hasRoute({ method: 'DELETE', url: '/gis-widget/:map/:id' })) {
|
|
53
|
+
app.delete('/gis-widget/:map/:id', privilegedParams, async ({ params, user, pg }) => {
|
|
54
|
+
const result = await delWidget({
|
|
55
|
+
id: params.id,
|
|
56
|
+
uid: user?.uid
|
|
57
|
+
}, pg);
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,144 +1,144 @@
|
|
|
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,
|
|
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
|
-
const cleanUp = async (when) => {
|
|
22
|
-
if (!pg) return;
|
|
23
|
-
const { rowCount: widgets } = await pg.query('delete from gis.widgets where (map_id like $1 or widget_id like $1)', [`${testKey}%`]);
|
|
24
|
-
console.log(`clean up widgets ${when}:`, widgets);
|
|
25
|
-
const { rowCount: maps } = await pg.query('delete from gis.maps where array[$1] && keywords', [testKey]);
|
|
26
|
-
console.log(`clean up maps ${when}:`, maps);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('maps api test', () => {
|
|
30
|
-
beforeAll(async () => {
|
|
31
|
-
await build();
|
|
32
|
-
pg = await getPGAsync();
|
|
33
|
-
// ensure not exists in case previous test fails / timeouts
|
|
34
|
-
await cleanUp('before');
|
|
35
|
-
|
|
36
|
-
await pg.query(
|
|
37
|
-
'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 *',
|
|
38
|
-
[testKey, user.uid, [30, 50]],
|
|
39
|
-
);
|
|
40
|
-
console.log('insert before success');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
afterAll(async () => {
|
|
44
|
-
await cleanUp('after');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const name = [testKey, randomUUID()].join('-');
|
|
48
|
-
|
|
49
|
-
test('POST /gis-widget/:map/:id?', async () => {
|
|
50
|
-
const res = await injectWithHeaders({
|
|
51
|
-
method: 'POST',
|
|
52
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
53
|
-
payload: {
|
|
54
|
-
type: 'card1',
|
|
55
|
-
},
|
|
56
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
57
|
-
});
|
|
58
|
-
expect(res.statusCode).toBe(200);
|
|
59
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
60
|
-
const json = res.json();
|
|
61
|
-
expect(json).toHaveProperty('map_id');
|
|
62
|
-
expect(json.map_id).toBe(testKey);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('GET /gis-widget/:map/:id', async () => {
|
|
66
|
-
const res = await injectWithHeaders({
|
|
67
|
-
method: 'GET',
|
|
68
|
-
url: `/api/gis-widget/${testKey}`,
|
|
69
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
70
|
-
});
|
|
71
|
-
expect(res.statusCode).toBe(200);
|
|
72
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
73
|
-
const json = res.json();
|
|
74
|
-
Object.assign(obj, { 'GET/gis-widget/:map': json });
|
|
75
|
-
expect(json).toHaveProperty('rows');
|
|
76
|
-
expect(json).toHaveProperty('fields');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('GET /gis-widget/:map/:id', async () => {
|
|
80
|
-
/*await dataInsert({
|
|
81
|
-
table: 'gis.widgets',
|
|
82
|
-
id: name,
|
|
83
|
-
data: {
|
|
84
|
-
widget_id: name,
|
|
85
|
-
map_id: testKey,
|
|
86
|
-
type: 'card',
|
|
87
|
-
title: name,
|
|
88
|
-
config: {
|
|
89
|
-
items: [{
|
|
90
|
-
label: 'Карта тимчасових споруд',
|
|
91
|
-
url: '/map/ts',
|
|
92
|
-
}],
|
|
93
|
-
},
|
|
94
|
-
position: 'top-right',
|
|
95
|
-
},
|
|
96
|
-
uid: '1',
|
|
97
|
-
});*/
|
|
98
|
-
const res = await injectWithHeaders({
|
|
99
|
-
method: 'GET',
|
|
100
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
101
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
102
|
-
});
|
|
103
|
-
expect(res.statusCode).toBe(200);
|
|
104
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
105
|
-
const json = res.json();
|
|
106
|
-
Object.assign(obj, { 'GET/gis-widget/:map/:id': json });
|
|
107
|
-
expect(json).toHaveProperty('widget_id');
|
|
108
|
-
expect(json).toHaveProperty('type');
|
|
109
|
-
expect(json).toHaveProperty('title');
|
|
110
|
-
expect(json).toHaveProperty('config');
|
|
111
|
-
expect(json).toHaveProperty('position');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test('PUT /gis-widget/:map/:id', async () => {
|
|
115
|
-
const res = await injectWithHeaders({
|
|
116
|
-
method: 'PUT',
|
|
117
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
118
|
-
payload: {
|
|
119
|
-
type: 'card1',
|
|
120
|
-
},
|
|
121
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
122
|
-
});
|
|
123
|
-
expect(res.statusCode).toBe(200);
|
|
124
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
125
|
-
const json = res.json();
|
|
126
|
-
Object.assign(obj, { 'PUT/gis-widget/:map/:id': json });
|
|
127
|
-
expect(json).toHaveProperty('map_id');
|
|
128
|
-
expect(json.map_id).toBe(testKey);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('DELETE /gis-widget/:map/:id', async () => {
|
|
132
|
-
const res = await injectWithHeaders({
|
|
133
|
-
method: 'DELETE',
|
|
134
|
-
url: `/api/gis-widget/${testKey}/${name}`,
|
|
135
|
-
headers: { uid: user.uid, user_type: user.user_type }
|
|
136
|
-
});
|
|
137
|
-
expect(res.statusCode).toBe(200);
|
|
138
|
-
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
139
|
-
const json = res.json();
|
|
140
|
-
Object.assign(obj, { 'DELETE/gis-widget/:map/:id': json });
|
|
141
|
-
expect(json).toHaveProperty('map_id');
|
|
142
|
-
expect(json.map_id).toBe(testKey);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
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,
|
|
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
|
+
const cleanUp = async (when) => {
|
|
22
|
+
if (!pg) return;
|
|
23
|
+
const { rowCount: widgets } = await pg.query('delete from gis.widgets where (map_id like $1 or widget_id like $1)', [`${testKey}%`]);
|
|
24
|
+
console.log(`clean up widgets ${when}:`, widgets);
|
|
25
|
+
const { rowCount: maps } = await pg.query('delete from gis.maps where array[$1] && keywords', [testKey]);
|
|
26
|
+
console.log(`clean up maps ${when}:`, maps);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('maps api test', () => {
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
await build();
|
|
32
|
+
pg = await getPGAsync();
|
|
33
|
+
// ensure not exists in case previous test fails / timeouts
|
|
34
|
+
await cleanUp('before');
|
|
35
|
+
|
|
36
|
+
await pg.query(
|
|
37
|
+
'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 *',
|
|
38
|
+
[testKey, user.uid, [30, 50]],
|
|
39
|
+
);
|
|
40
|
+
console.log('insert before success');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterAll(async () => {
|
|
44
|
+
await cleanUp('after');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const name = [testKey, randomUUID()].join('-');
|
|
48
|
+
|
|
49
|
+
test('POST /gis-widget/:map/:id?', async () => {
|
|
50
|
+
const res = await injectWithHeaders({
|
|
51
|
+
method: 'POST',
|
|
52
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
53
|
+
payload: {
|
|
54
|
+
type: 'card1',
|
|
55
|
+
},
|
|
56
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
57
|
+
});
|
|
58
|
+
expect(res.statusCode).toBe(200);
|
|
59
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
60
|
+
const json = res.json();
|
|
61
|
+
expect(json).toHaveProperty('map_id');
|
|
62
|
+
expect(json.map_id).toBe(testKey);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('GET /gis-widget/:map/:id', async () => {
|
|
66
|
+
const res = await injectWithHeaders({
|
|
67
|
+
method: 'GET',
|
|
68
|
+
url: `/api/gis-widget/${testKey}`,
|
|
69
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
70
|
+
});
|
|
71
|
+
expect(res.statusCode).toBe(200);
|
|
72
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
73
|
+
const json = res.json();
|
|
74
|
+
Object.assign(obj, { 'GET/gis-widget/:map': json });
|
|
75
|
+
expect(json).toHaveProperty('rows');
|
|
76
|
+
expect(json).toHaveProperty('fields');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('GET /gis-widget/:map/:id', async () => {
|
|
80
|
+
/*await dataInsert({
|
|
81
|
+
table: 'gis.widgets',
|
|
82
|
+
id: name,
|
|
83
|
+
data: {
|
|
84
|
+
widget_id: name,
|
|
85
|
+
map_id: testKey,
|
|
86
|
+
type: 'card',
|
|
87
|
+
title: name,
|
|
88
|
+
config: {
|
|
89
|
+
items: [{
|
|
90
|
+
label: 'Карта тимчасових споруд',
|
|
91
|
+
url: '/map/ts',
|
|
92
|
+
}],
|
|
93
|
+
},
|
|
94
|
+
position: 'top-right',
|
|
95
|
+
},
|
|
96
|
+
uid: '1',
|
|
97
|
+
});*/
|
|
98
|
+
const res = await injectWithHeaders({
|
|
99
|
+
method: 'GET',
|
|
100
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
101
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
102
|
+
});
|
|
103
|
+
expect(res.statusCode).toBe(200);
|
|
104
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
105
|
+
const json = res.json();
|
|
106
|
+
Object.assign(obj, { 'GET/gis-widget/:map/:id': json });
|
|
107
|
+
expect(json).toHaveProperty('widget_id');
|
|
108
|
+
expect(json).toHaveProperty('type');
|
|
109
|
+
expect(json).toHaveProperty('title');
|
|
110
|
+
expect(json).toHaveProperty('config');
|
|
111
|
+
expect(json).toHaveProperty('position');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('PUT /gis-widget/:map/:id', async () => {
|
|
115
|
+
const res = await injectWithHeaders({
|
|
116
|
+
method: 'PUT',
|
|
117
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
118
|
+
payload: {
|
|
119
|
+
type: 'card1',
|
|
120
|
+
},
|
|
121
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
122
|
+
});
|
|
123
|
+
expect(res.statusCode).toBe(200);
|
|
124
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
125
|
+
const json = res.json();
|
|
126
|
+
Object.assign(obj, { 'PUT/gis-widget/:map/:id': json });
|
|
127
|
+
expect(json).toHaveProperty('map_id');
|
|
128
|
+
expect(json.map_id).toBe(testKey);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('DELETE /gis-widget/:map/:id', async () => {
|
|
132
|
+
const res = await injectWithHeaders({
|
|
133
|
+
method: 'DELETE',
|
|
134
|
+
url: `/api/gis-widget/${testKey}/${name}`,
|
|
135
|
+
headers: { uid: user.uid, user_type: user.user_type }
|
|
136
|
+
});
|
|
137
|
+
expect(res.statusCode).toBe(200);
|
|
138
|
+
expect(res.headers['content-type']).toBe('application/json; charset=utf-8');
|
|
139
|
+
const json = res.json();
|
|
140
|
+
Object.assign(obj, { 'DELETE/gis-widget/:map/:id': json });
|
|
141
|
+
expect(json).toHaveProperty('map_id');
|
|
142
|
+
expect(json.map_id).toBe(testKey);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export const schemaInfo = {
|
|
2
|
-
params: {
|
|
3
|
-
type: 'object',
|
|
4
|
-
properties: {
|
|
5
|
-
slug: {
|
|
6
|
-
type: 'string',
|
|
7
|
-
},
|
|
8
|
-
z: {
|
|
9
|
-
type: 'number',
|
|
10
|
-
},
|
|
11
|
-
y: {
|
|
12
|
-
type: 'number',
|
|
13
|
-
},
|
|
14
|
-
x: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
pattern: '^\\d+\\.(pbf|vmt)$',
|
|
17
|
-
},
|
|
18
|
-
id: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
1
|
+
export const schemaInfo = {
|
|
2
|
+
params: {
|
|
3
|
+
type: 'object',
|
|
4
|
+
properties: {
|
|
5
|
+
slug: {
|
|
6
|
+
type: 'string',
|
|
7
|
+
},
|
|
8
|
+
z: {
|
|
9
|
+
type: 'number',
|
|
10
|
+
},
|
|
11
|
+
y: {
|
|
12
|
+
type: 'number',
|
|
13
|
+
},
|
|
14
|
+
x: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
pattern: '^\\d+\\.(pbf|vmt)$',
|
|
17
|
+
},
|
|
18
|
+
id: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
25
|
export default null;
|