@spytecgps/nova-orm 1.0.10 → 1.0.12

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.
@@ -18,6 +18,7 @@ export const createClientDeviceSetting = async (novaDataSource, params, logger)
18
18
  offlineThresholdMinutes: params.offlineThresholdMinutes,
19
19
  movementThresholdSpeed: params.movementThresholdSpeed,
20
20
  externalBatteryInformation: params.externalBatteryInformation,
21
+ reportingMode: params.reportingMode,
21
22
  };
22
23
  const result = await clientDeviceSettingRepository.save(newClientDeviceSetting);
23
24
  return result;
@@ -40,6 +40,15 @@ export const getDevices = async (novaDataSource, params, logger) => {
40
40
  if (params.projectionOptions.withClientDeviceSettings) {
41
41
  queryBuilder = queryBuilder.leftJoinAndMapOne('device.clientDeviceSetting', ClientDeviceSetting, 'clientDeviceSetting', 'device.imei = clientDeviceSetting.imei and device.clientId = clientDeviceSetting.clientId');
42
42
  }
43
+ if (params?.sortOptions?.sortField) {
44
+ queryBuilder = queryBuilder.orderBy(`device.${params.sortOptions.sortField}`, params?.sortOptions?.sortOrder ?? 'ASC');
45
+ }
46
+ if (params?.pagingOptions?.pageIndex) {
47
+ const pageSize = params?.pagingOptions?.pageSize ?? 1000;
48
+ const realPageIndex = (params?.pagingOptions?.pageIndex ?? 1) - 1;
49
+ queryBuilder = queryBuilder.offset(realPageIndex * pageSize);
50
+ queryBuilder = queryBuilder.limit(pageSize);
51
+ }
43
52
  const devices = await queryBuilder.getMany();
44
53
  return devices;
45
54
  }, 'DevicesRepository::getDevices');
@@ -11,7 +11,8 @@ export const updateClientDeviceSetting = async (novaDataSource, params, logger)
11
11
  !params?.values?.stopThresholdMinutes &&
12
12
  !params?.values?.offlineThresholdMinutes &&
13
13
  !params?.values?.movementThresholdSpeed &&
14
- params?.values?.externalBatteryInformation == null) {
14
+ params?.values?.externalBatteryInformation == null &&
15
+ !params?.values?.reportingMode) {
15
16
  logger.warn({ params }, 'DevicesRepository::updateClientDeviceSetting missing required parameters');
16
17
  return false;
17
18
  }
@@ -29,6 +30,7 @@ export const updateClientDeviceSetting = async (novaDataSource, params, logger)
29
30
  offlineThresholdMinutes: params.values.offlineThresholdMinutes,
30
31
  movementThresholdSpeed: params.values.movementThresholdSpeed,
31
32
  externalBatteryInformation: params.values.externalBatteryInformation,
33
+ reportingMode: params.values.reportingMode,
32
34
  })
33
35
  .where('imei = :imei', { imei: params.filters.imei })
34
36
  .andWhere('clientId = :clientId', { clientId: params.filters.clientId });
@@ -4,3 +4,9 @@ export interface ReportPagination {
4
4
  pageIndex: number | 0;
5
5
  };
6
6
  }
7
+ export interface OptionalReportPagination {
8
+ pagingOptions?: {
9
+ pageSize?: number;
10
+ pageIndex?: number;
11
+ };
12
+ }
@@ -1,3 +1,4 @@
1
+ import { OptionalReportPagination } from './common';
1
2
  import { DeviceStatus } from './enums';
2
3
  export interface GetDeviceParams {
3
4
  filters: {
@@ -10,7 +11,7 @@ export interface GetDeviceParams {
10
11
  withClientDeviceSettings: boolean;
11
12
  };
12
13
  }
13
- export interface GetDevicesParams {
14
+ export interface GetDevicesParams extends OptionalReportPagination {
14
15
  filters: {
15
16
  deviceTypeId?: number;
16
17
  status?: DeviceStatus;
@@ -18,9 +19,13 @@ export interface GetDevicesParams {
18
19
  imeiList?: string[];
19
20
  };
20
21
  projectionOptions: {
21
- withDeviceType: boolean;
22
- withIccidCarrier: boolean;
23
- withClientDeviceSettings: boolean;
22
+ withDeviceType?: boolean;
23
+ withIccidCarrier?: boolean;
24
+ withClientDeviceSettings?: boolean;
25
+ };
26
+ sortOptions?: {
27
+ sortField?: 'name';
28
+ sortOrder?: 'ASC' | 'DESC';
24
29
  };
25
30
  }
26
31
  export interface AllImeisAreActiveForClientParams {
@@ -150,6 +155,7 @@ export interface CreateClientDeviceSettingParams {
150
155
  offlineThresholdMinutes?: number;
151
156
  movementThresholdSpeed?: number;
152
157
  externalBatteryInformation?: boolean;
158
+ reportingMode?: string;
153
159
  }
154
160
  export interface UpdateClientDeviceSettingParams {
155
161
  filters: {
@@ -165,6 +171,7 @@ export interface UpdateClientDeviceSettingParams {
165
171
  offlineThresholdMinutes?: number;
166
172
  movementThresholdSpeed?: number;
167
173
  externalBatteryInformation?: boolean;
174
+ reportingMode?: string;
168
175
  };
169
176
  }
170
177
  export interface GetDeviceTypesModelsOrderedByDeviceCountParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",