@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.
- package/dist/entities/clientDeviceSetting.d.ts +1 -0
- package/dist/entities/clientDeviceSetting.js +5 -0
- package/dist/index.js +1 -1
- package/dist/repositories/devices/createClientDeviceSetting.js +1 -0
- package/dist/repositories/devices/getDevices.js +9 -0
- package/dist/repositories/devices/updateClientDeviceSetting.js +3 -1
- package/dist/types/common.d.ts +6 -0
- package/dist/types/devices.d.ts +11 -4
- package/package.json +1 -1
|
@@ -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 });
|
package/dist/types/common.d.ts
CHANGED
package/dist/types/devices.d.ts
CHANGED
|
@@ -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
|
|
22
|
-
withIccidCarrier
|
|
23
|
-
withClientDeviceSettings
|
|
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 {
|