@spytecgps/nova-orm 0.0.37 → 0.0.39

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.
@@ -2,5 +2,6 @@ import { BoundariesRepository } from './boundaries';
2
2
  import { ClientsRepository } from './clients';
3
3
  import { DevicesRepository } from './devices';
4
4
  import { FirmwaresRepository } from './firmwares';
5
+ import { PositionRepository } from './positions';
5
6
  import { SecurityRepository } from './security';
6
- export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository, FirmwaresRepository, };
7
+ export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository, FirmwaresRepository, PositionRepository, };
@@ -0,0 +1,6 @@
1
+ import { Position } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { Logger } from '../../types/logger';
4
+ import { CreatePositionParams } from '../../types/position';
5
+ export declare const createPosition: (novaDataSource: NovaDataSource, params: CreatePositionParams, logger: Logger) => Promise<Position>;
6
+ export declare const createPositions: (novaDataSource: NovaDataSource, params: CreatePositionParams[], logger: Logger) => Promise<Position[]>;
@@ -0,0 +1,5 @@
1
+ import { Position } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { Logger } from '../../types/logger';
4
+ import { GetPositionsByImeiParams } from '../../types/position';
5
+ export declare const getPositionsByImei: (novaDataSource: NovaDataSource, params: GetPositionsByImeiParams, logger: Logger) => Promise<Position[]>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { Logger } from '../../types/logger';
3
+ import { GetPositionsReportByClientIdParams, PositionReport } from '../../types/position';
4
+ export declare const getPositionsReportByClientId: (novaDataSource: NovaDataSource, params: GetPositionsReportByClientIdParams, logger: Logger) => Promise<PositionReport[]>;
@@ -0,0 +1,62 @@
1
+ import { Position } from '../../entities';
2
+ import { CreatePositionParams, GetPositionsByImeiParams, GetPositionsReportByClientIdParams, PositionReport } from '../../types/position';
3
+ import { BaseRepository } from '../baseRepository';
4
+ export declare class PositionRepository extends BaseRepository {
5
+ /**
6
+ * Create a position
7
+ * @param {CreatePositionParams} params containing information to create a position
8
+ * - id: position id. if null will be generated
9
+ * - imei: imei of the device reporting the position
10
+ * - lat: the latitude of the position
11
+ * - lon: the longitude of the position
12
+ * - actualDate: the actual date of the message
13
+ * - speed: the speed reported by the device
14
+ * - odometer: the odometer reported by the device
15
+ * - messageId: the id of the message
16
+ * - batteryPercentage: the battery percentage reported by the device
17
+ * - clientId: the client id of owner of the device
18
+ * - address: the address of the position
19
+ * - sendTime: the time the message was sent
20
+ * - gpsUtcTime: the time the gps was set
21
+ * - externalBatteryPercentage: the external battery percentage reported by the device
22
+ */
23
+ createPosition(params: CreatePositionParams): Promise<Position>;
24
+ /**
25
+ * Create a position
26
+ * @param {CreatePositionParams[]} params array containing information to create a positions
27
+ * - id: position id. if null will be generated
28
+ * - imei: imei of the device reporting the position
29
+ * - lat: the latitude of the position
30
+ * - lon: the longitude of the position
31
+ * - actualDate: the actual date of the message
32
+ * - speed: the speed reported by the device
33
+ * - odometer: the odometer reported by the device
34
+ * - messageId: the id of the message
35
+ * - batteryPercentage: the battery percentage reported by the device
36
+ * - clientId: the client id of owner of the device
37
+ * - address: the address of the position
38
+ * - sendTime: the time the message was sent
39
+ * - gpsUtcTime: the time the gps was set
40
+ * - externalBatteryPercentage: the external battery percentage reported by the device
41
+ */
42
+ createPositions(params: CreatePositionParams[]): Promise<Position[]>;
43
+ /**
44
+ * Get positions by imei
45
+ * @param {GetPositionsByImeiParams} params containing information to get positions
46
+ * - filters.imei: filters by imei to get positions
47
+ */
48
+ getPositionsByImei(params: GetPositionsByImeiParams): Promise<Position[]>;
49
+ /**
50
+ * Get positions report by client id
51
+ * @param {GetPositionsReportByClientIdParams} params containing information to get positions
52
+ * - filters.clientId: filters by client id to get positions
53
+ * - filters.imeis: filters by imeis to get positions
54
+ * - filters.actualDateFrom: filters by actual date from to get positions
55
+ * - filters.actualDateTo: filters by actual date to to get positions
56
+ * - filters.speedMin: filters by speed min to get positions
57
+ * - filters.speedMax: filters by speed max to get positions
58
+ * - pageSize: the page size
59
+ * - pageIndex: the page index
60
+ */
61
+ getPositionsReportByClientId(params: GetPositionsReportByClientIdParams): Promise<PositionReport[]>;
62
+ }
@@ -0,0 +1,51 @@
1
+ export interface CreatePositionParams {
2
+ id?: number;
3
+ imei: string;
4
+ lat?: number;
5
+ lon?: number;
6
+ actualDate: Date;
7
+ createdAt?: Date;
8
+ speed?: number;
9
+ odometer?: number;
10
+ messageId: string;
11
+ batteryPercentage?: number;
12
+ clientId: number;
13
+ address?: string;
14
+ sendTime: Date;
15
+ gpsUtcTime?: Date;
16
+ externalBatteryPercentage?: number;
17
+ externalPowerVoltage?: number;
18
+ }
19
+ export interface GetPositionsByImeiParams {
20
+ filters: {
21
+ imei: string;
22
+ };
23
+ }
24
+ export interface GetPositionsReportByClientIdParams {
25
+ filters: {
26
+ clientId: number;
27
+ imeis?: string[] | null;
28
+ actualDateFrom?: Date | null;
29
+ actualDateTo?: Date | null;
30
+ speedMin?: number | null;
31
+ speedMax?: number | null;
32
+ };
33
+ pagingOptions: {
34
+ limit: number | 25;
35
+ offset: number | 1;
36
+ };
37
+ }
38
+ export interface PositionReport {
39
+ imei: string;
40
+ created: Date;
41
+ actualDate: Date;
42
+ lat: number;
43
+ lon: number;
44
+ address: string;
45
+ speed: number;
46
+ odometer: number;
47
+ batteryPercentage: number;
48
+ externalPowerVoltage: number;
49
+ externalBatteryPercentage: number;
50
+ totalCount: number;
51
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "devDependencies": {
8
8
  "@types/jest": "^29.5.1",
9
9
  "@types/node": "^14.18.36",
10
+ "@types/uuid": "^9.0.2",
10
11
  "@typescript-eslint/eslint-plugin": "^5.59.0",
11
12
  "@typescript-eslint/parser": "^5.59.0",
12
13
  "aws-sdk": "^2.877.0",