Something went wrong. Try again.
TypeScript client for accessing TLE Community.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142import Lacuna from '../lacuna';import { spliceBuildingIds } from './util';import type { ServerResponse } from './server';
abstract class Endpoint { abstract lacuna: Lacuna; abstract module: string;
callWithSession<T>(method: string, params: any) { return this.lacuna.server.call<T>({ module: this.module, method, params, addSession: true }); }
/** * Wraps a call whose result carries an id-keyed `buildings` map, splicing the * map key onto each row as `id` (see util#spliceBuildingIds). */ protected withBuildingIds<T>(promise: Promise<ServerResponse<T>>): Promise<ServerResponse<T>> { return promise.then((res) => { const buildings = (res.result as { buildings?: Record<string, unknown> } | undefined) ?.buildings; if (buildings) spliceBuildingIds(buildings); return res; }); }
callWithoutSession<T>(method: string, params: any) { return this.lacuna.server.call<T>({ module: this.module, method, params, addSession: false }); }
/** For RPC methods with no working /v2 equivalent. See Server#callLegacy. */ callLegacyWithSession<T>(method: string, params: any) { return this.lacuna.server.callLegacy<T>({ module: this.module, method, params, addSession: true, }); }}
export default Endpoint;