fix: remove `geo.d.ts`
Use of Template Literal Types broke support for older LB4 projects. Temporarily removing it would have minimal impact as: 1. It was only introduced in the last release 2. It was not usable as-is due to wrong export location fixes: https://github.com/loopbackio/loopback-datasource-juggler/issues/1909 Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
This commit is contained in:
parent
74d429d52d
commit
2691470504
|
@ -34,4 +34,3 @@ export * from './types/observer-mixin';
|
|||
export * from './types/validation-mixin';
|
||||
export * from './types/inclusion-mixin';
|
||||
export * from './types/connector';
|
||||
export * from './types/geo';
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import {GeoDistanceUnit, GeoPoint, filter, nearFilter} from '../geo';
|
||||
|
||||
let numberTypeGuard: number;
|
||||
|
||||
new GeoPoint(123, 456);
|
||||
new GeoPoint('123', 456);
|
||||
new GeoPoint(123, '456');
|
||||
new GeoPoint('123', '456');
|
||||
|
||||
new GeoPoint([123, 456]);
|
||||
new GeoPoint(['123', '456']);
|
||||
new GeoPoint(['123', 456]);
|
||||
new GeoPoint([123, '456']);
|
||||
|
||||
new GeoPoint({lat: 123, lng: 456});
|
||||
new GeoPoint({lat: '123', lng: 456})
|
||||
new GeoPoint({lat: 123, lng: '456'})
|
||||
new GeoPoint({lat: '123', lng: '456'});
|
||||
|
||||
numberTypeGuard = GeoPoint.distanceBetwen([123, 456], [123, 456]);
|
||||
numberTypeGuard = GeoPoint.distanceBetwen([123, 456], [123, 456], {type: GeoDistanceUnit.degrees});
|
||||
|
||||
const geoPoint = new GeoPoint(123, 456);
|
||||
numberTypeGuard = geoPoint.distanceTo([123, 456])
|
||||
numberTypeGuard = geoPoint.distanceTo([123, 456], {type: GeoDistanceUnit.degrees});
|
|
@ -1,122 +0,0 @@
|
|||
import { Where } from "./query";
|
||||
|
||||
export function nearFilter(where: Where): false | GeoPointFilter[];
|
||||
|
||||
export function filter(rawResults: GeoPointRawResult[], filters: GeoPointFilter[]): GeoPointFilter;
|
||||
|
||||
export type GeoPointFilter = {
|
||||
near: GeoPoint | ConstructorParameters<typeof GeoPoint>;
|
||||
maxDistance: number;
|
||||
minDistance: number;
|
||||
unit: GeoDistanceUnit;
|
||||
mongoKey: string;
|
||||
key: string;
|
||||
}
|
||||
|
||||
export type GeoPointRawResult = {
|
||||
[key: string]: {
|
||||
lat: number;
|
||||
lng: number;
|
||||
}
|
||||
}
|
||||
|
||||
export class GeoPoint {
|
||||
lat: number;
|
||||
lng: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint({
|
||||
* lat: 145,
|
||||
* lng: 96,
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint({
|
||||
* lat: '145',
|
||||
* lng: '96',
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
constructor(data: {
|
||||
lat: string | number,
|
||||
lng: string | number,
|
||||
})
|
||||
|
||||
/**
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint('145,96');
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint('145 , 96');
|
||||
* ```
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
constructor(data: `${number},${number}`)
|
||||
|
||||
/**
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint([145, 96]);
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint(['145', '96']);
|
||||
* ```
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
constructor(data: [string | number, string | number])
|
||||
|
||||
/**
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint(145, 96);
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* new GeoPoint('145', '96');
|
||||
* ```
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
constructor(lat: string | number, lng: string | number)
|
||||
|
||||
static distanceBetwen(
|
||||
a: GeoPoint | ConstructorParameters<typeof GeoPoint>,
|
||||
b: GeoPoint | ConstructorParameters<typeof GeoPoint>,
|
||||
options?: GeoDistanceOptions,
|
||||
): number;
|
||||
|
||||
distanceTo(
|
||||
point: GeoPoint | ConstructorParameters<typeof GeoPoint>,
|
||||
options?: GeoDistanceOptions,
|
||||
): number;
|
||||
|
||||
toString(): `$${number},${number}`;
|
||||
}
|
||||
|
||||
export type GeoDistanceOptions = {
|
||||
type: GeoDistanceUnit;
|
||||
}
|
||||
|
||||
export enum GeoDistanceUnit {
|
||||
'kilometers',
|
||||
'meters',
|
||||
'miles',
|
||||
'feet',
|
||||
'radians',
|
||||
'degrees',
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
import {DateString} from './date-string';
|
||||
import {GeoPoint} from './geo';
|
||||
|
||||
// @achrinza: The return value is a hack to inform TypeScript of function parameter mutations.
|
||||
// see: https://github.com/microsoft/TypeScript/issues/22865#issuecomment-725015710
|
||||
|
@ -57,7 +56,7 @@ declare namespace registerModelTypes {
|
|||
'Buffer': Buffer;
|
||||
'Array': Array<unknown>;
|
||||
'Object': Object;
|
||||
'GeoPoint': GeoPoint
|
||||
// 'GeoPoint': GeoPoint // Removed temporarily. See: https://github.com/loopbackio/loopback-datasource-juggler/issues/1909
|
||||
};
|
||||
registerType: (type: Type, names?: string[]) => void;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue