This commit is contained in:
Râu Cao 2026-01-26 17:56:52 +07:00
parent 156cdefaba
commit 713efb81b5
Signed by: raucao
GPG Key ID: 37036C356E56CC51
2 changed files with 89 additions and 40 deletions

76
dist/places.d.ts vendored
View File

@ -1,21 +1,65 @@
import BaseClient from 'remotestoragejs/release/types/baseclient';
interface Place {
id: string;
title: string;
lat: number;
lon: number;
geohash: string;
zoom?: number;
url?: string;
osmId?: string;
osmType?: string;
osmTags?: Record<string, string>;
description?: string;
tags?: string[];
createdAt: string;
updatedAt?: string;
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"];
};
type Place = FromSchema<typeof placeSchema> & {
[key: string]: any;
}
};
declare const _default: {
name: string;
builder: (privateClient: BaseClient) => {

53
dist/places.js vendored
View File

@ -1,31 +1,35 @@
import Geohash from 'latlon-geohash';
import { ulid } from 'ulid';
const placeSchema = {
type: 'object',
properties: {
id: { type: 'string' },
title: { type: 'string' },
lat: { type: 'number' },
lon: { type: 'number' },
geohash: { type: 'string' },
zoom: { type: 'number' },
url: { type: 'string' },
osmId: { type: 'string' },
osmType: { type: 'string' },
osmTags: {
type: 'object',
additionalProperties: { type: 'string' },
},
description: { type: 'string' },
tags: {
type: 'array',
items: { type: 'string' },
default: [],
},
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' },
},
required: ['id', 'title', 'lat', 'lon', 'geohash', 'createdAt'],
};
const Places = function (privateClient /*, publicClient: BaseClient */) {
// Define Schema
privateClient.declareType('place', {
type: 'object',
properties: {
id: { type: 'string', required: true },
title: { type: 'string', required: true },
lat: { type: 'number', required: true },
lon: { type: 'number', required: true },
geohash: { type: 'string', required: true },
zoom: { type: 'number' },
url: { type: 'string' },
osmId: { type: 'string' },
osmType: { type: 'string' },
osmTags: { type: 'object' },
description: { type: 'string' },
tags: {
type: 'array',
items: { type: 'string' },
default: [],
},
createdAt: { type: 'string', format: 'date-time', required: true },
updatedAt: { type: 'string', format: 'date-time' },
},
required: ['id', 'title', 'lat', 'lon', 'geohash', 'createdAt'],
});
privateClient.declareType('place', placeSchema);
// Helper to normalize place object
function preparePlace(data) {
const now = new Date().toISOString();
@ -44,6 +48,7 @@ const Places = function (privateClient /*, publicClient: BaseClient */) {
lon,
geohash,
title,
tags: data.tags || [],
createdAt: data.createdAt || now,
updatedAt: data.id ? now : undefined,
};