1.0.0
This commit is contained in:
76
dist/places.d.ts
vendored
76
dist/places.d.ts
vendored
@@ -1,21 +1,65 @@
|
|||||||
import BaseClient from 'remotestoragejs/release/types/baseclient';
|
import BaseClient from 'remotestoragejs/release/types/baseclient';
|
||||||
interface Place {
|
import { FromSchema } from 'json-schema-to-ts';
|
||||||
id: string;
|
declare const placeSchema: {
|
||||||
title: string;
|
readonly type: "object";
|
||||||
lat: number;
|
readonly properties: {
|
||||||
lon: number;
|
readonly id: {
|
||||||
geohash: string;
|
readonly type: "string";
|
||||||
zoom?: number;
|
};
|
||||||
url?: string;
|
readonly title: {
|
||||||
osmId?: string;
|
readonly type: "string";
|
||||||
osmType?: string;
|
};
|
||||||
osmTags?: Record<string, string>;
|
readonly lat: {
|
||||||
description?: string;
|
readonly type: "number";
|
||||||
tags?: string[];
|
};
|
||||||
createdAt: string;
|
readonly lon: {
|
||||||
updatedAt?: string;
|
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;
|
[key: string]: any;
|
||||||
}
|
};
|
||||||
declare const _default: {
|
declare const _default: {
|
||||||
name: string;
|
name: string;
|
||||||
builder: (privateClient: BaseClient) => {
|
builder: (privateClient: BaseClient) => {
|
||||||
|
|||||||
53
dist/places.js
vendored
53
dist/places.js
vendored
@@ -1,31 +1,35 @@
|
|||||||
import Geohash from 'latlon-geohash';
|
import Geohash from 'latlon-geohash';
|
||||||
import { ulid } from 'ulid';
|
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 */) {
|
const Places = function (privateClient /*, publicClient: BaseClient */) {
|
||||||
// Define Schema
|
// Define Schema
|
||||||
privateClient.declareType('place', {
|
privateClient.declareType('place', placeSchema);
|
||||||
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'],
|
|
||||||
});
|
|
||||||
// Helper to normalize place object
|
// Helper to normalize place object
|
||||||
function preparePlace(data) {
|
function preparePlace(data) {
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
@@ -44,6 +48,7 @@ const Places = function (privateClient /*, publicClient: BaseClient */) {
|
|||||||
lon,
|
lon,
|
||||||
geohash,
|
geohash,
|
||||||
title,
|
title,
|
||||||
|
tags: data.tags || [],
|
||||||
createdAt: data.createdAt || now,
|
createdAt: data.createdAt || now,
|
||||||
updatedAt: data.id ? now : undefined,
|
updatedAt: data.id ? now : undefined,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user