@spytecgps/nova-orm 0.0.51 → 0.0.52

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.
@@ -0,0 +1,5 @@
1
+ import { Alert } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateAlertParams } from '../../types/alert';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createAlert: (novaDataSource: NovaDataSource, params: CreateAlertParams, logger: Logger) => Promise<Alert>;
@@ -0,0 +1,7 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { AlertReport, GetAlertReportByClientParams } from '../../types/alert';
3
+ import { Logger } from '../../types/logger';
4
+ /**
5
+ * @deprecated The method should not be used
6
+ */
7
+ export declare const getAlertsReportByClient: (novaDataSource: NovaDataSource, params: GetAlertReportByClientParams, logger: Logger) => Promise<AlertReport[]>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { AlertReport, GetAlertReportByUserParams } from '../../types/alert';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const getAlertsReportByUser: (novaDataSource: NovaDataSource, params: GetAlertReportByUserParams, logger: Logger) => Promise<AlertReport[]>;
@@ -0,0 +1,43 @@
1
+ import { Alert } from '../../entities';
2
+ import { AlertReport, CreateAlertParams, GetAlertReportByUserParams } from '../../types/alert';
3
+ import { BaseRepository } from '../baseRepository';
4
+ export declare class AlertRepository extends BaseRepository {
5
+ /** Create an alert record
6
+ * @param {CreateAlertParams} params containing information to create an alert
7
+ * id: The alert id. if null will be generated
8
+ * clientId: The client id of the owner of the device generating the alert
9
+ * deviceId: The device id of the device generating the alert
10
+ * alertTypeId: The alert type id
11
+ * value: The alert value
12
+ * userId: The user id of the user associated with the alert
13
+ * messageId: The message id of the message that generated the alert
14
+ * boundaryId: The boundary id of the boundary if the alert is related to a boundary
15
+ * imei: The imei of the device generating the alert
16
+ * sendTime: The time the alert was sent
17
+ * lat: The latitude of the device when the alert was generated
18
+ * lon: The longitude of the device when the alert was generated
19
+ * address: The address of the device when the alert was generated
20
+ * isBuffer: The is buffer flag
21
+ * isNotification: The is notification flag
22
+ * gpsUtcTime: The time the gps utc time was set
23
+ * relevantAddress: The relevant address
24
+ * gpsMessageId: The gps message id
25
+ * cellTowerRelevantAddress: The cell tower relevant address
26
+ */
27
+ createAlert(params: CreateAlertParams): Promise<Alert>;
28
+ /** Get alerts report by user id
29
+ * @param {GetAlertReportByUserParams} params containing information to filter alerts report by user id
30
+ * params.filters.userId: The user id of the user associated with the alert
31
+ * params.filters.imeis: The imeis of the devices generating the alert
32
+ * params.filters.alertTypeId: The alert type id
33
+ * params.filters.boundaryId: The boundary id of the boundary if the alert is related to a boundary
34
+ * params.filters.sendTimeFrom: The time the alert was sent from
35
+ * params.filters.sendTimeTo: The time the alert was sent to
36
+ * params.pagingOptions.pageSize: The number of alerts to return
37
+ * params.pagingOptions.pageIndex: The page index of the alerts to return
38
+ * params.sortOptions.sortField: The field to sort the alerts by
39
+ * params.sortOptions.sortOrder: The order to sort the alerts by desc | asc
40
+ * @returns Promise<AlertReport[]>
41
+ */
42
+ getAlertsReportByUser(params: GetAlertReportByUserParams): Promise<AlertReport[]>;
43
+ }
@@ -1,3 +1,4 @@
1
+ import { AlertRepository } from './alerts';
1
2
  import { BoundariesRepository } from './boundaries';
2
3
  import { ClientsRepository } from './clients';
3
4
  import { CountriesRepository } from './countries';
@@ -7,4 +8,4 @@ import { PositionRepository } from './positions';
7
8
  import { SecurityRepository } from './security';
8
9
  import { UserInvitationsRepository } from './userInvitations';
9
10
  import { UsersRepository } from './users';
10
- export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository, FirmwaresRepository, PositionRepository, UsersRepository, CountriesRepository, UserInvitationsRepository, };
11
+ export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository, FirmwaresRepository, PositionRepository, AlertRepository, UsersRepository, CountriesRepository, UserInvitationsRepository, };
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { Logger } from '../../types/logger';
3
+ import { GetPositionsReportByClientParams, PositionReport } from '../../types/position';
4
+ export declare const getPositionsReportByClient: (novaDataSource: NovaDataSource, params: GetPositionsReportByClientParams, logger: Logger) => Promise<PositionReport[]>;
@@ -1,5 +1,5 @@
1
1
  import { Position } from '../../entities';
2
- import { CreatePositionParams, GetPositionsByImeiParams, GetPositionsReportByClientIdParams, PositionReport } from '../../types/position';
2
+ import { CreatePositionParams, GetPositionsByImeiParams, GetPositionsReportByClientParams, PositionReport } from '../../types/position';
3
3
  import { BaseRepository } from '../baseRepository';
4
4
  export declare class PositionRepository extends BaseRepository {
5
5
  /**
@@ -48,7 +48,7 @@ export declare class PositionRepository extends BaseRepository {
48
48
  getPositionsByImei(params: GetPositionsByImeiParams): Promise<Position[]>;
49
49
  /**
50
50
  * Get positions report by client id
51
- * @param {GetPositionsReportByClientIdParams} params containing information to get positions
51
+ * @param {GetPositionsReportByClientParams} params containing information to get positions
52
52
  * - filters.clientId: filters by client id to get positions
53
53
  * - filters.imeis: filters by imeis to get positions
54
54
  * - filters.actualDateFrom: filters by actual date from to get positions
@@ -58,5 +58,5 @@ export declare class PositionRepository extends BaseRepository {
58
58
  * - pageSize: the page size
59
59
  * - pageIndex: the page index
60
60
  */
61
- getPositionsReportByClientId(params: GetPositionsReportByClientIdParams): Promise<PositionReport[]>;
61
+ getPositionsReportByClient(params: GetPositionsReportByClientParams): Promise<PositionReport[]>;
62
62
  }
@@ -0,0 +1,74 @@
1
+ /// <reference types="node" />
2
+ export interface CreateAlertParams {
3
+ id?: number;
4
+ alertTypeId: number;
5
+ value?: string;
6
+ userId?: string;
7
+ messageId: string;
8
+ boundaryId?: number;
9
+ deviceId?: number;
10
+ imei: string;
11
+ sendTime: Date;
12
+ lat?: number;
13
+ lon?: number;
14
+ address?: string;
15
+ clientId: number;
16
+ isBuffer?: boolean | null;
17
+ isNotification?: boolean | null;
18
+ gpsUtcTime?: Date;
19
+ relevantAddress?: string;
20
+ gpsMessageId?: string;
21
+ cellTowerRelevantAddress?: string;
22
+ createdAt?: Date;
23
+ }
24
+ export interface ReportPagination {
25
+ pagingOptions: {
26
+ pageSize: number | 25;
27
+ pageIndex: number | 1;
28
+ };
29
+ sortOptions?: {
30
+ sortField: string;
31
+ sortOrder: 'ASC' | 'DESC';
32
+ };
33
+ }
34
+ export interface GetAlertReportByUserParams extends ReportPagination {
35
+ filters: {
36
+ userId: string;
37
+ imeis: string[];
38
+ isTestEnvironment?: boolean | false;
39
+ alertTypeIds?: number[] | null;
40
+ boundaryId?: number | null;
41
+ sendTimeFrom?: Date | null;
42
+ sendTimeTo?: Date | null;
43
+ };
44
+ }
45
+ export interface GetAlertReportByClientParams extends ReportPagination {
46
+ filters: {
47
+ clientId: number;
48
+ imei?: string | null;
49
+ alertTypeId?: number | null;
50
+ boundaryId?: number | null;
51
+ sendTimeFrom?: Date | null;
52
+ sendTimeTo?: Date | null;
53
+ };
54
+ }
55
+ export interface AlertReport {
56
+ id: number;
57
+ alertTypeId: number;
58
+ value?: string | null;
59
+ createdAt: Date;
60
+ userId: Buffer;
61
+ messageId: Buffer;
62
+ boundaryId?: number | null;
63
+ imei: string;
64
+ sendTime: Date;
65
+ lat?: number | null;
66
+ lon?: number | null;
67
+ address?: string | null;
68
+ isBuffer?: boolean | null;
69
+ isNotification?: boolean | null;
70
+ gpsMessageId?: Buffer | null;
71
+ gpsUTCTime?: Date | null;
72
+ stage?: string | null;
73
+ totalCount: number;
74
+ }
@@ -21,7 +21,7 @@ export interface GetPositionsByImeiParams {
21
21
  imei: string;
22
22
  };
23
23
  }
24
- export interface GetPositionsReportByClientIdParams {
24
+ export interface GetPositionsReportByClientParams {
25
25
  filters: {
26
26
  clientId: number;
27
27
  imeis?: string[] | null;
@@ -31,8 +31,8 @@ export interface GetPositionsReportByClientIdParams {
31
31
  speedMax?: number | null;
32
32
  };
33
33
  pagingOptions: {
34
- limit: number | 25;
35
- offset: number | 1;
34
+ pageSize: number | 25;
35
+ pageIndex: number | 1;
36
36
  };
37
37
  }
38
38
  export interface PositionReport {
@@ -0,0 +1,4 @@
1
+ export declare const getRandomBoolean: () => boolean;
2
+ export declare const getRandomInteger: (max: number) => number;
3
+ export declare const getRandomString: (length: number) => string;
4
+ export declare const getRandomImei: (length?: number) => string;
@@ -1,2 +1,2 @@
1
1
  export declare const uuidStringToBinaryBuffer: (uuidString: string) => Buffer;
2
- export declare const binaryBufferToUuidString: (buffer: Buffer) => string;
2
+ export declare const binaryBufferToUuidString: (buffer: Buffer | null) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,4 +0,0 @@
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[]>;