Files
remotestorage-module-places/dist/places.d.ts
2026-03-13 16:59:06 +04:00

229 lines
6.8 KiB
TypeScript

import BaseClient from 'remotestoragejs/release/types/baseclient';
import { FromSchema } from 'json-schema-to-ts';
declare const placeSchema: {
readonly type: "object";
readonly properties: {
readonly id: {
readonly type: "string";
};
readonly title: {
readonly type: "string";
};
readonly lat: {
readonly type: "number";
};
readonly lon: {
readonly type: "number";
};
readonly geohash: {
readonly type: "string";
};
readonly zoom: {
readonly type: "number";
};
readonly url: {
readonly type: "string";
};
readonly osmId: {
readonly type: "string";
};
readonly osmType: {
readonly type: "string";
};
readonly osmTags: {
readonly type: "object";
readonly additionalProperties: {
readonly type: "string";
};
};
readonly description: {
readonly type: "string";
};
readonly tags: {
readonly type: "array";
readonly items: {
readonly type: "string";
};
readonly default: readonly [];
};
readonly createdAt: {
readonly type: "string";
readonly format: "date-time";
};
readonly updatedAt: {
readonly type: "string";
readonly format: "date-time";
};
};
readonly required: readonly ["id", "title", "lat", "lon", "geohash", "createdAt"];
};
declare const listSchema: {
readonly type: "object";
readonly properties: {
readonly id: {
readonly type: "string";
};
readonly title: {
readonly type: "string";
};
readonly color: {
readonly type: "string";
};
readonly placeRefs: {
readonly type: "array";
readonly items: {
readonly type: "object";
readonly properties: {
readonly id: {
readonly type: "string";
};
readonly geohash: {
readonly type: "string";
};
};
readonly required: readonly ["id", "geohash"];
};
readonly default: readonly [];
};
readonly createdAt: {
readonly type: "string";
readonly format: "date-time";
};
readonly updatedAt: {
readonly type: "string";
readonly format: "date-time";
};
};
readonly required: readonly ["id", "title", "placeRefs", "createdAt"];
};
/**
* Represents a List object.
*
* Core properties enforced by schema:
* - `id`: Unique identifier (slug)
* - `title`: Human readable title
* - `placeRefs`: Array of place references containing `id` and `geohash`
* - `createdAt`: ISO date string
*
* Optional properties:
* - `color`: Hex color code
* - `updatedAt`: ISO date string
*/
export type List = FromSchema<typeof listSchema> & {
[key: string]: any;
};
/**
* Represents a Place object.
*
* Core properties enforced by schema:
* - `id`: Unique identifier (ULID)
* - `title`: Name of the place
* - `lat`: Latitude
* - `lon`: Longitude
* - `geohash`: Geohash for indexing
* - `createdAt`: ISO date string
*
* Optional properties:
* - `description`: Text description
* - `zoom`: Map zoom level
* - `url`: Related URL
* - `osmId`, `osmType`, `osmTags`: OpenStreetMap data
* - `tags`: Array of string tags
* - `updatedAt`: ISO date string
*/
export type Place = FromSchema<typeof placeSchema> & {
[key: string]: any;
};
export interface PlacesClient {
/**
* Store a place.
* Generates ID and Geohash if missing.
* Path structure: `<geohash-prefix-2>/<geohash-prefix-2>/<id>`
*
* @param placeData - The data of the place to store.
* @returns The stored place object.
*/
store(placeData: Partial<Place>): Promise<Place>;
/**
* Remove a place.
* Requires geohash to locate the folder.
*
* @param id - The ID of the place to remove.
* @param geohash - The geohash of the place.
*/
remove(id: string, geohash: string): Promise<unknown>;
/**
* Get a single place.
* Requires geohash to locate the folder.
*
* @param id - The ID of the place to retrieve.
* @param geohash - The geohash of the place.
* @returns The place object.
*/
get(id: string, geohash: string): Promise<Place | unknown>;
/**
* List places matching a geohash prefix.
* Supports 2-char ("ab") or 4-char ("abcd") prefixes.
* If 2-char, it returns the sub-folders (prefixes), not places.
* If 4-char, it returns the places in that sector.
*
* @param prefix - The geohash prefix to filter by.
* @returns A map of objects found at the prefix.
*/
listByPrefix(prefix: string): Promise<unknown | {
[key: string]: any;
}>;
/**
* Get places from specific prefixes.
*
* @param prefixes - Optional array of 4-character geohash prefixes to load (e.g. ['w1q7', 'w1q8']).
* If not provided, it will attempt to scan ALL prefixes (recursive).
* @returns An array of places.
*/
getPlaces(prefixes?: string[]): Promise<Place[]>;
lists: {
/**
* Get all lists.
* @returns Array of List objects.
*/
getAll(): Promise<List[]>;
/**
* Get a single list by ID (slug).
* @param id - The slug ID of the list.
*/
get(id: string): Promise<List | null>;
/**
* Create or update a list.
* @param id - The slug ID (e.g., "to-go").
* @param title - Human readable title.
* @param color - Optional hex color code.
*/
create(id: string, title: string, color?: string): Promise<List>;
/**
* Delete a list.
* @param id - The slug ID of the list.
*/
delete(id: string): Promise<void>;
/**
* Add a place to a list.
* @param listId - The slug ID of the list.
* @param placeId - The ID of the place.
* @param geohash - The geohash of the place.
*/
addPlace(listId: string, placeId: string, geohash: string): Promise<List>;
/**
* Remove a place from a list.
* @param listId - The slug ID of the list.
* @param placeId - The ID of the place.
*/
removePlace(listId: string, placeId: string): Promise<List>;
};
}
declare const _default: {
name: string;
builder: (privateClient: BaseClient) => {
exports: PlacesClient;
};
};
export default _default;