kopia lustrzana https://github.com/FacilMap/facilmap
Rename PadNotFoundError to MapNotFoundError
rodzic
fe74eab306
commit
7fa2208079
|
@ -1,5 +1,5 @@
|
|||
import { io, type ManagerOptions, type Socket as SocketIO, type SocketOptions } from "socket.io-client";
|
||||
import { type Bbox, type BboxWithZoom, type CRU, type EventHandler, type EventName, type FindOnMapQuery, type FindMapsQuery, type FindMapsResult, type FindQuery, type GetMapQuery, type HistoryEntry, type ID, type Line, type LineExportRequest, type LineTemplateRequest, type LineToRouteCreate, type SocketEvents, type Marker, type MultipleEvents, type ObjectWithId, type MapData, type MapId, type PagedResults, type SocketRequest, type SocketRequestName, type SocketResponse, type Route, type RouteClear, type RouteCreate, type RouteExportRequest, type RouteInfo, type RouteRequest, type SearchResult, type SocketVersion, type TrackPoint, type Type, type View, type Writable, type SocketClientToServerEvents, type SocketServerToClientEvents, type LineTemplate, type LinePointsEvent, PadNotFoundError, type SetLanguageRequest } from "facilmap-types";
|
||||
import { type Bbox, type BboxWithZoom, type CRU, type EventHandler, type EventName, type FindOnMapQuery, type FindMapsQuery, type FindMapsResult, type FindQuery, type GetMapQuery, type HistoryEntry, type ID, type Line, type LineExportRequest, type LineTemplateRequest, type LineToRouteCreate, type SocketEvents, type Marker, type MultipleEvents, type ObjectWithId, type MapData, type MapId, type PagedResults, type SocketRequest, type SocketRequestName, type SocketResponse, type Route, type RouteClear, type RouteCreate, type RouteExportRequest, type RouteInfo, type RouteRequest, type SearchResult, type SocketVersion, type TrackPoint, type Type, type View, type Writable, type SocketClientToServerEvents, type SocketServerToClientEvents, type LineTemplate, type LinePointsEvent, MapNotFoundError, type SetLanguageRequest } from "facilmap-types";
|
||||
import { deserializeError, errorConstructors, serializeError } from "serialize-error";
|
||||
|
||||
export interface ClientEventsInterface extends SocketEvents<SocketVersion.V3> {
|
||||
|
@ -68,7 +68,7 @@ interface ClientData {
|
|||
routes: Record<string, RouteWithTrackPoints>;
|
||||
}
|
||||
|
||||
errorConstructors.set("PadNotFoundError", PadNotFoundError as any);
|
||||
errorConstructors.set("MapNotFoundError", MapNotFoundError as any);
|
||||
|
||||
class Client {
|
||||
private socket: SocketIO<SocketServerToClientEvents<SocketVersion.V3>, SocketClientToServerEvents<SocketVersion.V3>>;
|
||||
|
|
|
@ -5,7 +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.
|
||||
* “pad” was renamed “map” everywhere. This applies to the `padData` and `deletePad` socket events and `getPad` (including its `padId` request property), the `findPads`, `createPad`, `editPad`, `deletePad`, `setPadId` client/socket methods, the `PadNotFoundError`.
|
||||
|
||||
## v4.0.0 (API v2)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { computed, onBeforeUnmount, reactive, ref, toRaw, watch } from "vue";
|
||||
import Client from "facilmap-client";
|
||||
import { PadNotFoundError, type MapData, type MapId } from "facilmap-types";
|
||||
import { MapNotFoundError, type MapData, type MapId } from "facilmap-types";
|
||||
import MapSettingsDialog from "./map-settings-dialog/map-settings-dialog.vue";
|
||||
import storage from "../utils/storage";
|
||||
import { type ToastAction } from "./ui/toasts/toasts.vue";
|
||||
|
@ -12,7 +12,7 @@
|
|||
import { getCurrentLanguage, getCurrentUnits } from "facilmap-utils";
|
||||
|
||||
function isMapNotFoundError(serverError: Client["serverError"]): boolean {
|
||||
return !!serverError && serverError instanceof PadNotFoundError;
|
||||
return !!serverError && serverError instanceof MapNotFoundError;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { SocketVersion, type SocketEvents, type MultipleEvents, type FindOnMapResult, type SocketServerToClientEmitArgs, legacyV2MarkerToCurrent, currentMarkerToLegacyV2, currentTypeToLegacyV2, legacyV2TypeToCurrent, mapHistoryEntry } from "facilmap-types";
|
||||
import { SocketVersion, type SocketEvents, type MultipleEvents, type FindOnMapResult, type SocketServerToClientEmitArgs, legacyV2MarkerToCurrent, currentMarkerToLegacyV2, currentTypeToLegacyV2, legacyV2TypeToCurrent, mapHistoryEntry, MapNotFoundError } from "facilmap-types";
|
||||
import { mapMultipleEvents, type SocketConnection, type SocketHandlers } from "./socket-common";
|
||||
import { SocketConnectionV3 } from "./socket-v3";
|
||||
import type Database from "../database/database";
|
||||
|
@ -71,7 +71,16 @@ export class SocketConnectionV2 implements SocketConnection<SocketVersion.V2> {
|
|||
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)),
|
||||
setPadId: async (mapId) => {
|
||||
try {
|
||||
return prepareMultiple(await socketHandlersV3.setMapId(mapId));
|
||||
} catch (err: any) {
|
||||
if (err instanceof MapNotFoundError) {
|
||||
err.name = "PadNotFoundError";
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
updateBbox: async (bbox) => prepareMultiple(await socketHandlersV3.updateBbox(bbox)),
|
||||
listenToHistory: async (data) => prepareMultiple(await socketHandlersV3.listenToHistory(data)),
|
||||
|
|
|
@ -6,7 +6,7 @@ import { find } from "../search.js";
|
|||
import { geoipLookup } from "../geoip.js";
|
||||
import { cloneDeep, isEqual, omit } from "lodash-es";
|
||||
import Database, { type DatabaseEvents } from "../database/database.js";
|
||||
import { type Bbox, type BboxWithZoom, type SocketEvents, type MultipleEvents, type MapData, type MapId, SocketVersion, Writable, PadNotFoundError, type SocketServerToClientEmitArgs, type EventName } from "facilmap-types";
|
||||
import { type Bbox, type BboxWithZoom, type SocketEvents, type MultipleEvents, type MapData, type MapId, SocketVersion, Writable, MapNotFoundError, type SocketServerToClientEmitArgs, type EventName } from "facilmap-types";
|
||||
import { calculateRoute, prepareForBoundingBox } from "../routing/routing.js";
|
||||
import type { RouteWithId } from "../database/route.js";
|
||||
import { type SocketConnection, type DatabaseHandlers, type SocketHandlers } from "./socket-common.js";
|
||||
|
@ -108,7 +108,7 @@ export class SocketConnectionV3 implements SocketConnection<SocketVersion.V3> {
|
|||
map = omit({ ...read, writable: Writable.READ }, ["writeId", "adminId"]);
|
||||
else {
|
||||
this.mapId = undefined;
|
||||
throw new PadNotFoundError(getI18n().t("socket.map-not-exist-error"));
|
||||
throw new MapNotFoundError(getI18n().t("socket.map-not-exist-error"));
|
||||
}
|
||||
|
||||
this.mapId = map.id;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export class PadNotFoundError extends Error {
|
||||
name = "PadNotFoundError";
|
||||
export class MapNotFoundError extends Error {
|
||||
name = "MapNotFoundError";
|
||||
}
|
Ładowanie…
Reference in New Issue