From fe74eab30651d2e679291df06b7381d31c109ba1 Mon Sep 17 00:00:00 2001 From: Candid Dauth Date: Sun, 21 Apr 2024 19:50:44 +0200 Subject: [PATCH] Rename pad to map in socket methods --- client/src/client.ts | 12 ++-- docs/src/developers/client/changelog.md | 1 + .../src/lib/components/open-map-dialog.vue | 2 +- .../src/socket-v3/mapData.test.ts | 68 +++++++++---------- .../src/socket-v3/types/types.test.ts | 12 ++-- server/src/database/type.ts | 8 +-- server/src/socket/socket-v2.ts | 36 ++++++---- server/src/socket/socket-v3.ts | 14 ++-- types/package.json | 1 + types/src/socket/socket-common.ts | 2 +- types/src/socket/socket-v2.ts | 20 +++++- types/src/socket/socket-v3.ts | 24 +++---- types/src/type.ts | 2 +- yarn.lock | 1 + 14 files changed, 114 insertions(+), 89 deletions(-) diff --git a/client/src/client.ts b/client/src/client.ts index 4fccfef3..fbbfa223 100644 --- a/client/src/client.ts +++ b/client/src/client.ts @@ -395,15 +395,15 @@ class Client { } async getMap(data: GetMapQuery): Promise { - return await this._emit("getPad", data); + return await this._emit("getMap", data); } async findMaps(data: FindMapsQuery): Promise> { - return await this._emit("findPads", data); + return await this._emit("findMaps", data); } async createMap(data: MapData): Promise>> { - const obj = await this._emit("createPad", data); + const obj = await this._emit("createMap", data); this._set(this.state, 'serverError', undefined); this._set(this.state, 'readonly', false); this._set(this.state, 'writable', 2); @@ -412,11 +412,11 @@ class Client { } async editMap(data: MapData): Promise { - return await this._emit("editPad", data); + return await this._emit("editMap", data); } async deleteMap(): Promise { - await this._emit("deletePad"); + await this._emit("deleteMap"); } async listenToHistory(): Promise>> { @@ -586,7 +586,7 @@ class Client { this._set(this.state, 'serverError', undefined); this._set(this.state, 'mapId', mapId); try { - const obj = await this._emit("setPadId", mapId); + const obj = await this._emit("setMapId", mapId); this._receiveMultiple(obj); return obj; } catch(err: any) { diff --git a/docs/src/developers/client/changelog.md b/docs/src/developers/client/changelog.md index f7dcc69c..eab8a5ac 100644 --- a/docs/src/developers/client/changelog.md +++ b/docs/src/developers/client/changelog.md @@ -5,6 +5,7 @@ The websocket on the FacilMap server provides different API versions (implemente ## v5.0.0 (API v3) * “symbol” was renamed to “icon” everywhere. This applies to `Marker.symbol`, `Type.defaultSymbol`, `Type.symbolFixed`, `Type.fields[].controlSymbol` and `Type.fields[].options[].symbol`. +* “pad” was renamed “map” everywhere. This applies to the `padData` and `deletePad` socket events and `getPad` (including its `padId` request property), `findPads`, `createPad`, `editPad`, `deletePad`, `setPadId` client/socket methods. ## v4.0.0 (API v2) diff --git a/frontend/src/lib/components/open-map-dialog.vue b/frontend/src/lib/components/open-map-dialog.vue index 63674f20..07e4c728 100644 --- a/frontend/src/lib/components/open-map-dialog.vue +++ b/frontend/src/lib/components/open-map-dialog.vue @@ -115,7 +115,7 @@ const parsed = parseMapId(mapId, context); if (parsed) { - const mapInfo = await client.value.getMap({ padId: parsed.mapId }); + const mapInfo = await client.value.getMap({ mapId: parsed.mapId }); if (!mapInfo) { return i18n.t("open-map-dialog.map-not-found-error"); } diff --git a/integration-tests/src/socket-v3/mapData.test.ts b/integration-tests/src/socket-v3/mapData.test.ts index cea66533..f1a93496 100644 --- a/integration-tests/src/socket-v3/mapData.test.ts +++ b/integration-tests/src/socket-v3/mapData.test.ts @@ -33,18 +33,18 @@ test("Create map (using default values)", async () => { expect(client.mapData).toEqual(expectedMapData); expect(onMapData).toBeCalledTimes(1); expect(onMapData).toHaveBeenCalledWith(expectedMapData); - expect(await client.getMap({ padId: createMapData.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); + expect(await client.getMap({ mapId: createMapData.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); }); }); -test("Create pad (using custom values)", async () => { +test("Create map (using custom values)", async () => { const client = await openClient(); const onMapData = vi.fn(); client.on("mapData", onMapData); await createTemporaryMap(client, { - name: "Test pad", + name: "Test map", searchEngines: true, description: "Test description", clusterMarkers: true, @@ -67,11 +67,11 @@ test("Create pad (using custom values)", async () => { expect(client.mapData).toEqual(expectedMapData); expect(onMapData).toBeCalledTimes(1); expect(onMapData).toHaveBeenCalledWith(expectedMapData); - expect(await client.getMap({ padId: createMapData.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); + expect(await client.getMap({ mapId: createMapData.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); }); }); -test("Create pad (ID already taken)", async () => { +test("Create map (ID already taken)", async () => { const client1 = await openClient(); const client2 = await openClient(); @@ -96,7 +96,7 @@ test("Create pad (ID already taken)", async () => { }); }); -test("Create pad (duplicate IDs)", async () => { +test("Create map (duplicate IDs)", async () => { const client = await openClient(); const newId = generateTestMapId(); @@ -123,7 +123,7 @@ test("Create pad (duplicate IDs)", async () => { }).rejects.toThrowError("have to be different"); }); -test("Edit pad", async () => { +test("Edit map", async () => { const client = await openClient(); const onMapData = vi.fn(); @@ -131,7 +131,7 @@ test("Edit pad", async () => { await createTemporaryMap(client, {}, async (createMapData, mapData) => { const update = { - name: "Test pad", + name: "Test map", searchEngines: true, description: "Test description", clusterMarkers: true, @@ -152,11 +152,11 @@ test("Edit pad", async () => { expect(updatedMapData).toEqual(expectedMapData); expect(client.mapData).toEqual(expectedMapData); expect(onMapData).toHaveBeenLastCalledWith(expectedMapData); - expect(await client.getMap({ padId: createMapData.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); + expect(await client.getMap({ mapId: createMapData.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); }); }); -test("Rename pad", async () => { +test("Rename map", async () => { const client = await openClient(); const onMapData = vi.fn(); @@ -180,17 +180,17 @@ test("Rename pad", async () => { expect(client.mapData).toEqual(expectedMapData); expect(onMapData).toHaveBeenLastCalledWith(expectedMapData); - expect(await client.getMap({ padId: createMapData.id })).toBeNull(); - expect(await client.getMap({ padId: createMapData.writeId })).toBeNull(); - expect(await client.getMap({ padId: createMapData.adminId })).toBeNull(); + expect(await client.getMap({ mapId: createMapData.id })).toBeNull(); + expect(await client.getMap({ mapId: createMapData.writeId })).toBeNull(); + expect(await client.getMap({ mapId: createMapData.adminId })).toBeNull(); - expect(await client.getMap({ padId: update.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); - expect(await client.getMap({ padId: update.writeId })).toEqual(pick(expectedMapData, ["id", "name", "description"])); - expect(await client.getMap({ padId: update.adminId })).toEqual(pick(expectedMapData, ["id", "name", "description"])); + expect(await client.getMap({ mapId: update.id })).toEqual(pick(expectedMapData, ["id", "name", "description"])); + expect(await client.getMap({ mapId: update.writeId })).toEqual(pick(expectedMapData, ["id", "name", "description"])); + expect(await client.getMap({ mapId: update.adminId })).toEqual(pick(expectedMapData, ["id", "name", "description"])); }); }); -test("Rename pad (ID already taken)", async () => { +test("Rename map (ID already taken)", async () => { const client1 = await openClient(); const client2 = await openClient(); @@ -217,7 +217,7 @@ test("Rename pad (ID already taken)", async () => { }); }); -test("Rename pad (duplicate IDs)", async () => { +test("Rename map (duplicate IDs)", async () => { const client = await openClient(); await createTemporaryMap(client, {}, async () => { @@ -246,24 +246,24 @@ test("Rename pad (duplicate IDs)", async () => { }); }); -test("Delete pad", async () => { +test("Delete map", async () => { const client = await openClient(); const mapData = getTemporaryMapData(SocketVersion.V3, {}); await createTemporaryMap(client, mapData, async () => { expect(client.deleted).toBe(false); - const result = await client.getMap({ padId: mapData.id }); + const result = await client.getMap({ mapId: mapData.id }); expect(result).toBeTruthy(); }); expect(client.deleted).toBe(true); - const result = await client.getMap({ padId: mapData.id }); + const result = await client.getMap({ mapId: mapData.id }); expect(result).toBeNull(); }); -test("Open existing pad", async () => { +test("Open existing map", async () => { const client1 = await openClient(); await createTemporaryMap(client1, {}, async (createMapData, mapData) => { @@ -305,7 +305,7 @@ test("Open existing pad", async () => { }); }); -test("Open non-existing pad", async () => { +test("Open non-existing map", async () => { const id = generateTestMapId(); const client1 = new Client(getFacilMapUrl(), id, { reconnection: false }); @@ -323,16 +323,16 @@ test("Open non-existing pad", async () => { expect(client2.serverError?.message).toMatch("does not exist"); }); -test("Find pads", async () => { +test("Find maps", async () => { const uniqueId = generateTestMapId(); const client = await openClient(); await createTemporaryMap(client, { - name: `Test ${uniqueId} pad`, + name: `Test ${uniqueId} map`, searchEngines: true }, async (createMapData) => { const expectedFound: PagedResults = { - results: [{ id: createMapData.id, name: `Test ${uniqueId} pad`, description: "" }], + results: [{ id: createMapData.id, name: `Test ${uniqueId} map`, description: "" }], totalLength: 1 }; @@ -341,18 +341,18 @@ test("Find pads", async () => { totalLength: 0 }; - expect(await client.findMaps({ query: `Test ${uniqueId} pad` })).toEqual(expectedFound); - expect(await client.findMaps({ query: `test ${uniqueId} pad` })).toEqual(expectedFound); - expect(await client.findMaps({ query: `Te?t ${uniqueId} pad` })).toEqual(expectedFound); - expect(await client.findMaps({ query: `Te* ${uniqueId} pad` })).toEqual(expectedFound); + expect(await client.findMaps({ query: `Test ${uniqueId} map` })).toEqual(expectedFound); + expect(await client.findMaps({ query: `test ${uniqueId} map` })).toEqual(expectedFound); + expect(await client.findMaps({ query: `Te?t ${uniqueId} map` })).toEqual(expectedFound); + expect(await client.findMaps({ query: `Te* ${uniqueId} map` })).toEqual(expectedFound); expect(await client.findMaps({ query: uniqueId })).toEqual(expectedFound); - expect(await client.findMaps({ query: `Te ${uniqueId} pad` })).toEqual(expectedNotFound); - expect(await client.findMaps({ query: `Te? ${uniqueId} pad` })).toEqual(expectedNotFound); - expect(await client.findMaps({ query: `Te% ${uniqueId} pad` })).toEqual(expectedNotFound); + expect(await client.findMaps({ query: `Te ${uniqueId} map` })).toEqual(expectedNotFound); + expect(await client.findMaps({ query: `Te? ${uniqueId} map` })).toEqual(expectedNotFound); + expect(await client.findMaps({ query: `Te% ${uniqueId} map` })).toEqual(expectedNotFound); await client.editMap({ searchEngines: false }); - expect(await client.findMaps({ query: `Test ${uniqueId} pad` })).toEqual(expectedNotFound); + expect(await client.findMaps({ query: `Test ${uniqueId} map` })).toEqual(expectedNotFound); }); }); \ No newline at end of file diff --git a/integration-tests/src/socket-v3/types/types.test.ts b/integration-tests/src/socket-v3/types/types.test.ts index 1057edc1..247c5b13 100644 --- a/integration-tests/src/socket-v3/types/types.test.ts +++ b/integration-tests/src/socket-v3/types/types.test.ts @@ -36,7 +36,7 @@ test("Default types are added", async () => { defaultMode: '', modeFixed: false, showInLegend: false, - mapId: mapData.id + padId: mapData.id }, { fields: [ @@ -61,7 +61,7 @@ test("Default types are added", async () => { defaultMode: '', modeFixed: false, showInLegend: false, - mapId: mapData.id + padId: mapData.id } ] satisfies Array; @@ -107,7 +107,7 @@ test("Create type (marker, default settings)", async () => { const expectedType: Type = { ...type, id: typeResult.id, - mapId: mapData.id, + padId: mapData.id, idx: 0, defaultColour: "ff0000", colourFixed: false, @@ -178,7 +178,7 @@ test("Create type (line, default settings)", async () => { const expectedType: Type = { ...type, id: typeResult.id, - mapId: mapData.id, + padId: mapData.id, idx: 0, defaultColour: "0000ff", colourFixed: false, @@ -263,7 +263,7 @@ test("Create type (custom settings)", async () => { const expectedType: Type = { ...type, id: typeResult.id, - mapId: mapData.id + padId: mapData.id }; expect(typeResult).toEqual(expectedType); @@ -327,7 +327,7 @@ test("Update type", async () => { const expectedType: Type = { ...update, - mapId: mapData.id, + padId: mapData.id, type: "marker" }; diff --git a/server/src/database/type.ts b/server/src/database/type.ts index 4371d8b5..f2862115 100644 --- a/server/src/database/type.ts +++ b/server/src/database/type.ts @@ -107,7 +107,7 @@ export default class DatabaseTypes { for (const obj of newIndexes) { if ((typeId == null || obj.id !== typeId) && obj.oldIdx !== obj.newIdx) { const result = await this._db.helpers._updateMapObject("Type", mapId, obj.id, { idx: obj.newIdx }, true); - this._db.emit("type", result.mapId, result); + this._db.emit("type", result.padId, result); } } @@ -121,7 +121,7 @@ export default class DatabaseTypes { ...data, idx }); - this._db.emit("type", createdType.mapId, createdType); + this._db.emit("type", createdType.padId, createdType); return createdType; } @@ -154,12 +154,12 @@ export default class DatabaseTypes { } const result = await this._db.helpers._updateMapObject("Type", mapId, typeId, data); - this._db.emit("type", result.mapId, result); + this._db.emit("type", result.padId, result); if(Object.keys(rename).length > 0) await this._db.helpers.renameObjectDataField(mapId, result.id, rename, result.type == "line"); - await this.recalculateObjectStylesForType(result.mapId, typeId, result.type == "line"); + await this.recalculateObjectStylesForType(result.padId, typeId, result.type == "line"); return result; } diff --git a/server/src/socket/socket-v2.ts b/server/src/socket/socket-v2.ts index 6acbde61..ddfcd7b9 100644 --- a/server/src/socket/socket-v2.ts +++ b/server/src/socket/socket-v2.ts @@ -2,6 +2,7 @@ import { SocketVersion, type SocketEvents, type MultipleEvents, type FindOnMapRe import { mapMultipleEvents, type SocketConnection, type SocketHandlers } from "./socket-common"; import { SocketConnectionV3 } from "./socket-v3"; import type Database from "../database/database"; +import { omit } from "lodash-es"; function prepareEvent(...args: SocketServerToClientEmitArgs): Array> { if (args[0] === "marker") { @@ -55,25 +56,30 @@ export class SocketConnectionV2 implements SocketConnection { } getSocketHandlers(): SocketHandlers { - const socketHandlers = this.socketV3.getSocketHandlers(); + const socketHandlersV3 = this.socketV3.getSocketHandlers(); return { - ...socketHandlers, + ...omit(socketHandlersV3, ["getMap", "findMaps", "createMap", "editMap", "deleteMap", "setMapId"]), - addMarker: async (marker) => currentMarkerToLegacyV2(await socketHandlers.addMarker(legacyV2MarkerToCurrent(marker))), - editMarker: async (marker) => currentMarkerToLegacyV2(await socketHandlers.editMarker(legacyV2MarkerToCurrent(marker))), - addType: async (type) => currentTypeToLegacyV2(await socketHandlers.addType(legacyV2TypeToCurrent(type))), - editType: async (type) => currentTypeToLegacyV2(await socketHandlers.editType(legacyV2TypeToCurrent(type))), + addMarker: async (marker) => currentMarkerToLegacyV2(await socketHandlersV3.addMarker(legacyV2MarkerToCurrent(marker))), + editMarker: async (marker) => currentMarkerToLegacyV2(await socketHandlersV3.editMarker(legacyV2MarkerToCurrent(marker))), + addType: async (type) => currentTypeToLegacyV2(await socketHandlersV3.addType(legacyV2TypeToCurrent(type))), + editType: async (type) => currentTypeToLegacyV2(await socketHandlersV3.editType(legacyV2TypeToCurrent(type))), - updateBbox: async (bbox) => prepareMultiple(await socketHandlers.updateBbox(bbox)), - createPad: async (mapData) => prepareMultiple(await socketHandlers.createPad(mapData)), - listenToHistory: async (data) => prepareMultiple(await socketHandlers.listenToHistory(data)), - revertHistoryEntry: async (entry) => prepareMultiple(await socketHandlers.revertHistoryEntry(entry)), - getMarker: async (data) => currentMarkerToLegacyV2(await socketHandlers.getMarker(data)), - deleteMarker: async (data) => currentMarkerToLegacyV2(await socketHandlers.deleteMarker(data)), - findOnMap: async (data) => (await socketHandlers.findOnMap(data)).map((result) => prepareMapResultOutput(result)), - deleteType: async (data) => currentTypeToLegacyV2(await socketHandlers.deleteType(data)), - setPadId: async (mapId) => prepareMultiple(await socketHandlers.setPadId(mapId)) + getPad: async (data) => await socketHandlersV3.getMap({ mapId: data.padId }), + findPads: async (data) => await socketHandlersV3.findMaps(data), + createPad: async (mapData) => prepareMultiple(await socketHandlersV3.createMap(mapData)), + editPad: async (mapData) => await socketHandlersV3.editMap(mapData), + deletePad: async (data) => await socketHandlersV3.deleteMap(data), + setPadId: async (mapId) => prepareMultiple(await socketHandlersV3.setMapId(mapId)), + + updateBbox: async (bbox) => prepareMultiple(await socketHandlersV3.updateBbox(bbox)), + listenToHistory: async (data) => prepareMultiple(await socketHandlersV3.listenToHistory(data)), + revertHistoryEntry: async (entry) => prepareMultiple(await socketHandlersV3.revertHistoryEntry(entry)), + getMarker: async (data) => currentMarkerToLegacyV2(await socketHandlersV3.getMarker(data)), + deleteMarker: async (data) => currentMarkerToLegacyV2(await socketHandlersV3.deleteMarker(data)), + findOnMap: async (data) => (await socketHandlersV3.findOnMap(data)).map((result) => prepareMapResultOutput(result)), + deleteType: async (data) => currentTypeToLegacyV2(await socketHandlersV3.deleteType(data)) }; } diff --git a/server/src/socket/socket-v3.ts b/server/src/socket/socket-v3.ts index d90e6c11..b8e3e2b7 100644 --- a/server/src/socket/socket-v3.ts +++ b/server/src/socket/socket-v3.ts @@ -87,7 +87,7 @@ export class SocketConnectionV3 implements SocketConnection { getSocketHandlers(): SocketHandlers { return { - setPadId: async (mapId) => { + setMapId: async (mapId) => { if(this.mapId != null) throw new Error(getI18n().t("socket.map-id-set-error")); @@ -159,10 +159,10 @@ export class SocketConnectionV3 implements SocketConnection { return await promiseProps(ret); }, - getPad: async (data) => { + getMap: async (data) => { this.validatePermissions(Writable.READ); - const mapData = await this.database.maps.getMapDataByAnyId(data.padId); + const mapData = await this.database.maps.getMapDataByAnyId(data.mapId); return mapData && { id: mapData.id, name: mapData.name, @@ -170,13 +170,13 @@ export class SocketConnectionV3 implements SocketConnection { }; }, - findPads: async (data) => { + findMaps: async (data) => { this.validatePermissions(Writable.READ); return this.database.maps.findMaps(data); }, - createPad: async (data) => { + createMap: async (data) => { this.validatePermissions(Writable.READ); if(this.mapId) @@ -192,7 +192,7 @@ export class SocketConnectionV3 implements SocketConnection { return await this.getMapObjects({ ...mapData, writable: Writable.ADMIN }); }, - editPad: async (data) => { + editMap: async (data) => { this.validatePermissions(Writable.ADMIN); if (!isMapId(this.mapId)) @@ -204,7 +204,7 @@ export class SocketConnectionV3 implements SocketConnection { }; }, - deletePad: async () => { + deleteMap: async () => { this.validatePermissions(Writable.ADMIN); if (!isMapId(this.mapId)) diff --git a/types/package.json b/types/package.json index 4d528df4..7a752259 100644 --- a/types/package.json +++ b/types/package.json @@ -28,6 +28,7 @@ ], "dependencies": { "@types/geojson": "^7946.0.14", + "lodash-es": "^4.17.21", "zod": "^3.22.4" }, "devDependencies": { diff --git a/types/src/socket/socket-common.ts b/types/src/socket/socket-common.ts index 6f5d7ff6..df600425 100644 --- a/types/src/socket/socket-common.ts +++ b/types/src/socket/socket-common.ts @@ -5,7 +5,7 @@ import { type Line, type TrackPoint } from "../line.js"; import * as z from "zod"; export const getMapQueryValidator = z.object({ - padId: z.string() + mapId: z.string() }); export type GetMapQuery = z.infer; diff --git a/types/src/socket/socket-v2.ts b/types/src/socket/socket-v2.ts index 370f1954..a849a126 100644 --- a/types/src/socket/socket-v2.ts +++ b/types/src/socket/socket-v2.ts @@ -7,10 +7,12 @@ import { requestDataValidatorsV3, type MapEventsV3, type ResponseDataMapV3 } fro import type { CRU, CRUType } from "../cru.js"; import * as z from "zod"; import type { GenericHistoryEntry, HistoryEntryObjectTypes } from "../historyEntry.js"; +import { omit } from "lodash-es"; // Socket v2: // - “icon” is called “symbol” in `Marker.symbol`, `Type.defaultSymbol`, `Type.symbolFixed`, `Type.fields[].controlSymbol` and // `Type.fields[].options[].symbol`. +// - “map” is called “pad” in events, types, methods export const legacyV2MarkerValidator = { read: markerValidator.read.omit({ icon: true }).extend({ symbol: markerValidator.read.shape.icon }), @@ -67,15 +69,29 @@ export type LegacyV2HistoryEntry = GenericHistoryEntry; }>>; +export const legacyV2GetMapQueryValidator = z.object({ + padId: z.string() +}); + export const requestDataValidatorsV2 = { - ...requestDataValidatorsV3, + ...omit(requestDataValidatorsV3, ["getMap", "findMaps", "createMap", "editMap", "deleteMap", "setMapId"]), + getPad: legacyV2GetMapQueryValidator, + findPads: requestDataValidatorsV3.findMaps, + createPad: requestDataValidatorsV3.createMap, + editPad: requestDataValidatorsV3.editMap, + deletePad: requestDataValidatorsV3.deleteMap, + setPadId: requestDataValidatorsV3.setMapId, addMarker: legacyV2MarkerValidator.create, editMarker: legacyV2MarkerValidator.update.extend({ id: idValidator }), addType: legacyV2TypeValidator.create, editType: legacyV2TypeValidator.update.extend({ id: idValidator }) }; -export type ResponseDataMapV2 = ReplaceProperties, { + getPad: ResponseDataMapV3["getMap"]; + findPads: ResponseDataMapV3["findMaps"]; + editPad: ResponseDataMapV3["editMap"]; + deletePad: ResponseDataMapV3["deleteMap"]; updateBbox: MultipleEvents; createPad: MultipleEvents; listenToHistory: MultipleEvents; diff --git a/types/src/socket/socket-v3.ts b/types/src/socket/socket-v3.ts index f37df939..2e74572e 100644 --- a/types/src/socket/socket-v3.ts +++ b/types/src/socket/socket-v3.ts @@ -13,11 +13,11 @@ import type { HistoryEntry } from "../historyEntry.js"; export const requestDataValidatorsV3 = { updateBbox: bboxWithZoomValidator, - getPad: getMapQueryValidator, - findPads: findMapsQueryValidator, - createPad: mapDataValidator.create, - editPad: mapDataValidator.update, - deletePad: nullOrUndefinedValidator, + getMap: getMapQueryValidator, + findMaps: findMapsQueryValidator, + createMap: mapDataValidator.create, + editMap: mapDataValidator.update, + deleteMap: nullOrUndefinedValidator, listenToHistory: nullOrUndefinedValidator, stopListeningToHistory: nullOrUndefinedValidator, revertHistoryEntry: objectWithIdValidator, @@ -44,17 +44,17 @@ export const requestDataValidatorsV3 = { editView: viewValidator.update.extend({ id: idValidator }), deleteView: objectWithIdValidator, geoip: nullOrUndefinedValidator, - setPadId: z.string(), + setMapId: z.string(), setLanguage: setLanguageRequestValidator }; export interface ResponseDataMapV3 { updateBbox: MultipleEvents; - getPad: FindMapsResult | null; - findPads: PagedResults; - createPad: MultipleEvents; - editPad: MapData & { writable: Writable }; - deletePad: null; + getMap: FindMapsResult | null; + findMaps: PagedResults; + createMap: MultipleEvents; + editMap: MapData & { writable: Writable }; + deleteMap: null; listenToHistory: MultipleEvents; stopListeningToHistory: null; revertHistoryEntry: MultipleEvents; @@ -81,7 +81,7 @@ export interface ResponseDataMapV3 { editView: View; deleteView: View; geoip: Bbox | null; - setPadId: MultipleEvents; + setMapId: MultipleEvents; setLanguage: void; } diff --git a/types/src/type.ts b/types/src/type.ts index 0a2a0cb8..22da64cb 100644 --- a/types/src/type.ts +++ b/types/src/type.ts @@ -127,7 +127,7 @@ export const defaultFields = (): Field[] => [ { name: "Description", type: "text export const rawTypeValidator = cruValidator({ id: onlyRead(idValidator), type: exceptUpdate(objectTypeValidator), - mapId: onlyRead(mapIdValidator), + padId: onlyRead(mapIdValidator), name: optionalUpdate(z.string().trim().min(1).max(100)), idx: optionalCreate(z.number().int().min(0)), diff --git a/yarn.lock b/yarn.lock index d72884df..e7f9db4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4196,6 +4196,7 @@ __metadata: resolution: "facilmap-types@workspace:types" dependencies: "@types/geojson": ^7946.0.14 + lodash-es: ^4.17.21 rimraf: ^5.0.5 typescript: ^5.4.4 vite: ^5.2.8