@opengis/gis 0.2.167 → 0.2.169
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/{CardIcon-golqfa-Y.js → CardIcon-xkRDr3_E.js} +1 -1
- package/dist/{EntityTablePage-BhmxePgR.js → EntityTablePage-D1IR5Bmq.js} +1 -1
- package/dist/{ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-BFa27smR.js → ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-BJKIgAkD.js} +1 -1
- package/dist/{HeaderActions.vue_vue_type_script_setup_true_lang-Dp0MjgnU.js → HeaderActions.vue_vue_type_script_setup_true_lang-BU8__ouG.js} +1 -1
- package/dist/{MapSettings-F_DT3xKl.js → MapSettings-DIOlNpt6.js} +1 -1
- package/dist/{RastersTablePage-3rXQ0baG.js → RastersTablePage-OD1VqHP8.js} +1 -1
- package/dist/{cartocss-CN-UrS7V.js → cartocss-BiamDcNB.js} +5 -5
- package/dist/{import-utils-F5ErbNz1.js → import-utils-CvUG1jV0.js} +1 -1
- package/dist/{index-CdB0VXro.js → index-C6W8IkTm.js} +1224 -1221
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +53 -40
- package/dist/{raster-DWmiWlf7.js → raster-BbIiZGoX.js} +3 -3
- package/dist/{register-D1jLD0hK.js → register-Dt2QoLZ3.js} +3 -3
- package/dist/service-CdUYntMi.js +3472 -0
- package/dist/{vs-datatable-BWItxbtK.js → vs-datatable-BELnJrfM.js} +2 -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/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 +124 -124
- 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 +303 -0
- package/module/test/map/{addr.yml → addr1.yml} +3 -1
- package/module/test/select/address.str_id.sql +3 -0
- package/package.json +10 -10
- package/plugin.js +21 -12
- package/server/plugins/mapnik/funcs/checkRasterFile.js +1 -3
- package/server/routes/cartocss/cartocss.route.js +31 -0
- package/server/routes/cartocss/cartocss.route.test.js +79 -0
- package/server/routes/cartocss/cartocss.schema.js +73 -0
- package/server/routes/{gis/cartocss → cartocss/functions}/add.cartocss.js +8 -11
- package/server/routes/{gis/cartocss → cartocss/functions}/get.cartocss.js +11 -13
- package/server/routes/gis/functions/checkXML.js +107 -0
- package/server/routes/gis/functions/dashboard.js +24 -0
- package/server/routes/gis/gis.route.js +26 -0
- package/server/routes/gis/gis.route.test.js +34 -0
- package/server/routes/gis/gis.schema.js +1 -0
- package/server/routes/map/{controllers → functions}/clearTiles.js +9 -8
- package/server/routes/map/{controllers → functions}/geojson.js +43 -43
- package/server/routes/map/{controllers → functions}/gis.convert.js +15 -23
- package/server/routes/map/{controllers → functions}/gis.icon.js +23 -10
- package/server/routes/map/{controllers → functions}/jsonData.js +72 -71
- package/server/routes/map/{controllers → functions}/layerList.js +17 -17
- package/server/routes/map/{controllers → functions}/map.js +8 -9
- package/server/routes/map/{controllers → functions}/mapCatalog.js +7 -7
- package/server/routes/map/functions/mapCatalogAttribute.js +54 -0
- package/server/routes/map/{controllers → functions}/mapFeatures.js +22 -18
- package/server/routes/map/{controllers → functions}/mapFormat.js +25 -28
- package/server/routes/map/{controllers → functions}/mapTiles.js +39 -30
- package/server/routes/map/{controllers → functions}/maps.js +3 -3
- package/server/routes/map/{controllers → functions}/marker_icon.js +1 -1
- package/server/routes/map/{controllers → functions}/parseGeoFile.js +10 -11
- package/server/routes/map/{controllers → functions}/pointHeight.js +3 -7
- package/server/routes/map/{controllers → functions}/vtile.js +5 -3
- package/server/routes/map/{vtile1.js → functions/vtile1.js} +39 -33
- package/server/routes/map/map.route.js +280 -0
- package/server/routes/map/map.route.test.js +503 -0
- package/server/routes/map/map.schema.js +356 -0
- package/server/routes/mapnik/{controllers → functions}/clearTiles.js +26 -29
- package/server/routes/mapnik/{controllers → functions}/createXml.js +17 -20
- package/server/routes/mapnik/{controllers → functions}/createXmlMulti.js +11 -15
- package/server/routes/mapnik/{controllers → functions}/fileSearch.js +6 -9
- package/server/routes/mapnik/functions/fileStat.js +28 -0
- package/server/routes/mapnik/{controllers → functions}/pretile.js +29 -35
- package/server/routes/mapnik/{controllers → functions}/rasterInfo.js +19 -10
- package/server/routes/mapnik/{controllers → functions}/readDir.js +4 -4
- package/server/routes/mapnik/functions/rtile.js +164 -0
- package/server/routes/mapnik/{controllers → functions}/uploadRaster.js +19 -24
- package/server/routes/mapnik/functions/uploadXML.js +27 -0
- package/server/routes/mapnik/mapnik.route.js +102 -0
- package/server/routes/mapnik/mapnik.route.test.js +371 -0
- package/server/routes/mapnik/mapnik.schema.mjs +190 -0
- package/server/routes/mapnik.prefixless/functions/mapnikLogger.js +31 -0
- package/server/routes/{mapnik/controllers → mapnik.prefixless/functions}/mapnikStat.js +7 -5
- package/server/routes/mapnik.prefixless/mapnik.prefixless.route.js +20 -0
- package/server/routes/mapnik.prefixless/mapnik.prefixless.route.test.js +91 -0
- package/server/routes/mapnik.prefixless/mapnik.prefixless.schema.mjs +27 -0
- package/server/routes/maps/functions/add.map.js +42 -0
- package/server/routes/{map/maps → maps/functions}/del.map.js +6 -7
- package/server/routes/{map/maps → maps/functions}/get.map.js +12 -11
- package/server/routes/maps/maps.route.js +58 -0
- package/server/routes/maps/maps.route.test.js +231 -0
- package/server/routes/maps/maps.schema.js +10 -0
- package/server/routes/metadata/functions/editMetadata.js +35 -0
- package/server/routes/metadata/functions/metadataXML.js +19 -0
- package/server/routes/metadata/metadata.route.js +26 -0
- package/server/routes/metadata/metadata.route.test.js +47 -0
- package/server/routes/metadata/metadata.schema.js +53 -0
- package/server/routes/{gis/ogc → ogc/functions}/map.info.point.js +22 -29
- package/server/routes/ogc/ogc.route.js +21 -0
- package/server/routes/ogc/ogc.route.test.js +54 -0
- package/server/routes/ogc/ogc.schema.js +16 -0
- package/server/routes/permissions/functions/catalog.permissions.edit.js +20 -0
- package/server/routes/permissions/functions/catalog.permissions.js +13 -0
- package/server/routes/permissions/{controllers → functions}/gis.catalog.js +10 -10
- package/server/routes/permissions/permissions.route.js +35 -0
- package/server/routes/permissions/permissions.route.test.js +35 -0
- package/server/routes/permissions/permissions.schema.js +44 -0
- package/server/routes/registers/functions/add.registry.js +37 -0
- package/server/routes/{gis/registers/funcs → registers/functions}/classifiers.js +2 -2
- package/server/routes/{gis/registers → registers/functions}/del.registry.js +5 -5
- package/server/routes/{gis/registers/funcs → registers/functions}/get.info.js +9 -5
- package/server/routes/{gis/registers → registers/functions}/gis.export.js +27 -21
- package/server/routes/{gis/registers → registers/functions}/gis.registry.js +22 -15
- package/server/routes/{gis/registers → registers/functions}/gis.registry.list.js +12 -10
- package/server/routes/{gis/registers/funcs → registers/functions}/handleRegistryRequest.js +12 -11
- package/server/routes/registers/registers.route.js +80 -0
- package/server/routes/registers/registers.route.test.js +145 -0
- package/server/routes/registers/registers.schema.js +246 -0
- package/server/routes/{gis/services → services/functions}/add.service.js +14 -16
- package/server/routes/services/functions/create.route.js +93 -0
- package/server/routes/{gis/services → services/functions}/del.service.js +5 -5
- package/server/routes/{gis/services → services/functions}/get.service.users.js +15 -13
- package/server/routes/services/functions/get.services.col.js +34 -0
- package/server/routes/{gis/services → services/functions}/get.services.js +21 -16
- package/server/routes/services/services.route.js +76 -0
- package/server/routes/services/services.route.test.js +168 -0
- package/server/routes/services/services.schema.js +278 -0
- package/server/routes/widgets/functions/add.widget.js +39 -0
- package/server/routes/widgets/functions/del.widget.js +18 -0
- package/server/routes/{map/widgets → widgets/functions}/get.widget.js +12 -11
- package/server/routes/widgets/widgets.route.js +61 -0
- package/server/routes/widgets/widgets.route.test.js +144 -0
- package/server/routes/widgets/widgets.schema.js +25 -0
- package/dist/service-JGNtth-y.js +0 -2593
- package/module/cls.json +0 -7
- package/module/gis/card/gis.metadata.table/main_info.hbs +0 -21
- package/module/gis/card/gis.metadata.table/metadata_info.hbs +0 -28
- package/module/gis/card/gis.metadata.table/other.hbs +0 -26
- package/module/gis/card/gis.rasters.table/main_info.hbs +0 -27
- package/module/gis/card/gis.registers.table/cls.hbs +0 -36
- package/module/gis/card/gis.registers.table/columns.hbs +0 -89
- package/module/gis/card/gis.registers.table/filters.hbs +0 -80
- package/module/gis/card/gis.registers.table/main_info.hbs +0 -35
- package/module/gis/card/gis.registers.table/source.hbs +0 -45
- package/module/gis/card/gis.services.table/attributes.hbs +0 -91
- package/module/gis/card/gis.services.table/filters.hbs +0 -83
- package/module/gis/card/gis.services.table/main_info.hbs +0 -27
- package/module/gis/card/gis.services.table/source.hbs +0 -26
- package/module/test/cls/bp_build_type.json +0 -37
- package/module/test/cls/doc_status.json +0 -32
- package/module/test/cls/ts.temp_status.json +0 -18
- package/module/test/cls/ts.temp_structure.ts_class.json +0 -50
- package/module/test/cls/ts.temp_type.json +0 -10
- package/module/test/layer/bp.json +0 -60
- package/module/test/layer/bp1.yml +0 -33
- package/module/test/layer/individual.yml +0 -54
- package/module/test/layer/ts.linking_passport.yml +0 -56
- package/module/test/layer/ts.temp_structure.yml +0 -51
- package/module/test/map/bp_myo.json +0 -44
- package/module/test/map/bpf.json +0 -44
- package/module/test/map/main.json +0 -39
- package/module/test/map/mbd.json +0 -92
- package/module/test/map/ts.json +0 -53
- package/module/test/select/address_id.json +0 -3
- package/module/test/select/address_id.sql +0 -8
- package/module/test/select/core.user_uid.sql +0 -1
- package/module/test/table/data_address.street.table.json +0 -70
- package/module/test/table/data_bp_myo.bp.table.json +0 -123
- package/server/routes/gis/checkXML.js +0 -117
- package/server/routes/gis/dashboard.js +0 -29
- package/server/routes/gis/index.mjs +0 -92
- package/server/routes/gis/metadata/editMetadata.js +0 -34
- package/server/routes/gis/metadata/metadataXML.js +0 -13
- package/server/routes/gis/registers/add.registry.js +0 -35
- package/server/routes/gis/registers/insert.columns.js +0 -107
- package/server/routes/gis/registers/insert.filters.js +0 -110
- package/server/routes/gis/services/create.route.js +0 -96
- package/server/routes/gis/services/get.services.col.js +0 -33
- package/server/routes/map/controllers/mapCatalogAttribute.js +0 -56
- package/server/routes/map/index.mjs +0 -259
- package/server/routes/map/maps/add.map.js +0 -43
- package/server/routes/map/widgets/add.widget.js +0 -39
- package/server/routes/map/widgets/del.widget.js +0 -23
- package/server/routes/mapnik/controllers/fileStat.js +0 -28
- package/server/routes/mapnik/controllers/mapnikLogger.js +0 -29
- package/server/routes/mapnik/controllers/rtile.js +0 -167
- package/server/routes/mapnik/index.js +0 -40
- package/server/routes/permissions/controllers/catalog.permissions.edit.js +0 -22
- package/server/routes/permissions/controllers/catalog.permissions.js +0 -8
- package/server/routes/permissions/index.mjs +0 -18
- /package/server/routes/map/{controllers/pin → pin}/circle1.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/circle2.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/none.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin1.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin2.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin3.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin4.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin5.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin6.svg +0 -0
- /package/server/routes/map/{controllers/pin → pin}/pin7.svg +0 -0
- /package/server/routes/permissions/{controllers/utils → functions}/get.permissions.js +0 -0
- /package/server/routes/{gis/registers/funcs → registers/functions}/columns.js +0 -0
- /package/server/routes/{gis/registers/funcs → registers/functions}/content.type.js +0 -0
- /package/server/routes/{gis/registers → registers/functions}/map.registry.js +0 -0
- /package/server/routes/{gis/services → services/functions}/get.layer.geom.js +0 -0
- /package/server/routes/{gis/services → services/functions}/legend.auto.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BadRequestError } from "@opengis/fastify-table/errors.js";
|
|
1
2
|
import { dataDelete, dataInsert, dataUpdate, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
3
|
|
|
3
4
|
async function updateTemplate(client, body, uid, id) {
|
|
@@ -19,46 +20,43 @@ async function updateTemplate(client, body, uid, id) {
|
|
|
19
20
|
return rowCount;
|
|
20
21
|
}
|
|
21
22
|
export default async function addService({
|
|
22
|
-
method,
|
|
23
|
-
},
|
|
24
|
-
if (method === 'PUT' && !
|
|
25
|
-
|
|
23
|
+
method, id, body, uid = '0'
|
|
24
|
+
}, pg = pgClients.client) {
|
|
25
|
+
if (method === 'PUT' && !id) {
|
|
26
|
+
throw BadRequestError('not enough params: id');
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
const { uid = '0' } = user;
|
|
29
|
-
|
|
30
29
|
const client = await pg.connect();
|
|
31
30
|
try {
|
|
32
31
|
await client.query('begin');
|
|
33
32
|
|
|
34
33
|
if (method === 'POST') {
|
|
35
|
-
const
|
|
34
|
+
const row = await dataInsert({
|
|
36
35
|
pg: client,
|
|
37
|
-
id
|
|
36
|
+
id,
|
|
38
37
|
table: 'gis.services',
|
|
39
38
|
data: body,
|
|
40
39
|
uid,
|
|
41
|
-
});
|
|
42
|
-
|
|
40
|
+
}).then(r => r.rows[0]);
|
|
41
|
+
await updateTemplate(client, body.html, uid, row.service_id);
|
|
43
42
|
await client.query('commit');
|
|
44
|
-
return
|
|
43
|
+
return row;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
48
46
|
const row = await dataUpdate({
|
|
49
47
|
pg: client,
|
|
50
|
-
id
|
|
48
|
+
id,
|
|
51
49
|
table: 'gis.services',
|
|
52
50
|
data: body,
|
|
53
51
|
uid,
|
|
54
52
|
});
|
|
55
|
-
|
|
53
|
+
await updateTemplate(client, body.html, uid, id);
|
|
56
54
|
await client.query('commit');
|
|
57
|
-
return
|
|
55
|
+
return row;
|
|
58
56
|
|
|
59
57
|
} catch (err) {
|
|
60
58
|
await client.query('rollback');
|
|
61
|
-
|
|
59
|
+
throw err;
|
|
62
60
|
} finally {
|
|
63
61
|
client.release();
|
|
64
62
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const ROUTE_URL = process.env.ROUTE_URL || 'https://data.gki.com.ua/api/osrm-routes';
|
|
2
|
+
|
|
3
|
+
function parseCoordPair(raw) {
|
|
4
|
+
const [lngRaw, latRaw] = String(raw || '').split(',');
|
|
5
|
+
const lng = Number(lngRaw);
|
|
6
|
+
const lat = Number(latRaw);
|
|
7
|
+
|
|
8
|
+
if (
|
|
9
|
+
!Number.isFinite(lng)
|
|
10
|
+
|| !Number.isFinite(lat)
|
|
11
|
+
|| lng < -180
|
|
12
|
+
|| lng > 180
|
|
13
|
+
|| lat < -90
|
|
14
|
+
|| lat > 90
|
|
15
|
+
) {
|
|
16
|
+
throw new Error('invalid coordinate')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return [lng, lat];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function buildRoutePoints(from, to, via) {
|
|
23
|
+
const points = [parseCoordPair(from)];
|
|
24
|
+
if (via) {
|
|
25
|
+
for (const segment of String(via).split(';')) {
|
|
26
|
+
const trimmed = segment.trim();
|
|
27
|
+
if (trimmed) {
|
|
28
|
+
points.push(parseCoordPair(trimmed));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
points.push(parseCoordPair(to));
|
|
33
|
+
return points;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function routeOptionsQuery(query) {
|
|
37
|
+
const params = new URLSearchParams()
|
|
38
|
+
for (const key of ['optimize', 'surface', 'weight', 'mode']) {
|
|
39
|
+
const value = typeof query?.[key] === 'string' ? query[key].trim() : '';
|
|
40
|
+
if (value) {
|
|
41
|
+
params.set(key, value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const qs = params.toString();
|
|
45
|
+
return qs ? `&${qs}` : '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function buildSegmentsBody(points) {
|
|
49
|
+
const segments = [];
|
|
50
|
+
for (let i = 0; i < points.length - 1; i += 1) {
|
|
51
|
+
segments.push([
|
|
52
|
+
[points[i][0], points[i][1]],
|
|
53
|
+
[points[i + 1][0], points[i + 1][1]],
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
return JSON.stringify(segments);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default async function createRouteHandler({ from, to, via, mode, alternatives, steps, optimize, surface, weight }) {
|
|
60
|
+
const points = buildRoutePoints(from, to, via);
|
|
61
|
+
const query = { from, to, via, mode, alternatives, steps, optimize, surface, weight };
|
|
62
|
+
const url = `${ROUTE_URL}?steps=true&alternatives=true${routeOptionsQuery(query)}`;
|
|
63
|
+
|
|
64
|
+
const response = await fetch(url, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: {
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
Accept: 'application/json',
|
|
69
|
+
},
|
|
70
|
+
body: buildSegmentsBody(points),
|
|
71
|
+
signal: AbortSignal.timeout(10_000),
|
|
72
|
+
}).catch(error => ({
|
|
73
|
+
ok: false,
|
|
74
|
+
status: 502,
|
|
75
|
+
headers: new Headers({ 'content-type': 'application/json' }),
|
|
76
|
+
text: async () => JSON.stringify({ error: String(error), code: 502 }),
|
|
77
|
+
}))
|
|
78
|
+
|
|
79
|
+
const contentType = response.headers?.get?.('content-type') || 'application/json';
|
|
80
|
+
const text = await response.text();
|
|
81
|
+
|
|
82
|
+
let payload = text
|
|
83
|
+
|
|
84
|
+
if (contentType.includes('application/json')) {
|
|
85
|
+
try {
|
|
86
|
+
payload = text ? JSON.parse(text) : null
|
|
87
|
+
} catch {
|
|
88
|
+
payload = text
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return payload;
|
|
93
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
2
|
|
|
3
3
|
export default async function deleteService({
|
|
4
|
-
|
|
5
|
-
},
|
|
4
|
+
id, uid,
|
|
5
|
+
}, pg = pgClients.client) {
|
|
6
6
|
const row = await dataDelete({
|
|
7
7
|
pg,
|
|
8
|
-
id
|
|
8
|
+
id,
|
|
9
9
|
table: 'gis.services',
|
|
10
|
-
uid
|
|
10
|
+
uid,
|
|
11
11
|
});
|
|
12
|
-
return
|
|
12
|
+
return row;
|
|
13
13
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BadRequestError } from '@opengis/fastify-table/errors.js';
|
|
1
2
|
import { pgClients } from '@opengis/fastify-table/utils.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,7 +8,7 @@ import { pgClients } from '@opengis/fastify-table/utils.js';
|
|
|
7
8
|
* @summary Апі повертає перелік користувачів, які мають доступ до георесурсу
|
|
8
9
|
* @alias getServiceUsers
|
|
9
10
|
* @tag services
|
|
10
|
-
* @param {String}
|
|
11
|
+
* @param {String} id Ідентифікатор георесурсу (service_id)
|
|
11
12
|
* @param {Number} query.limit Кількість записів на сторінці (макс. 100, за замовчуванням 20)
|
|
12
13
|
* @param {Number} query.offset Зміщення для пагінації
|
|
13
14
|
* @param {String} query.search Текстовий пошук за прізвищем, іменем, по-батькові або логіном
|
|
@@ -15,13 +16,16 @@ import { pgClients } from '@opengis/fastify-table/utils.js';
|
|
|
15
16
|
*
|
|
16
17
|
* @example /api/gis-service-users/3054579335420708639?limit=8&offset=0
|
|
17
18
|
*/
|
|
18
|
-
export default async function getServiceUsers({
|
|
19
|
-
const
|
|
20
|
-
const limit = Math.min(parseInt(query.limit, 10) || 20, 100);
|
|
21
|
-
const offset = parseInt(query.offset, 10) || 0;
|
|
22
|
-
const search = query.search?.trim() || '';
|
|
19
|
+
export default async function getServiceUsers({ id, search: querySearch = '', limit: queryLimit = 10, offset = 0 }, pg = pgClients.client) {
|
|
20
|
+
const limit = Math.min(queryLimit, 100);
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
const search = querySearch?.trim() || '';
|
|
23
|
+
|
|
24
|
+
if (!id) {
|
|
25
|
+
throw BadRequestError('service_id is required');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const args = search ? [id, `%${search}%`] : [id];
|
|
25
29
|
|
|
26
30
|
const searchFilter = search
|
|
27
31
|
? `and (
|
|
@@ -49,7 +53,7 @@ export default async function getServiceUsers({ params = {}, query = {}, pg = pg
|
|
|
49
53
|
where a.service_id = $1
|
|
50
54
|
${searchFilter}
|
|
51
55
|
order by user_full_name
|
|
52
|
-
limit
|
|
56
|
+
limit $${args.length + 1}::bigint offset $${args.length + 2}::bigint
|
|
53
57
|
`;
|
|
54
58
|
|
|
55
59
|
const countSql = `
|
|
@@ -60,15 +64,13 @@ export default async function getServiceUsers({ params = {}, query = {}, pg = pg
|
|
|
60
64
|
${searchFilter}
|
|
61
65
|
`;
|
|
62
66
|
|
|
63
|
-
const args = search ? [id, `%${search}%`] : [id];
|
|
64
|
-
|
|
65
67
|
const [{ rows }, countResult] = await Promise.all([
|
|
66
|
-
pg.query(sql, args),
|
|
68
|
+
pg.query(sql, args.concat([limit, offset])),
|
|
67
69
|
pg.query(countSql, args).then((r) => r.rows?.[0]?.total ?? 0),
|
|
68
70
|
]);
|
|
69
71
|
|
|
70
|
-
return
|
|
72
|
+
return {
|
|
71
73
|
rows,
|
|
72
74
|
count: countResult,
|
|
73
|
-
}
|
|
75
|
+
};
|
|
74
76
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NotFoundError } from '@opengis/fastify-table/errors.js';
|
|
2
|
+
import { metaFormat, pgClients, getTemplate } from '@opengis/fastify-table/utils.js';
|
|
3
|
+
|
|
4
|
+
export default async function getServicesCol({ id, column }, pg = pgClients.client) {
|
|
5
|
+
const row = await getTemplate('layer', id) || await pg.query(`
|
|
6
|
+
SELECT
|
|
7
|
+
service_id, source_path, attributes
|
|
8
|
+
FROM gis.services where ${id ? 'service_id=$1' : '1=1'}
|
|
9
|
+
`, [id].filter(Boolean)).then(r => r.rows[0] || {});
|
|
10
|
+
|
|
11
|
+
if (!row.source_path) {
|
|
12
|
+
throw NotFoundError('source not found');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const fields = await pg.query(`SELECT * FROM ${row.source_path} limit 0`).then(r => r.fields);
|
|
16
|
+
const field = fields.find(el => el.name === column);
|
|
17
|
+
|
|
18
|
+
if (!field) {
|
|
19
|
+
throw NotFoundError('column not found: ' + column);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rows = await pg.query(`SELECT ${column}::text as id, ${column}, count(*) FROM ${row.source_path}
|
|
23
|
+
where ${column} is not null group by ${column} order by count(*) desc limit 10`).then(r => r.rows || []);
|
|
24
|
+
|
|
25
|
+
const cls = row.attributes?.filter?.((col) => col.name && col.data && ['select', 'badge', 'tags'].includes(col.format)).reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {}) || {};
|
|
26
|
+
|
|
27
|
+
await metaFormat({ rows, table: row.source_path, cls });
|
|
28
|
+
|
|
29
|
+
const rows1 = rows.map(row => ({
|
|
30
|
+
...row[`${column}_data`], ...row, [`${column}_data`]: undefined, [column]: undefined,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
return { rows: rows1, field, fields };
|
|
34
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NotFoundError } from '@opengis/fastify-table/errors.js';
|
|
1
2
|
import {
|
|
2
3
|
dataUpdate, getMeta, pgClients, yml2json, getTemplate,
|
|
3
4
|
} from '@opengis/fastify-table/utils.js';
|
|
@@ -12,10 +13,14 @@ const columnType = {
|
|
|
12
13
|
'timestamp with time zone': 'date',
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
export default async function getServices({
|
|
16
|
-
const t = await getTemplate('layer',
|
|
16
|
+
export default async function getServices({ id }, pg = pgClients.client) {
|
|
17
|
+
const t = await getTemplate('layer', id);
|
|
17
18
|
if (t) return t;
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
if (!pg.tlist.includes('gis.services')) {
|
|
21
|
+
throw NotFoundError('table not found');
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
const rows = await pg.query(`
|
|
20
25
|
SELECT
|
|
21
26
|
service_id, service_key, name, description, keywords, category, holder, group_id, b.group_name, service_type, card_mode,
|
|
@@ -24,18 +29,18 @@ export default async function getServices({ params = {}, pg = pgClients.client }
|
|
|
24
29
|
metadata_url, thumbnail_url, created_by, updated_by, updated_at, created_at, template
|
|
25
30
|
FROM gis.services a
|
|
26
31
|
left join lateral (select group_name from gis.group_list where group_id=a.group_id)b on 1=1
|
|
27
|
-
where ${
|
|
28
|
-
`, [
|
|
32
|
+
where ${id ? 'service_id=$1' : '1=1'}
|
|
33
|
+
`, [id].filter(Boolean)).then(r => r.rows || []);
|
|
29
34
|
|
|
30
|
-
if (
|
|
31
|
-
|
|
35
|
+
if (id && !rows.length) {
|
|
36
|
+
throw NotFoundError('service not found');
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
const totals = pg.queryCache ? await pg.queryCache('select json_object_agg(oid::regclass, reltuples) from pg_class')
|
|
35
|
-
.then(
|
|
40
|
+
.then(r => r.rows?.[0]?.json_object_agg || {}) : {};
|
|
36
41
|
|
|
37
|
-
if (
|
|
38
|
-
const html = await pg.query('select body from admin.templates where template_id=$1', [
|
|
42
|
+
if (id) {
|
|
43
|
+
const html = await pg.query('select body from admin.templates where template_id=$1', [id]).then(r => r.rows?.[0]?.body);
|
|
39
44
|
Object.assign(rows[0], { html });
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -43,13 +48,13 @@ export default async function getServices({ params = {}, pg = pgClients.client }
|
|
|
43
48
|
Object.assign(row, { count: totals[row.source_path] || 0 });
|
|
44
49
|
});
|
|
45
50
|
|
|
46
|
-
const
|
|
51
|
+
const columns = rows[0].source_path ? await getMeta({ pg, table: rows[0].source_path }).then(r => r?.columns || []) : [];
|
|
47
52
|
|
|
48
53
|
const fields = columns.map(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'], label: title || name }));
|
|
49
54
|
|
|
50
55
|
const noCenterIds = rows.filter(row => !row.center && row.bbox).map(row => row.service_id);
|
|
51
56
|
|
|
52
|
-
const centers = noCenterIds.length ? await pg.query('SELECT json_object_agg(service_id, st_pointonsurface(bbox)::json) FROM gis.services where service_id=any($1)', [noCenterIds].filter(Boolean)).then(
|
|
57
|
+
const centers = noCenterIds.length ? await pg.query('SELECT json_object_agg(service_id, st_pointonsurface(bbox)::json) FROM gis.services where service_id=any($1)', [noCenterIds].filter(Boolean)).then(r => r.rows?.[0]?.json_object_agg || {}) : {};
|
|
53
58
|
|
|
54
59
|
await Promise.all(rows.filter(row => centers[row.service_id]).map(async (row) => {
|
|
55
60
|
// console.log('update service center', row.service_id, JSON.stringify(centers[row.service_id]));
|
|
@@ -73,12 +78,12 @@ export default async function getServices({ params = {}, pg = pgClients.client }
|
|
|
73
78
|
filters: row.filters.map(filter => ({ ...filter, api: `/api/suggest/${row.source_path}:${filter.name}${filter.data && filter.name !== filter.data ? `?sel=${filter.data}` : ''}` })),
|
|
74
79
|
}));
|
|
75
80
|
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
81
|
+
if (id) {
|
|
82
|
+
return { ...rows[0], fields };
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
return
|
|
85
|
+
return {
|
|
81
86
|
rows,
|
|
82
87
|
fields,
|
|
83
|
-
}
|
|
88
|
+
};
|
|
84
89
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// import getLayerGeom from './functions/get.layer.geom.js';
|
|
2
|
+
import getServices from './functions/get.services.js';
|
|
3
|
+
import getServiceUsers from './functions/get.service.users.js';
|
|
4
|
+
import deleteService from './functions/del.service.js';
|
|
5
|
+
import addService from './functions/add.service.js';
|
|
6
|
+
import getServicesCol from './functions/get.services.col.js';
|
|
7
|
+
// import legendAuto from './functions/legend.auto.js';
|
|
8
|
+
import createRoute from './functions/create.route.js';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
getServicesSchema,
|
|
12
|
+
getServicesColSchema,
|
|
13
|
+
addServiceSchema,
|
|
14
|
+
editServiceSchema,
|
|
15
|
+
deleteServiceSchema,
|
|
16
|
+
getServiceUsersSchema,
|
|
17
|
+
createRouteSchema,
|
|
18
|
+
} from './services.schema.js';
|
|
19
|
+
const publicParams = { config: { policy: 'L0', package: 'gis' } };
|
|
20
|
+
|
|
21
|
+
async function route(app) {
|
|
22
|
+
app.get('/gis-service/:id?', { ...publicParams, schema: getServicesSchema }, async ({ params, pg }) => {
|
|
23
|
+
const result = await getServices({
|
|
24
|
+
id: params.id,
|
|
25
|
+
}, pg);
|
|
26
|
+
return result;
|
|
27
|
+
});
|
|
28
|
+
app.get('/gis-service/:id/:col', { ...publicParams, schema: getServicesColSchema }, async ({ params, pg }) => {
|
|
29
|
+
const result = await getServicesCol({
|
|
30
|
+
id: params.id,
|
|
31
|
+
column: params.col,
|
|
32
|
+
}, pg);
|
|
33
|
+
return result;
|
|
34
|
+
});
|
|
35
|
+
app.post('/gis-service/:id?', { ...publicParams, schema: addServiceSchema }, async ({ method, params, body, user, pg }) => {
|
|
36
|
+
const result = await addService({
|
|
37
|
+
method,
|
|
38
|
+
id: params.id,
|
|
39
|
+
body,
|
|
40
|
+
uid: user?.uid,
|
|
41
|
+
}, pg);
|
|
42
|
+
return result;
|
|
43
|
+
});
|
|
44
|
+
app.put('/gis-service/:id', { ...publicParams, schema: editServiceSchema }, async ({ method, params, body, user, pg }) => {
|
|
45
|
+
const result = await addService({
|
|
46
|
+
method,
|
|
47
|
+
id: params.id,
|
|
48
|
+
body,
|
|
49
|
+
uid: user?.uid,
|
|
50
|
+
}, pg);
|
|
51
|
+
return result;
|
|
52
|
+
});
|
|
53
|
+
app.delete('/gis-service/:id', { ...publicParams, schema: deleteServiceSchema }, async ({ params, user, pg }) => {
|
|
54
|
+
const result = await deleteService({
|
|
55
|
+
id: params.id,
|
|
56
|
+
uid: user?.uid
|
|
57
|
+
}, pg);
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
60
|
+
// app.get('/legend-auto/:id', { ...publicParams, schema: legendAutoSchema }, legendAuto);
|
|
61
|
+
app.get('/gis-service-users/:id', { ...publicParams, schema: getServiceUsersSchema }, async ({ params, query, pg }) => {
|
|
62
|
+
const result = await getServiceUsers({
|
|
63
|
+
id: params.id,
|
|
64
|
+
search: query.search,
|
|
65
|
+
limit: query.limit,
|
|
66
|
+
offset: query.offset,
|
|
67
|
+
}, pg);
|
|
68
|
+
return result;
|
|
69
|
+
});
|
|
70
|
+
app.get('/routes', { ...publicParams, schema: createRouteSchema }, async ({ query }) => {
|
|
71
|
+
const { from, to, via, mode, alternatives, steps, optimize, surface, weight } = query;
|
|
72
|
+
const result = await createRoute({ from, to, via, mode, alternatives, steps, optimize, surface, weight });
|
|
73
|
+
return result;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export default route;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { getPGAsync } from '@opengis/fastify-table/utils.js';
|
|
4
|
+
|
|
5
|
+
import { build, injectWithHeaders } from '../../../test/helper.js';
|
|
6
|
+
|
|
7
|
+
let pg;
|
|
8
|
+
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
await build();
|
|
11
|
+
|
|
12
|
+
pg = await getPGAsync();
|
|
13
|
+
|
|
14
|
+
await cleanUp('before');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterAll(async () => {
|
|
18
|
+
await cleanUp('after');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const testId = 'testService';
|
|
22
|
+
|
|
23
|
+
const cleanUp = async (when) => {
|
|
24
|
+
if (!pg) return;
|
|
25
|
+
const rowCount1 = await pg.query('delete from gis.services where service_id=$1', [testId]).then(r => r.rowCount || 0);
|
|
26
|
+
const rowCount4 = await pg.query('delete from gis.services_users_rel where service_id=$1', [testId]).then(r => r.rowCount || 0);
|
|
27
|
+
console.log(`clean up finished: ${when}`, rowCount1, rowCount4);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe('GIS routes', () => {
|
|
31
|
+
test('GET /gis-service + /gis-service/:id + /gis-service/:id/:col returns 200', async () => {
|
|
32
|
+
const res = await injectWithHeaders({
|
|
33
|
+
url: '/api/gis-service',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(res.statusCode).toBe(200);
|
|
37
|
+
expect(res.body).toHaveProperty('rows');
|
|
38
|
+
expect(res.body.rows.length).toBeGreaterThan(0);
|
|
39
|
+
expect(res.body).toHaveProperty('fields');
|
|
40
|
+
expect(res.body.fields.length).toBeGreaterThan(0);
|
|
41
|
+
|
|
42
|
+
expect(res.body.rows[0].service_id).toBeDefined();
|
|
43
|
+
|
|
44
|
+
const res1 = await injectWithHeaders({
|
|
45
|
+
url: `/api/gis-service/${res.body.rows[0].service_id}`,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(res1.statusCode).toBe(200);
|
|
49
|
+
expect(res1.body).toHaveProperty('service_id');
|
|
50
|
+
expect(res1.body).toHaveProperty('name');
|
|
51
|
+
expect(res1.body).toHaveProperty('service_key');
|
|
52
|
+
|
|
53
|
+
const res2 = await injectWithHeaders({
|
|
54
|
+
url: `/api/gis-service/${res.body.rows[0].service_id}/${res.body.fields[0].name}`,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(res2.statusCode).toBe(200);
|
|
58
|
+
expect(res2.body).toHaveProperty('rows');
|
|
59
|
+
expect(res2.body).toHaveProperty('fields');
|
|
60
|
+
|
|
61
|
+
expect(res2.body).toHaveProperty('field');
|
|
62
|
+
expect(res2.body.field).toHaveProperty('name');
|
|
63
|
+
expect(res2.body.field.name).toBe(res.body.fields[0].name);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('POST /gis-service returns 200', async () => {
|
|
67
|
+
await pg.query('delete from gis.services where service_id=$1', [testId]);
|
|
68
|
+
const res = await injectWithHeaders({
|
|
69
|
+
method: 'POST',
|
|
70
|
+
url: `/api/gis-service/${testId}`,
|
|
71
|
+
payload: {
|
|
72
|
+
name: 'unit test',
|
|
73
|
+
service_type: 'other'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(res.statusCode, res.body).toBe(200);
|
|
78
|
+
expect(res.body).toHaveProperty('service_id');
|
|
79
|
+
expect(res.body).toHaveProperty('name');
|
|
80
|
+
expect(res.body).toHaveProperty('service_type');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('PUT /gis-service/:id returns 200', async () => {
|
|
84
|
+
const payload = {
|
|
85
|
+
service_type: 'geojson'
|
|
86
|
+
};
|
|
87
|
+
const res = await injectWithHeaders({
|
|
88
|
+
method: 'PUT',
|
|
89
|
+
url: `/api/gis-service/${testId}`,
|
|
90
|
+
payload
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
expect(res.statusCode).toBe(200);
|
|
94
|
+
expect(res.body).toHaveProperty('service_id');
|
|
95
|
+
expect(res.body).toHaveProperty('name');
|
|
96
|
+
expect(res.body).toHaveProperty('service_type');
|
|
97
|
+
expect(res.body.service_type).toBe(payload.service_type);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// ! before delete
|
|
101
|
+
test('GET /gis-service-users/:id returns 200', async () => {
|
|
102
|
+
await pg.query('insert into gis.services_users_rel (user_id, service_id, actions) values($1,$2,$3)', ['2', testId, ['read']]).catch(err => console.error(err));
|
|
103
|
+
const res = await injectWithHeaders({
|
|
104
|
+
method: 'GET',
|
|
105
|
+
url: `/api/gis-service-users/${testId}`,
|
|
106
|
+
query: {
|
|
107
|
+
// search: '',
|
|
108
|
+
limit: 1,
|
|
109
|
+
offset: 0
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(res.statusCode, res.body).toBe(200);
|
|
114
|
+
expect(res.body).toHaveProperty('count');
|
|
115
|
+
expect(res.body).toHaveProperty('rows');
|
|
116
|
+
expect(res.body.rows).toBeInstanceOf(Array);
|
|
117
|
+
expect(res.body.rows.length).toBeGreaterThan(0);
|
|
118
|
+
expect(res.body.rows[0]).toHaveProperty('actions');
|
|
119
|
+
expect(res.body.rows[0].actions).toBeInstanceOf(Array);
|
|
120
|
+
expect(res.body.rows[0].actions.length).toBe(1);
|
|
121
|
+
expect(res.body.rows[0].actions[0]).toBe('read');
|
|
122
|
+
expect(res.body.rows[0]).toHaveProperty('user_id');
|
|
123
|
+
expect(res.body.rows[0]).toHaveProperty('user_full_name');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('DELETE /gis-service/:id returns 200', async () => {
|
|
127
|
+
const res = await injectWithHeaders({
|
|
128
|
+
method: 'DELETE',
|
|
129
|
+
url: `/api/gis-service/${testId}`,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
expect(res.statusCode).toBe(200);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('GET /routes returns 200', async () => {
|
|
136
|
+
const res = await injectWithHeaders({
|
|
137
|
+
url: '/api/routes',
|
|
138
|
+
query: {
|
|
139
|
+
from: '30.50,50.00',
|
|
140
|
+
to: '31.50,49.50',
|
|
141
|
+
alternatives: 'true',
|
|
142
|
+
steps: 'true'
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
expect(res.statusCode).toBe(200);
|
|
147
|
+
// skip if rate limited by cloudflare
|
|
148
|
+
if (res.body?.status !== 429) {
|
|
149
|
+
expect(res.body).toBeInstanceOf(Array);
|
|
150
|
+
expect(res.body.length).toBeGreaterThan(0);
|
|
151
|
+
expect(res.body[0]).toHaveProperty('alternative');
|
|
152
|
+
expect(res.body[0]).toHaveProperty('geom');
|
|
153
|
+
expect(res.body[0]).toHaveProperty('instructions');
|
|
154
|
+
expect(res.body[0].instructions).toBeInstanceOf(Array);
|
|
155
|
+
expect(res.body[0].instructions.length).toBeGreaterThan(0);
|
|
156
|
+
expect(res.body[0].instructions[0]).toHaveProperty('geometry');
|
|
157
|
+
expect(res.body[0].instructions[0]).toHaveProperty('mode');
|
|
158
|
+
expect(res.body[0].instructions[0]).toHaveProperty('driving_side');
|
|
159
|
+
expect(res.body[0].instructions[0]).toHaveProperty('duration');
|
|
160
|
+
expect(res.body[0].instructions[0]).toHaveProperty('distance');
|
|
161
|
+
expect(res.body[0].instructions[0]).toHaveProperty('weight');
|
|
162
|
+
expect(res.body[0].instructions[0]).toHaveProperty('name');
|
|
163
|
+
expect(res.body[0]).toHaveProperty('distance');
|
|
164
|
+
expect(res.body[0].distance).toBeTypeOf('number');
|
|
165
|
+
expect(res.body[0]).toHaveProperty('time_for_route');
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|