@spytecgps/nova-orm 1.0.67 → 1.0.68
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/index.js +1 -1
- package/dist/repositories/trips/getDeviceTripConfiguration.d.ts +4 -0
- package/dist/repositories/trips/getDeviceTripConfiguration.js +34 -0
- package/dist/repositories/trips/getDeviceTripConfiguration.js.map +1 -0
- package/dist/repositories/trips/index.d.ts +2 -1
- package/dist/repositories/trips/index.js +8 -0
- package/dist/repositories/trips/index.js.map +1 -1
- package/dist/types/trip.d.ts +15 -0
- package/dist/types/trip.js +1 -0
- package/dist/types/trip.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { Logger } from '../../types/logger';
|
|
3
|
+
import { DeviceTripConfiguration, GetUserTripConfigurationParams } from '../../types/trip';
|
|
4
|
+
export declare const getDeviceTripConfiguration: (novaDataSource: NovaDataSource, params: GetUserTripConfigurationParams, logger: Logger) => Promise<DeviceTripConfiguration>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ClientDeviceSetting, Device, UserActivationDevice } from '../../entities';
|
|
2
|
+
import { requiredGetUserTripConfigurationParamsAttributes, } from '../../types/trip';
|
|
3
|
+
import { anyAttributeIsNull } from '../../utils/paramsValidators';
|
|
4
|
+
export const getDeviceTripConfiguration = async (novaDataSource, params, logger) => {
|
|
5
|
+
if (anyAttributeIsNull(params, requiredGetUserTripConfigurationParamsAttributes)) {
|
|
6
|
+
logger.warn('TripRepository::getTrips missing required parameters');
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return novaDataSource.safeQuery(async (safeDataSource) => {
|
|
10
|
+
const repository = safeDataSource.getRepository(Device);
|
|
11
|
+
const queryBuilder = repository
|
|
12
|
+
.createQueryBuilder('device')
|
|
13
|
+
.innerJoin(ClientDeviceSetting, 'cds', 'cds.imei = device.imei')
|
|
14
|
+
.leftJoin(UserActivationDevice, 'uad', 'uad.imei = device.imei');
|
|
15
|
+
const { filters } = params;
|
|
16
|
+
queryBuilder.where('device.imei = :imei', { imei: filters.imei });
|
|
17
|
+
const deviceTripConfiguration = await queryBuilder
|
|
18
|
+
.select([
|
|
19
|
+
'device.clientId as clientId',
|
|
20
|
+
'device.deviceTypeId as deviceTypeId',
|
|
21
|
+
'uad.servicePlan as servicePlan',
|
|
22
|
+
'cds.generateTrips as generateTrips',
|
|
23
|
+
'cds.stopThresholdMinutes as stopThresholdMinutes',
|
|
24
|
+
'cds.movementThresholdSpeed as movementThresholdSpeed',
|
|
25
|
+
'cds.reportingMode as reportingMode',
|
|
26
|
+
])
|
|
27
|
+
.getRawOne();
|
|
28
|
+
return {
|
|
29
|
+
...deviceTripConfiguration,
|
|
30
|
+
generateTrips: deviceTripConfiguration.generateTrips === 1,
|
|
31
|
+
};
|
|
32
|
+
}, 'TripRepository::getTrips error');
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=getDeviceTripConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDeviceTripConfiguration.js","sourceRoot":"","sources":["../../../src/repositories/trips/getDeviceTripConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAGlF,OAAO,EAGL,gDAAgD,GACjD,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAC7C,cAA8B,EAC9B,MAAsC,EACtC,MAAc,EACd,EAAE;IACF,IACE,kBAAkB,CAChB,MAAM,EACN,gDAAgD,CACjD,EACD;QACA,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;QACnE,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,cAA8B,EAEnE,EAAE;QACF,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAEvD,MAAM,YAAY,GAAG,UAAU;aAC5B,kBAAkB,CAAC,QAAQ,CAAC;aAC5B,SAAS,CAAC,mBAAmB,EAAE,KAAK,EAAE,wBAAwB,CAAC;aAC/D,QAAQ,CAAC,oBAAoB,EAAE,KAAK,EAAE,wBAAwB,CAAC,CAAA;QAElE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QAE1B,YAAY,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QAEjE,MAAM,uBAAuB,GAAG,MAAM,YAAY;aAC/C,MAAM,CAAC;YACN,6BAA6B;YAC7B,qCAAqC;YACrC,gCAAgC;YAChC,oCAAoC;YACpC,kDAAkD;YAClD,sDAAsD;YACtD,oCAAoC;SACrC,CAAC;aACD,SAAS,EAAE,CAAA;QAEd,OAAO;YACL,GAAG,uBAAuB;YAC1B,aAAa,EAAE,uBAAuB,CAAC,aAAa,KAAK,CAAC;SAChC,CAAA;IAC9B,CAAC,EAAE,gCAAgC,CAAC,CAAA;AACtC,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Trip } from '../../entities';
|
|
2
|
-
import { CreateTripParams, GetTripsParams, GetTripsResult, UpdateTripEndValuesParams } from '../../types/trip';
|
|
2
|
+
import { CreateTripParams, DeviceTripConfiguration, GetTripsParams, GetTripsResult, GetUserTripConfigurationParams, UpdateTripEndValuesParams } from '../../types/trip';
|
|
3
3
|
import { BaseRepository } from '../baseRepository';
|
|
4
4
|
export declare class TripRepository extends BaseRepository {
|
|
5
5
|
/**
|
|
@@ -32,4 +32,5 @@ export declare class TripRepository extends BaseRepository {
|
|
|
32
32
|
* @returns {boolean} true if the event was upserted, false otherwise
|
|
33
33
|
*/
|
|
34
34
|
upsertTrip(params: CreateTripParams): Promise<boolean>;
|
|
35
|
+
getDeviceTripConfiguration(params: GetUserTripConfigurationParams): Promise<DeviceTripConfiguration>;
|
|
35
36
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NovaDataSource } from '../../novaDataSource';
|
|
2
2
|
import { BaseRepository } from '../baseRepository';
|
|
3
3
|
import { createTrip } from './createTrip';
|
|
4
|
+
import { getDeviceTripConfiguration } from './getDeviceTripConfiguration';
|
|
4
5
|
import { getTripById } from './getTripById';
|
|
5
6
|
import { getTrips } from './getTrips';
|
|
6
7
|
import { updateTripEndValues } from './updateTripEndValues';
|
|
@@ -66,5 +67,12 @@ export class TripRepository extends BaseRepository {
|
|
|
66
67
|
this.logger.trace({ result }, 'TripRepository::upsertTrip result');
|
|
67
68
|
return result;
|
|
68
69
|
}
|
|
70
|
+
async getDeviceTripConfiguration(params) {
|
|
71
|
+
this.logger.trace({}, `TripRepository::this.getDeviceTripConfiguration started with params`);
|
|
72
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
|
|
73
|
+
const result = await getDeviceTripConfiguration(novaDataSource, params, this.logger);
|
|
74
|
+
this.logger.trace(result, 'TripRepository::getDeviceTripConfiguration result');
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/trips/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/trips/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AASrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM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C,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,mCAAmC,CAAC,CAAA;QAElE,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,MAAsC;QAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,qEAAqE,CAAC,CAAA;QAE5F,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,2BAA2B,CACjC,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,0BAA0B,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,mDAAmD,CAAC,CAAA;QAE9E,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
package/dist/types/trip.d.ts
CHANGED
|
@@ -74,3 +74,18 @@ export interface GetTripsResult {
|
|
|
74
74
|
trips: TripWithDevice[];
|
|
75
75
|
totalCount: number;
|
|
76
76
|
}
|
|
77
|
+
export declare const requiredGetUserTripConfigurationParamsAttributes: string[];
|
|
78
|
+
export interface GetUserTripConfigurationParams {
|
|
79
|
+
filters: {
|
|
80
|
+
imei: string;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface DeviceTripConfiguration {
|
|
84
|
+
clientId: number;
|
|
85
|
+
deviceTypeId: number;
|
|
86
|
+
servicePlan: string;
|
|
87
|
+
generateTrips: boolean;
|
|
88
|
+
stopThresholdMinutes: number;
|
|
89
|
+
movementThresholdSpeed: number;
|
|
90
|
+
reportingMode: string;
|
|
91
|
+
}
|
package/dist/types/trip.js
CHANGED
|
@@ -27,4 +27,5 @@ export const requiredUpdateTripEndValuesParamsAttributes = [
|
|
|
27
27
|
'values.tripCompletionStatusId',
|
|
28
28
|
];
|
|
29
29
|
export const requiredGetTripsParamsAttributes = ['filters.clientId', 'filters.from', 'filters.to'];
|
|
30
|
+
export const requiredGetUserTripConfigurationParamsAttributes = ['filters.imei'];
|
|
30
31
|
//# sourceMappingURL=trip.js.map
|
package/dist/types/trip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trip.js","sourceRoot":"","sources":["../../src/types/trip.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,UAAU;IACV,MAAM;IACN,WAAW;IACX,UAAU;IACV,UAAU;IACV,UAAU;IACV,cAAc;IACd,eAAe;IACf,wBAAwB;IACxB,UAAU;IACV,UAAU;IACV,UAAU;IACV,gBAAgB;CACjB,CAAA;AA2BD,MAAM,CAAC,MAAM,2CAA2C,GAAG;IACzD,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,oBAAoB;IACpB,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,+BAA+B;CAChC,CAAA;AAqBD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,kBAAkB,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"trip.js","sourceRoot":"","sources":["../../src/types/trip.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,UAAU;IACV,MAAM;IACN,WAAW;IACX,UAAU;IACV,UAAU;IACV,UAAU;IACV,cAAc;IACd,eAAe;IACf,wBAAwB;IACxB,UAAU;IACV,UAAU;IACV,UAAU;IACV,gBAAgB;CACjB,CAAA;AA2BD,MAAM,CAAC,MAAM,2CAA2C,GAAG;IACzD,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,oBAAoB;IACpB,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,+BAA+B;CAChC,CAAA;AAqBD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,kBAAkB,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;AAoClG,MAAM,CAAC,MAAM,gDAAgD,GAAG,CAAC,cAAc,CAAC,CAAA"}
|