diff --git a/api/package-lock.json b/api/package-lock.json index caff3f5fd..497d3b7e5 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -81,7 +81,7 @@ "@types/busboy": "^1.5.0", "@types/connect-history-api-fallback": "^1.3.5", "@types/cors": "^2.8.13", - "@types/express": "^4.17.16", + "@types/express": "^5.0.0", "@types/geojson": "^7946.0.10", "@types/jsonwebtoken": "^9.0.1", "@types/memjs": "^1.3.0", @@ -3378,6 +3378,30 @@ "node": ">= 18" } }, + "node_modules/@openaddresses/batch-error/node_modules/@types/express": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "node_modules/@openaddresses/batch-error/node_modules/@types/express-serve-static-core": { + "version": "4.19.6", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz", + "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, "node_modules/@openaddresses/batch-generic": { "version": "21.1.0", "resolved": "https://registry.npmjs.org/@openaddresses/batch-generic/-/batch-generic-21.1.0.tgz", @@ -4695,13 +4719,14 @@ "license": "MIT" }, "node_modules/@types/express": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", - "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.0.tgz", + "integrity": "sha512-DvZriSMehGHL1ZNLzi6MidnsDhUZM/x2pRdDIKdwbUNqqwHxMlRdkxtn6/EPKyqKpHqTl/4nRZsRNLpZxZRpPQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.33", + "@types/express-serve-static-core": "^5.0.0", "@types/qs": "*", "@types/serve-static": "*" } @@ -4719,18 +4744,6 @@ "@types/send": "*" } }, - "node_modules/@types/express/node_modules/@types/express-serve-static-core": { - "version": "4.19.6", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz", - "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==", - "license": "MIT", - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*", - "@types/send": "*" - } - }, "node_modules/@types/geojson": { "version": "7946.0.14", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.14.tgz", diff --git a/api/package.json b/api/package.json index d92f32fda..4d2c8e258 100644 --- a/api/package.json +++ b/api/package.json @@ -93,7 +93,7 @@ "@types/busboy": "^1.5.0", "@types/connect-history-api-fallback": "^1.3.5", "@types/cors": "^2.8.13", - "@types/express": "^4.17.16", + "@types/express": "^5.0.0", "@types/geojson": "^7946.0.10", "@types/jsonwebtoken": "^9.0.1", "@types/memjs": "^1.3.0", diff --git a/api/routes/basemap.ts b/api/routes/basemap.ts index 505020922..35517025b 100644 --- a/api/routes/basemap.ts +++ b/api/routes/basemap.ts @@ -21,6 +21,14 @@ import { Basemap } from '../lib/schema.js'; import { toEnum, Basemap_Format, Basemap_Style, Basemap_Type } from '../lib/enums.js'; import * as Default from '../lib/limits.js'; +const AugmentedBasemapResponse = Type.Composite([ + Type.Omit(BasemapResponse, ['bounds', 'center']), + Type.Object({ + bounds: Type.Optional(Type.Array(Type.Number(), { minItems: 4, maxItems: 4 })), + center: Type.Optional(Type.Array(Type.Number())) + }) +]) + export default async function router(schema: Schema, config: Config) { await schema.put('/basemap', { name: 'Import BaseMaps', @@ -142,7 +150,7 @@ export default async function router(schema: Schema, config: Config) { }), res: Type.Object({ total: Type.Integer(), - items: Type.Array(BasemapResponse) + items: Type.Array(AugmentedBasemapResponse) }) }, async (req, res) => { try { @@ -166,7 +174,16 @@ export default async function router(schema: Schema, config: Config) { ` }); - return res.json(list); + return res.json({ + total: list.total, + items: list.items.map((basemap) => { + return { + ...basemap, + bounds: basemap.bounds ? bbox(basemap.bounds) : undefined, + center: basemap.center ? basemap.center.coordinates : undefined, + }; + }) + }); } catch (err) { return Err.respond(err, res); } @@ -189,7 +206,7 @@ export default async function router(schema: Schema, config: Config) { bounds: Type.Optional(Type.Array(Type.Number(), { minItems: 4, maxItems: 4 })), center: Type.Optional(Type.Array(Type.Number())) }), - res: BasemapResponse + res: AugmentedBasemapResponse }, async (req, res) => { try { const user = await Auth.as_user(config, req); @@ -220,7 +237,11 @@ export default async function router(schema: Schema, config: Config) { username }); - return res.json(basemap); + return res.json({ + ...basemap, + bounds: basemap.bounds ? bbox(basemap.bounds) : undefined, + center: basemap.center ? basemap.center.coordinates : undefined, + }); } catch (err) { return Err.respond(err, res); } @@ -244,7 +265,7 @@ export default async function router(schema: Schema, config: Config) { bounds: Type.Optional(Type.Array(Type.Number(), { minItems: 4, maxItems: 4 })), center: Type.Optional(Type.Array(Type.Number())) }), - res: BasemapResponse + res: AugmentedBasemapResponse }, async (req, res) => { try { const user = await Auth.as_user(config, req); @@ -266,13 +287,17 @@ export default async function router(schema: Schema, config: Config) { const basemap = await config.models.Basemap.commit(Number(req.params.basemapid), { updated: sql`Now()`, + ...req.body, bounds, center, - ...req.body }); await config.cacher.del(`basemap-${req.params.basemapid}`); - return res.json(basemap); + return res.json({ + ...basemap, + bounds: basemap.bounds ? bbox(basemap.bounds) : undefined, + center: basemap.center ? basemap.center.coordinates : undefined, + }); } catch (err) { return Err.respond(err, res); } @@ -290,7 +315,7 @@ export default async function router(schema: Schema, config: Config) { format: Type.Optional(Type.String()), token: Type.Optional(Type.String()), }), - res: Type.Union([BasemapResponse, Type.String()]) + res: Type.Union([AugmentedBasemapResponse, Type.String()]) }, async (req, res) => { try { const user = await Auth.as_user(config, req, { token: true }); @@ -326,7 +351,11 @@ export default async function router(schema: Schema, config: Config) { return res.send(xml); } else { - return res.json(basemap); + return res.json({ + ...basemap, + bounds: basemap.bounds ? bbox(basemap.bounds) : undefined, + center: basemap.center ? basemap.center.coordinates : undefined, + }); } } catch (err) { return Err.respond(err, res); diff --git a/api/web/src/components/Admin/AdminOverlaysEdit.vue b/api/web/src/components/Admin/AdminOverlaysEdit.vue index a1a1327b7..0a0ec248b 100644 --- a/api/web/src/components/Admin/AdminOverlaysEdit.vue +++ b/api/web/src/components/Admin/AdminOverlaysEdit.vue @@ -38,6 +38,18 @@ label='MaxZoom' /> +