@lyxa.ai/core 1.3.185 → 1.3.186

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MapService = exports.MapProvider = void 0;
4
+ const distance_1 = require("../../utilities/shared/distance");
4
5
  var MapProvider;
5
6
  (function (MapProvider) {
6
7
  MapProvider["GOOGLE"] = "google";
@@ -14,18 +15,7 @@ class MapService {
14
15
  this.osrm = osrm;
15
16
  }
16
17
  calculateHaversineDistance(coord1, coord2) {
17
- const [lat1, lon1] = coord1;
18
- const [lat2, lon2] = coord2;
19
- const R = 6371;
20
- const dLat = ((lat2 - lat1) * Math.PI) / 180;
21
- const dLon = ((lon2 - lon1) * Math.PI) / 180;
22
- const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
23
- Math.cos((lat1 * Math.PI) / 180) *
24
- Math.cos((lat2 * Math.PI) / 180) *
25
- Math.sin(dLon / 2) *
26
- Math.sin(dLon / 2);
27
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
28
- return R * c;
18
+ return (0, distance_1.haversineDistance)(coord1, coord2);
29
19
  }
30
20
  getProvider(options) {
31
21
  const provider = options?.provider ?? MapProvider.OSRM;
@@ -1 +1 @@
1
- {"version":3,"file":"mapService.js","sourceRoot":"/","sources":["libraries/map/mapService.ts"],"names":[],"mappings":";;;AAUA,IAAY,WAGX;AAHD,WAAY,WAAW;IACtB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;AACd,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAOD,MAAa,UAAU;IACd,MAAM,CAAoB;IAC1B,IAAI,CAAiB;IAE7B,YAAY,MAAyB,EAAE,IAAoB;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAEM,0BA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AAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,iBAAiB,CACtB,OAA2B,EAC3B,YAAgC,EAChC,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACjF,CAAC;CACD;AArFD,gCAqFC","sourcesContent":["import { GoogleMapsService } from './providers/google-maps';\nimport { OsrmMapService } from './providers/osrm';\nimport {\n\tICoordinate,\n\tIDistanceInfo,\n\tIMapService,\n\tIRouteMatrixDTO,\n\tIWaypointDistanceInfo,\n} from './interfaces/IMapService';\n\nexport enum MapProvider {\n\tGOOGLE = 'google',\n\tOSRM = 'osrm',\n}\n\nexport interface MapOptions {\n\tprovider: MapProvider;\n\t// Add other options if needed\n}\n\nexport class MapService {\n\tprivate google: GoogleMapsService;\n\tprivate osrm: OsrmMapService;\n\n\tconstructor(google: GoogleMapsService, osrm: OsrmMapService) {\n\t\tthis.google = google;\n\t\tthis.osrm = osrm;\n\t}\n\n\tpublic calculateHaversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\t\tconst [lat1, lon1] = coord1;\n\t\tconst [lat2, lon2] = coord2;\n\t\tconst R = 6371;\n\t\tconst dLat = ((lat2 - lat1) * Math.PI) / 180;\n\t\tconst dLon = ((lon2 - lon1) * Math.PI) / 180;\n\t\tconst a =\n\t\t\tMath.sin(dLat / 2) * Math.sin(dLat / 2) +\n\t\t\tMath.cos((lat1 * Math.PI) / 180) *\n\t\t\t\tMath.cos((lat2 * Math.PI) / 180) *\n\t\t\t\tMath.sin(dLon / 2) *\n\t\t\t\tMath.sin(dLon / 2);\n\t\tconst c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\t\treturn R * c;\n\t}\n\tprivate getProvider(options?: MapOptions): IMapService {\n\t\t// Default to OSRM if options not provided\n\t\tconst provider = options?.provider ?? MapProvider.OSRM;\n\n\t\tswitch (provider) {\n\t\t\tcase MapProvider.GOOGLE:\n\t\t\t\treturn this.google;\n\t\t\tcase MapProvider.OSRM:\n\t\t\t\treturn this.osrm;\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Unknown map provider');\n\t\t}\n\t}\n\n\tpublic async calculateDistanceBetweenCoordinates(\n\t\tcoord1: [number, number],\n\t\tcoord2: [number, number],\n\t\toptions?: MapOptions // optional\n\t): Promise<number> {\n\t\tconst [lon1, lat1] = coord1;\n\t\tconst [lon2, lat2] = coord2;\n\n\t\ttry {\n\t\t\tconst distanceInfo = await this.getProvider(options).getDistanceInfo(\n\t\t\t\t{ latitude: lat1, longitude: lon1 },\n\t\t\t\t{ latitude: lat2, longitude: lon2 }\n\t\t\t);\n\t\t\tif (distanceInfo && distanceInfo.distance) {\n\t\t\t\treturn distanceInfo.distance.value / 1000;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Error fetching distance info: ${error}`);\n\t\t}\n\t\tconsole.log('Maps API failed. Falling back to Haversine calculation.');\n\t\treturn this.calculateHaversineDistance(coord1, coord2);\n\t}\n\n\tasync getDistanceInfo(\n\t\torigin: ICoordinate,\n\t\tdestination: ICoordinate,\n\t\toptions?: MapOptions\n\t): Promise<IDistanceInfo> {\n\t\treturn await this.getProvider(options).getDistanceInfo(origin, destination);\n\t}\n\n\tasync getWaypointsDistanceInfo(\n\t\torigin: ICoordinate,\n\t\tdestination: ICoordinate,\n\t\twaypoints: Array<ICoordinate>,\n\t\toptions?: MapOptions\n\t): Promise<IWaypointDistanceInfo> {\n\t\treturn await this.getProvider(options).getWaypointsDistanceInfo(origin, destination, waypoints);\n\t}\n\n\tasync getDistanceMatrix(\n\t\torigins: Array<ICoordinate>,\n\t\tdestinations: Array<ICoordinate>,\n\t\toptions?: MapOptions\n\t): Promise<IRouteMatrixDTO[]> {\n\t\treturn await this.getProvider(options).getDistanceMat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,EAAE,EACnC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CACnC,CAAC;YACF,IAAI,YAAY,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;gBAC3C,OAAO,YAAY,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;YAC3C,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,eAAe,CACpB,MAAmB,EACnB,WAAwB,EACxB,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,wBAAwB,CAC7B,MAAmB,EACnB,WAAwB,EACxB,SAA6B,EAC7B,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,iBAAiB,CACtB,OAA2B,EAC3B,YAAgC,EAChC,OAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACjF,CAAC;CACD;AAhFD,gCAgFC","sourcesContent":["import { GoogleMapsService } from './providers/google-maps';\nimport { OsrmMapService } from './providers/osrm';\nimport {\n\tICoordinate,\n\tIDistanceInfo,\n\tIMapService,\n\tIRouteMatrixDTO,\n\tIWaypointDistanceInfo,\n} from './interfaces/IMapService';\nimport { haversineDistance } from '../../utilities/shared/distance';\n\nexport enum MapProvider {\n\tGOOGLE = 'google',\n\tOSRM = 'osrm',\n}\n\nexport interface MapOptions {\n\tprovider: MapProvider;\n\t// Add other options if needed\n}\n\nexport class MapService {\n\tprivate google: GoogleMapsService;\n\tprivate osrm: OsrmMapService;\n\n\tconstructor(google: GoogleMapsService, osrm: OsrmMapService) {\n\t\tthis.google = google;\n\t\tthis.osrm = osrm;\n\t}\n\n\t/**\n\t *\n\t * @param coord1 [latitude, longitude]\n\t * @param coord2 [latitude, longitude]\n\t * @returns straight line distance in KM\n\t */\n\tpublic calculateHaversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\t\treturn haversineDistance(coord1, coord2);\n\t}\n\t\n\tprivate getProvider(options?: MapOptions): IMapService {\n\t\t// Default to OSRM if options not provided\n\t\tconst provider = options?.provider ?? MapProvider.OSRM;\n\n\t\tswitch (provider) {\n\t\t\tcase MapProvider.GOOGLE:\n\t\t\t\treturn this.google;\n\t\t\tcase MapProvider.OSRM:\n\t\t\t\treturn this.osrm;\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Unknown map provider');\n\t\t}\n\t}\n\n\tpublic async calculateDistanceBetweenCoordinates(\n\t\tcoord1: [number, number],\n\t\tcoord2: [number, number],\n\t\toptions?: MapOptions // optional\n\t): Promise<number> {\n\t\tconst [lon1, lat1] = coord1;\n\t\tconst [lon2, lat2] = coord2;\n\n\t\ttry {\n\t\t\tconst distanceInfo = await this.getProvider(options).getDistanceInfo(\n\t\t\t\t{ latitude: lat1, longitude: lon1 },\n\t\t\t\t{ latitude: lat2, longitude: lon2 }\n\t\t\t);\n\t\t\tif (distanceInfo && distanceInfo.distance) {\n\t\t\t\treturn distanceInfo.distance.value / 1000;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Error fetching distance info: ${error}`);\n\t\t}\n\t\tconsole.log('Maps API failed. Falling back to Haversine calculation.');\n\t\treturn this.calculateHaversineDistance(coord1, coord2);\n\t}\n\n\tasync getDistanceInfo(\n\t\torigin: ICoordinate,\n\t\tdestination: ICoordinate,\n\t\toptions?: MapOptions\n\t): Promise<IDistanceInfo> {\n\t\treturn await this.getProvider(options).getDistanceInfo(origin, destination);\n\t}\n\n\tasync getWaypointsDistanceInfo(\n\t\torigin: ICoordinate,\n\t\tdestination: ICoordinate,\n\t\twaypoints: Array<ICoordinate>,\n\t\toptions?: MapOptions\n\t): Promise<IWaypointDistanceInfo> {\n\t\treturn await this.getProvider(options).getWaypointsDistanceInfo(origin, destination, waypoints);\n\t}\n\n\tasync getDistanceMatrix(\n\t\torigins: Array<ICoordinate>,\n\t\tdestinations: Array<ICoordinate>,\n\t\toptions?: MapOptions\n\t): Promise<IRouteMatrixDTO[]> {\n\t\treturn await this.getProvider(options).getDistanceMatrix(origins, destinations);\n\t}\n}\n"]}
@@ -5,10 +5,10 @@ interface AuthOptions {
5
5
  autoRefresh?: boolean;
6
6
  }
7
7
  export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
8
- req: import("http").IncomingMessage;
9
8
  res: import("http").ServerResponse<import("http").IncomingMessage>;
10
9
  tokenType: TokenType | undefined;
11
10
  entity: import("../context").EntityContext | undefined;
11
+ req: import("http").IncomingMessage;
12
12
  requestId: string | undefined;
13
13
  usedRefreshToken: boolean | undefined;
14
14
  tokenRenewed: boolean | undefined;
@@ -4,10 +4,10 @@ interface RoleProtectedOptions {
4
4
  allowedRoles: string[];
5
5
  }
6
6
  export declare function createRoleProtectedProcedure(options: RoleProtectedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
7
- req: import("http").IncomingMessage;
8
7
  res: import("http").ServerResponse<import("http").IncomingMessage>;
9
8
  tokenType: import("../../auth").TokenType | undefined;
10
9
  entity: import("../context").EntityContext | undefined;
10
+ req: import("http").IncomingMessage;
11
11
  requestId: string | undefined;
12
12
  usedRefreshToken: boolean | undefined;
13
13
  tokenRenewed: boolean | undefined;
@@ -3,10 +3,10 @@ interface PhoneVerifiedOptions {
3
3
  entityTypes: AuthEntityType[];
4
4
  }
5
5
  export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
6
- req: import("http").IncomingMessage;
7
6
  res: import("http").ServerResponse<import("http").IncomingMessage>;
8
7
  tokenType: import("../../auth").TokenType | undefined;
9
8
  entity: import("../context").EntityContext | undefined;
9
+ req: import("http").IncomingMessage;
10
10
  requestId: string | undefined;
11
11
  usedRefreshToken: boolean | undefined;
12
12
  tokenRenewed: boolean | undefined;
@@ -5,10 +5,10 @@ interface AuthOptions {
5
5
  autoRefresh?: boolean;
6
6
  }
7
7
  export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
8
- req: import("http").IncomingMessage;
9
8
  res: import("http").ServerResponse<import("http").IncomingMessage>;
10
9
  tokenType: TokenType | undefined;
11
10
  entity: import("../context").EntityContext | undefined;
11
+ req: import("http").IncomingMessage;
12
12
  requestId: string | undefined;
13
13
  usedRefreshToken: boolean | undefined;
14
14
  tokenRenewed: boolean | undefined;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.3.185
25
+ Version: 1.3.186
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.3.185",
3
+ "version": "1.3.186",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -0,0 +1 @@
1
+ export declare function haversineDistance(coord1: [number, number], coord2: [number, number]): number;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.haversineDistance = haversineDistance;
4
+ function haversineDistance(coord1, coord2) {
5
+ const [lat1, lon1] = coord1;
6
+ const [lat2, lon2] = coord2;
7
+ const R = 6371;
8
+ const dLat = ((lat2 - lat1) * Math.PI) / 180;
9
+ const dLon = ((lon2 - lon1) * Math.PI) / 180;
10
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
11
+ Math.cos((lat1 * Math.PI) / 180) *
12
+ Math.cos((lat2 * Math.PI) / 180) *
13
+ Math.sin(dLon / 2) *
14
+ Math.sin(dLon / 2);
15
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
16
+ return R * c;
17
+ }
18
+ //# sourceMappingURL=distance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distance.js","sourceRoot":"/","sources":["utilities/shared/distance.ts"],"names":[],"mappings":";;AAMA,8CAcC;AAdD,SAAgB,iBAAiB,CAAC,MAAwB,EAAE,MAAwB;IACnF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,CAAC,GACN,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC","sourcesContent":["/**\n * Calculates the Haversine distance between two coordinates.\n * @param coord1 [latitude, longitude]\n * @param coord2 [latitude, longitude]\n * @returns straight line distance in KM\n */\nexport function haversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\tconst [lat1, lon1] = coord1;\n\tconst [lat2, lon2] = coord2;\n\tconst R = 6371;\n\tconst dLat = ((lat2 - lat1) * Math.PI) / 180;\n\tconst dLon = ((lon2 - lon1) * Math.PI) / 180;\n\tconst a =\n\t\tMath.sin(dLat / 2) * Math.sin(dLat / 2) +\n\t\tMath.cos((lat1 * Math.PI) / 180) *\n\t\t\tMath.cos((lat2 * Math.PI) / 180) *\n\t\t\tMath.sin(dLon / 2) *\n\t\t\tMath.sin(dLon / 2);\n\tconst c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\treturn R * c;\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function haversineDistance(coord1: [number, number], coord2: [number, number]): number;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.haversineDistance = haversineDistance;
4
+ function haversineDistance(coord1, coord2) {
5
+ const [lat1, lon1] = coord1;
6
+ const [lat2, lon2] = coord2;
7
+ const R = 6371;
8
+ const dLat = ((lat2 - lat1) * Math.PI) / 180;
9
+ const dLon = ((lon2 - lon1) * Math.PI) / 180;
10
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
11
+ Math.cos((lat1 * Math.PI) / 180) *
12
+ Math.cos((lat2 * Math.PI) / 180) *
13
+ Math.sin(dLon / 2) *
14
+ Math.sin(dLon / 2);
15
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
16
+ return R * c;
17
+ }
18
+ //# sourceMappingURL=distance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distance.js","sourceRoot":"/","sources":["utilities/shared/distance.ts"],"names":[],"mappings":";;AAMA,8CAcC;AAdD,SAAgB,iBAAiB,CAAC,MAAwB,EAAE,MAAwB;IACnF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,CAAC,GACN,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC","sourcesContent":["/**\n * Calculates the Haversine distance between two coordinates.\n * @param coord1 [latitude, longitude]\n * @param coord2 [latitude, longitude]\n * @returns straight line distance in KM\n */\nexport function haversineDistance(coord1: [number, number], coord2: [number, number]): number {\n\tconst [lat1, lon1] = coord1;\n\tconst [lat2, lon2] = coord2;\n\tconst R = 6371;\n\tconst dLat = ((lat2 - lat1) * Math.PI) / 180;\n\tconst dLon = ((lon2 - lon1) * Math.PI) / 180;\n\tconst a =\n\t\tMath.sin(dLat / 2) * Math.sin(dLat / 2) +\n\t\tMath.cos((lat1 * Math.PI) / 180) *\n\t\t\tMath.cos((lat2 * Math.PI) / 180) *\n\t\t\tMath.sin(dLon / 2) *\n\t\t\tMath.sin(dLon / 2);\n\tconst c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\treturn R * c;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.3.185",
3
+ "version": "1.3.186",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",