@spytecgps/nova-orm 1.2.24 → 1.2.25
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/index.d.ts +1 -2
- package/package.json +1 -1
- package/dist/repositories/liveLinks/createLiveLink.d.ts +0 -5
- package/dist/repositories/liveLinks/createLiveLink.js +0 -30
- package/dist/repositories/liveLinks/createLiveLink.js.map +0 -1
- package/dist/repositories/liveLinks/getLiveLinkData.d.ts +0 -5
- package/dist/repositories/liveLinks/getLiveLinkData.js +0 -105
- package/dist/repositories/liveLinks/getLiveLinkData.js.map +0 -1
- package/dist/repositories/liveLinks/getLiveLinkDataCount.d.ts +0 -5
- package/dist/repositories/liveLinks/getLiveLinkDataCount.js +0 -49
- package/dist/repositories/liveLinks/getLiveLinkDataCount.js.map +0 -1
- package/dist/repositories/liveLinks/getLiveLinks.d.ts +0 -5
- package/dist/repositories/liveLinks/getLiveLinks.js +0 -60
- package/dist/repositories/liveLinks/getLiveLinks.js.map +0 -1
- package/dist/repositories/liveLinks/getLiveLinksCount.d.ts +0 -4
- package/dist/repositories/liveLinks/getLiveLinksCount.js +0 -38
- package/dist/repositories/liveLinks/getLiveLinksCount.js.map +0 -1
- package/dist/repositories/liveLinks/index.d.ts +0 -80
- package/dist/repositories/liveLinks/index.js +0 -124
- package/dist/repositories/liveLinks/index.js.map +0 -1
- package/dist/repositories/liveLinks/updateLiveLink.d.ts +0 -4
- package/dist/repositories/liveLinks/updateLiveLink.js +0 -36
- package/dist/repositories/liveLinks/updateLiveLink.js.map +0 -1
|
@@ -23,7 +23,6 @@ import { EntityTagsRepository } from './entityTags';
|
|
|
23
23
|
import { FeatureRepository } from './features';
|
|
24
24
|
import { FirmwaresRepository } from './firmwares';
|
|
25
25
|
import { LatestUserAppInfoRepository } from './latestUserAppInfo';
|
|
26
|
-
import { LiveLinksRepository } from './liveLinks';
|
|
27
26
|
import { NotificationRecipientsRepository } from './notificationRecipients';
|
|
28
27
|
import { PositionRepository } from './positions';
|
|
29
28
|
import { PromotionRepository } from './promotions';
|
|
@@ -40,4 +39,4 @@ import { UserInvitationsRepository } from './userInvitations';
|
|
|
40
39
|
import { UserRatingRequestsRepository } from './userRatingRequests';
|
|
41
40
|
import { UserRegistrationAttemptsRepository } from './userRegistrationAttempts';
|
|
42
41
|
import { UsersRepository } from './users';
|
|
43
|
-
export { AcumaticaRepository, AempTokenRepository, AlertRepository, AlertTypesRepository, AppFeaturesRepository, AssetCategoriesRepository, BillingRepository, BlacklistRepository, BLEMeshRepository, BLEMeshConfigurationRepository, BoundariesRepository, ClientAlertConfigurationRepository, ClientsRepository, CountriesRepository, DataExportsRepository, DeactivationsRepository, DeviceStatusRepository, DeviceBehaviorsRepository, DevicePairingsRepository, DevicesRepository, DeviceTypeFeatureRepository, EntityTagsRepository, FeatureRepository, FirmwaresRepository, LatestUserAppInfoRepository,
|
|
42
|
+
export { AcumaticaRepository, AempTokenRepository, AlertRepository, AlertTypesRepository, AppFeaturesRepository, AssetCategoriesRepository, BillingRepository, BlacklistRepository, BLEMeshRepository, BLEMeshConfigurationRepository, BoundariesRepository, ClientAlertConfigurationRepository, ClientsRepository, CountriesRepository, DataExportsRepository, DeactivationsRepository, DeviceStatusRepository, DeviceBehaviorsRepository, DevicePairingsRepository, DevicesRepository, DeviceTypeFeatureRepository, EntityTagsRepository, FeatureRepository, FirmwaresRepository, LatestUserAppInfoRepository, NotificationRecipientsRepository, PositionRepository, PromotionRepository, SecurityRepository, TagsRepository, TasksRepository, TripRepository, UserActivationsRepository, UserAppFeedbackRepository, UserAppIncidentsRepository, UserConfigurationsRepository, UserDataDeletionRequestsRepository, UserInvitationsRepository, UserRatingRequestsRepository, UserRegistrationAttemptsRepository, UsersRepository, };
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities';
|
|
2
|
-
import { NovaDataSource } from '../../novaDataSource';
|
|
3
|
-
import { CreateLiveLinkParams } from '../../types/liveLinks';
|
|
4
|
-
import { Logger } from '../../types/logger';
|
|
5
|
-
export declare const createLiveLink: (novaDataSource: NovaDataSource, params: CreateLiveLinkParams, logger: Logger) => Promise<LiveLink>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities';
|
|
2
|
-
// import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers'
|
|
3
|
-
export const createLiveLink = async (novaDataSource, params, logger) => {
|
|
4
|
-
if (!params?.id || !params?.name || !params?.clientId || !params?.deviceAccess) {
|
|
5
|
-
logger.warn({ params }, 'LiveLinksRepository::createLiveLink - missing required parameters');
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
if (params.deviceAccess === 'limited' && !params.devices) {
|
|
9
|
-
logger.warn({ params }, 'LiveLinksRepository::createLiveLink - devices should be provided if deviceAccess is limited');
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
// const binaryBuffer = uuidStringToBinaryBuffer(params?.id)
|
|
13
|
-
// if (!binaryBuffer?.length) {
|
|
14
|
-
// logger.warn({ params }, 'LiveLinksRepository::createLiveLink - id should be a valid UUID')
|
|
15
|
-
// return null
|
|
16
|
-
// }
|
|
17
|
-
return novaDataSource.safeQuery(async (dataSource) => {
|
|
18
|
-
const lifeLinkssRepository = dataSource.getRepository(LiveLink);
|
|
19
|
-
const now = new Date();
|
|
20
|
-
const newLiveLink = {
|
|
21
|
-
...params,
|
|
22
|
-
// id: binaryBuffer,
|
|
23
|
-
status: 'active',
|
|
24
|
-
createdAt: now,
|
|
25
|
-
modifiedAt: now,
|
|
26
|
-
};
|
|
27
|
-
return await lifeLinkssRepository.save(newLiveLink);
|
|
28
|
-
}, 'LiveLinksRepository::createLiveLink');
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=createLiveLink.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createLiveLink.js","sourceRoot":"","sources":["../../../src/reposit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Params, LiveLinkData } from '../../types/liveLinks';
|
|
3
|
-
import { Logger } from '../../types/logger';
|
|
4
|
-
import { DeviceStatusRepository } from '../deviceStatus';
|
|
5
|
-
export declare const getLiveLinkData: (novaDataSource: NovaDataSource, params: GetLiveLinkDataParams, logger: Logger, deviceStatusRepository: DeviceStatusRepository) => Promise<LiveLinkData>;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities/liveLink';
|
|
2
|
-
import { Enums } from '../../types';
|
|
3
|
-
import { tryParseBoolean, tryParseDate, tryParseFloat } from '../../utils/parsingTools';
|
|
4
|
-
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
5
|
-
export const getLiveLinkData = async (novaDataSource, params, logger, deviceStatusRepository) => {
|
|
6
|
-
if (!params?.filters?.id || !params?.filters?.clientId) {
|
|
7
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinkData - missing required parameters');
|
|
8
|
-
return { trackersWithStatus: [] };
|
|
9
|
-
}
|
|
10
|
-
const binaryBuffer = uuidStringToBinaryBuffer(params?.filters?.id);
|
|
11
|
-
if (!binaryBuffer?.length) {
|
|
12
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinkData - id should be a valid UUID');
|
|
13
|
-
return { trackersWithStatus: [] };
|
|
14
|
-
}
|
|
15
|
-
// Force the query to run on master or slave
|
|
16
|
-
const dbQueryRunner = novaDataSource.createQueryRunnerFromParams(params);
|
|
17
|
-
return novaDataSource.safeQuery(async (dataSource, queryRunner) => {
|
|
18
|
-
const liveLinksRepository = dataSource.getRepository(LiveLink);
|
|
19
|
-
const queryBuilder = liveLinksRepository
|
|
20
|
-
.createQueryBuilder('liveLink')
|
|
21
|
-
.andWhere('id = :id', { id: binaryBuffer })
|
|
22
|
-
.andWhere('clientId = :clientId', { clientId: params.filters.clientId });
|
|
23
|
-
if (queryRunner) {
|
|
24
|
-
queryBuilder.setQueryRunner(queryRunner);
|
|
25
|
-
}
|
|
26
|
-
const liveLink = await queryBuilder.getOne();
|
|
27
|
-
if (!liveLink) {
|
|
28
|
-
return { trackersWithStatus: [] };
|
|
29
|
-
}
|
|
30
|
-
const result = {
|
|
31
|
-
trackersWithStatus: [],
|
|
32
|
-
};
|
|
33
|
-
const devices = liveLink.devices;
|
|
34
|
-
if (liveLink.deviceAccess === 'limited' && !devices?.length) {
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
const filters = liveLink.deviceAccess === 'limited'
|
|
38
|
-
? { imeiList: devices }
|
|
39
|
-
: { clientId: liveLink.clientId };
|
|
40
|
-
const pageSize = params.pagingOptions?.pageSize ?? 100;
|
|
41
|
-
const pageIndex = params.pagingOptions?.pageIndex ?? 0;
|
|
42
|
-
const deviceStatuses = await deviceStatusRepository.getDeviceStatuses({
|
|
43
|
-
filters: {
|
|
44
|
-
...filters,
|
|
45
|
-
minSendTime: params.filters.minSendTime,
|
|
46
|
-
deviceStatus: Enums.DeviceStatus.Active,
|
|
47
|
-
},
|
|
48
|
-
projectionOptions: {
|
|
49
|
-
withDevice: true,
|
|
50
|
-
deviceProperties: ['imei', 'name', 'description', 'deviceTypeId', 'color', 'icon'],
|
|
51
|
-
deviceStatusProperties: [
|
|
52
|
-
'created',
|
|
53
|
-
'latitude',
|
|
54
|
-
'longitude',
|
|
55
|
-
'address',
|
|
56
|
-
'sendTime',
|
|
57
|
-
'odoMileage',
|
|
58
|
-
'batteryPercentage',
|
|
59
|
-
'speed',
|
|
60
|
-
'hoursOfOperation',
|
|
61
|
-
'batteryVoltage',
|
|
62
|
-
'externalPowerVoltage',
|
|
63
|
-
'reportType',
|
|
64
|
-
'connectionStatus',
|
|
65
|
-
'isOnline',
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
pagingOptions: {
|
|
69
|
-
limit: pageSize,
|
|
70
|
-
offset: pageSize * pageIndex,
|
|
71
|
-
},
|
|
72
|
-
queryOptions: {
|
|
73
|
-
forceUseReplica: params.queryOptions?.forceUseReplica,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
result.trackersWithStatus.push(...deviceStatuses.map(deviceStatus => {
|
|
77
|
-
const data = deviceStatus?.data;
|
|
78
|
-
return {
|
|
79
|
-
imei: deviceStatus.imei,
|
|
80
|
-
name: deviceStatus.device?.name,
|
|
81
|
-
description: deviceStatus.device?.description,
|
|
82
|
-
deviceTypeId: deviceStatus.device?.deviceTypeId,
|
|
83
|
-
color: deviceStatus.device?.color,
|
|
84
|
-
icon: deviceStatus.device?.icon,
|
|
85
|
-
status: {
|
|
86
|
-
latitude: tryParseFloat(data?.latitude) ?? undefined,
|
|
87
|
-
longitude: tryParseFloat(data?.longitude) ?? undefined,
|
|
88
|
-
address: data?.address ?? undefined,
|
|
89
|
-
sendTime: tryParseDate(data?.sendTime) ?? undefined,
|
|
90
|
-
odoMileage: tryParseFloat(data?.odoMileage) ?? undefined,
|
|
91
|
-
batteryPercentage: tryParseFloat(data?.batteryPercentage) ?? undefined,
|
|
92
|
-
speed: tryParseFloat(data?.speed) ?? undefined,
|
|
93
|
-
hoursOfOperation: tryParseFloat(data?.hoursOfOperation) ?? undefined,
|
|
94
|
-
batteryVoltage: tryParseFloat(data?.batteryVoltage) ?? undefined,
|
|
95
|
-
externalPowerVoltage: tryParseFloat(data?.externalPowerVoltage) ?? undefined,
|
|
96
|
-
reportType: tryParseFloat(data?.reportType) ?? undefined,
|
|
97
|
-
connectionStatus: data?.connectionStatus ?? undefined,
|
|
98
|
-
isOnline: tryParseBoolean(data?.isOnline) ?? undefined,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}));
|
|
102
|
-
return result;
|
|
103
|
-
}, 'LiveLinksRepository::getLiveLinkData', dbQueryRunner);
|
|
104
|
-
};
|
|
105
|
-
//# sourceMappingURL=getLiveLinkData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLiveLinkData.js","sourceRoot":"","sources":["../../../src/repositories/liveLinks/getLiveLinkData.ts"],"names":[],"mapp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C,IAAI,EAAE,KAAK,CAAC,IAAI,SAAS;oBAC9C,gBAAgB,EAAE,aAAa,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,SAAS;oBACpE,cAAc,EAAE,aAAa,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,SAAS;oBAChE,oBAAoB,EAAE,aAAa,CAAC,IAAI,EAAE,oBAAoB,CAAC,IAAI,SAAS;oBAC5E,UAAU,EAAE,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,SAAS;oBACxD,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,IAAI,SAAS;oBACrD,QAAQ,EAAE,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,SAAS;iBACvD;aACF,CAAA;QACH,CAAC,CAAC,CACH,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC,EACD,sCAAsC,EACtC,aAAa,CACd,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
-
import { GetLiveLinkDataCountParams } from '../../types/liveLinks';
|
|
3
|
-
import { Logger } from '../../types/logger';
|
|
4
|
-
import { DeviceStatusRepository } from '../deviceStatus';
|
|
5
|
-
export declare const getLiveLinkDataCount: (novaDataSource: NovaDataSource, params: GetLiveLinkDataCountParams, logger: Logger, deviceStatusRepository: DeviceStatusRepository) => Promise<number>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities/liveLink';
|
|
2
|
-
import { Enums } from '../../types';
|
|
3
|
-
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
4
|
-
export const getLiveLinkDataCount = async (novaDataSource, params, logger, deviceStatusRepository) => {
|
|
5
|
-
if (!params?.filters?.id || !params?.filters?.clientId) {
|
|
6
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinkDataCount - missing required parameters');
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
const binaryBuffer = uuidStringToBinaryBuffer(params?.filters?.id);
|
|
10
|
-
if (!binaryBuffer?.length) {
|
|
11
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinkDataCount - id should be a valid UUID');
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
// Force the query to run on master or slave
|
|
15
|
-
const dbQueryRunner = novaDataSource.createQueryRunnerFromParams(params);
|
|
16
|
-
return novaDataSource.safeQuery(async (dataSource, queryRunner) => {
|
|
17
|
-
const liveLinksRepository = dataSource.getRepository(LiveLink);
|
|
18
|
-
const queryBuilder = liveLinksRepository
|
|
19
|
-
.createQueryBuilder('liveLink')
|
|
20
|
-
.andWhere('id = :id', { id: binaryBuffer })
|
|
21
|
-
.andWhere('clientId = :clientId', { clientId: params.filters.clientId });
|
|
22
|
-
if (queryRunner) {
|
|
23
|
-
queryBuilder.setQueryRunner(queryRunner);
|
|
24
|
-
}
|
|
25
|
-
const liveLink = await queryBuilder.getOne();
|
|
26
|
-
if (!liveLink) {
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
const devices = liveLink.devices;
|
|
30
|
-
if (liveLink.deviceAccess === 'limited' && !devices?.length) {
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
const filters = liveLink.deviceAccess === 'limited'
|
|
34
|
-
? { imeiList: devices }
|
|
35
|
-
: { clientId: liveLink.clientId };
|
|
36
|
-
const result = await deviceStatusRepository.getDeviceStatusesCount({
|
|
37
|
-
filters: {
|
|
38
|
-
...filters,
|
|
39
|
-
minSendTime: params.filters.minSendTime,
|
|
40
|
-
deviceStatus: Enums.DeviceStatus.Active,
|
|
41
|
-
},
|
|
42
|
-
queryOptions: {
|
|
43
|
-
forceUseReplica: params.queryOptions?.forceUseReplica,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
return result;
|
|
47
|
-
}, 'LiveLinksRepository::getLiveLinkDataCount', dbQueryRunner);
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=getLiveLinkDataCount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLiveLinkDataCount.js","sourceRoot":"","sources":["../../../src/repositories/liveLinks/getLiveLinkDataCount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAGlE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,cAA8B,EAC9B,MAAkC,EAClC,MAAc,EACd,sBAA8C,EAC7B,EAAE;IACnB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;QACtD,MAAM,CAAC,IAAI,CACT,EAAE,MAAM,EAAE,EACV,yEAAyE,CAC1E,CAAA;QACD,OAAO,CAAC,CAAA;KACT;IAED,MAAM,YAAY,GAAG,wBAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA;IAElE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,uEAAuE,CAAC,CAAA;QAChG,OAAO,CAAC,CAAA;KACT;IAED,4CAA4C;IAC5C,MAAM,aAAa,GAAG,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAA;IAExE,OAAO,cAAc,CAAC,SAAS,CAC7B,KAAK,EAAE,UAA0B,EAAE,WAAyB,EAAmB,EAAE;QAC/E,MAAM,mBAAmB,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE9D,MAAM,YAAY,GAAG,mBAAmB;aACrC,kBAAkB,CAAC,UAAU,CAAC;aAC9B,QAAQ,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC;aAC1C,QAAQ,CAAC,sBAAsB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;QAE1E,IAAI,WAAW,EAAE;YACf,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;SACzC;QAED,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,CAAA;QAE5C,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO,CAAC,CAAA;SACT;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAmB,CAAA;QAE5C,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YAC3D,OAAO,CAAC,CAAA;SACT;QAED,MAAM,OAAO,GACX,QAAQ,CAAC,YAAY,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE;YACvB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAA;QAErC,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,sBAAsB,CAAC;YACjE,OAAO,EAAE;gBACP,GAAG,OAAO;gBACV,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;gBACvC,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM;aACxC;YACD,YAAY,EAAE;gBACZ,eAAe,EAAE,MAAM,CAAC,YAAY,EAAE,eAAe;aACtD;SACF,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC,EACD,2CAA2C,EAC3C,aAAa,CACd,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities/liveLink';
|
|
2
|
-
import { NovaDataSource } from '../../novaDataSource';
|
|
3
|
-
import { GetLiveLinksParams } from '../../types/liveLinks';
|
|
4
|
-
import { Logger } from '../../types/logger';
|
|
5
|
-
export declare const getLiveLinks: (novaDataSource: NovaDataSource, params: GetLiveLinksParams, logger: Logger) => Promise<LiveLink[]>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities/liveLink';
|
|
2
|
-
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
-
export const getLiveLinks = async (novaDataSource, params, logger) => {
|
|
4
|
-
if (!params?.filters?.id &&
|
|
5
|
-
!params?.filters?.clientId &&
|
|
6
|
-
!params?.filters?.status &&
|
|
7
|
-
!params?.filters?.name &&
|
|
8
|
-
!params?.filters?.imeis?.length) {
|
|
9
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinks - missing required parameters');
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
const binaryBuffer = uuidStringToBinaryBuffer(params?.filters?.id);
|
|
13
|
-
if (params?.filters?.id && !binaryBuffer?.length) {
|
|
14
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinks - id should be a valid UUID');
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
// Force the query to run on master or slave
|
|
18
|
-
const dbQueryRunner = novaDataSource.createQueryRunnerFromParams(params);
|
|
19
|
-
return novaDataSource.safeQuery(async (dataSource, queryRunner) => {
|
|
20
|
-
const liveLinksRepository = dataSource.getRepository(LiveLink);
|
|
21
|
-
let queryBuilder = liveLinksRepository.createQueryBuilder('liveLink');
|
|
22
|
-
if (queryRunner) {
|
|
23
|
-
queryBuilder.setQueryRunner(queryRunner);
|
|
24
|
-
}
|
|
25
|
-
if (params?.filters?.id) {
|
|
26
|
-
queryBuilder = queryBuilder.andWhere('id = :id', { id: binaryBuffer });
|
|
27
|
-
}
|
|
28
|
-
if (params?.filters?.clientId) {
|
|
29
|
-
queryBuilder = queryBuilder.andWhere('clientId = :clientId', {
|
|
30
|
-
clientId: params.filters.clientId,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (params?.filters?.status) {
|
|
34
|
-
queryBuilder = queryBuilder.andWhere('status = :status', {
|
|
35
|
-
status: params.filters.status,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
if (params?.filters?.name) {
|
|
39
|
-
queryBuilder = queryBuilder.andWhere('LOWER(name) LIKE :name', {
|
|
40
|
-
name: `%${params.filters.name.toLowerCase()}%`,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (params?.filters?.imeis?.length) {
|
|
44
|
-
queryBuilder = queryBuilder.andWhere(`deviceAccess = 'full' OR JSON_OVERLAPS(liveLink.devices, :deviceList)`, {
|
|
45
|
-
deviceList: JSON.stringify(params?.filters?.imeis),
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const sortField = params.sortOptions?.sortField ?? 'createdAt';
|
|
49
|
-
const sortOrder = params.sortOptions?.sortOrder ?? 'DESC';
|
|
50
|
-
queryBuilder = queryBuilder.orderBy(`liveLink.${sortField}`, sortOrder);
|
|
51
|
-
const pageSize = params.pagingOptions?.pageSize ?? 100;
|
|
52
|
-
const pageIndex = params.pagingOptions?.pageIndex ?? 0;
|
|
53
|
-
const result = await queryBuilder
|
|
54
|
-
.limit(pageSize)
|
|
55
|
-
.offset(pageSize * pageIndex)
|
|
56
|
-
.getMany();
|
|
57
|
-
return result;
|
|
58
|
-
}, 'LiveLinksRepository::getLiveLinks', dbQueryRunner);
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=getLiveLinks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLiveLinks.js","sourceRoot":"","sources":["../../../src/repositories/liveLinks/getLiveLinks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAIlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAElE,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,cAA8B,EAC9B,MAA0B,EAC1B,MAAc,EACO,EAAE;IACvB,IACE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACpB,CAAC,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CAAA"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
-
import { GetLiveLinksCountParams } from '../../types/liveLinks';
|
|
3
|
-
import { Logger } from '../../types/logger';
|
|
4
|
-
export declare const getLiveLinksCount: (novaDataSource: NovaDataSource, params: GetLiveLinksCountParams, logger: Logger) => Promise<number>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities/liveLink';
|
|
2
|
-
export const getLiveLinksCount = async (novaDataSource, params, logger) => {
|
|
3
|
-
if (!params?.filters?.clientId) {
|
|
4
|
-
logger.warn({ params }, 'LiveLinksRepository::getLiveLinksCount - missing required parameters');
|
|
5
|
-
return 0;
|
|
6
|
-
}
|
|
7
|
-
// Force the query to run on master or slave
|
|
8
|
-
const dbQueryRunner = novaDataSource.createQueryRunnerFromParams(params);
|
|
9
|
-
return novaDataSource.safeQuery(async (dataSource, queryRunner) => {
|
|
10
|
-
const liveLinksRepository = dataSource.getRepository(LiveLink);
|
|
11
|
-
let queryBuilder = liveLinksRepository
|
|
12
|
-
.createQueryBuilder('liveLink')
|
|
13
|
-
.where('clientId = :clientId', {
|
|
14
|
-
clientId: params.filters.clientId,
|
|
15
|
-
});
|
|
16
|
-
if (queryRunner) {
|
|
17
|
-
queryBuilder.setQueryRunner(queryRunner);
|
|
18
|
-
}
|
|
19
|
-
if (params?.filters?.status) {
|
|
20
|
-
queryBuilder = queryBuilder.andWhere('status = :status', {
|
|
21
|
-
status: params.filters.status,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
if (params?.filters?.name) {
|
|
25
|
-
queryBuilder = queryBuilder.andWhere('LOWER(name) LIKE :name', {
|
|
26
|
-
name: `%${params.filters.name.toLowerCase()}%`,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (params?.filters?.imeis?.length) {
|
|
30
|
-
queryBuilder = queryBuilder.andWhere(`deviceAccess = 'full' OR JSON_OVERLAPS(liveLink.devices, :deviceList)`, {
|
|
31
|
-
deviceList: JSON.stringify(params?.filters?.imeis),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const result = await queryBuilder.getCount();
|
|
35
|
-
return result;
|
|
36
|
-
}, 'LiveLinksRepository::getLiveLinksCount', dbQueryRunner);
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=getLiveLinksCount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLiveLinksCount.js","sourceRoot":"","sources":["../../../src/repositories/liveLinks/getLiveLinksCount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAKlD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,cAA8B,EAC9B,MAA+B,EAC/B,MAAc,EACG,EAAE;IACnB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC9B,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,sEAAsE,CAAC,CAAA;QAC/F,OAAO,CAAC,CAAA;KACT;IAED,4CAA4C;IAC5C,MAAM,aAAa,GAAG,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAA;IAExE,OAAO,cAAc,CAAC,SAAS,CAC7B,KAAK,EAAE,UAA0B,EAAE,WAAyB,EAAmB,EAAE;QAC/E,MAAM,mBAAmB,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE9D,IAAI,YAAY,GAAG,mBAAmB;aACnC,kBAAkB,CAAC,UAAU,CAAC;aAC9B,KAAK,CAAC,sBAAsB,EAAE;YAC7B,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ;SAClC,CAAC,CAAA;QAEJ,IAAI,WAAW,EAAE;YACf,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;SACzC;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;YAC3B,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,kBAAkB,EAAE;gBACvD,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;aAC9B,CAAC,CAAA;SACH;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;YACzB,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,wBAAwB,EAAE;gBAC7D,IAAI,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG;aAC/C,CAAC,CAAA;SACH;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;YAClC,YAAY,GAAG,YAAY,CAAC,QAAQ,CAClC,uEAAuE,EACvE;gBACE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;aACnD,CACF,CAAA;SACF;QAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,CAAA;QAE5C,OAAO,MAAM,CAAA;IACf,CAAC,EACD,wCAAwC,EACxC,aAAa,CACd,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities';
|
|
2
|
-
import { CreateLiveLinkParams, GetLiveLinkDataCountParams, GetLiveLinkDataParams, GetLiveLinksCountParams, GetLiveLinksParams, LiveLinkData, UpdateLiveLinkParams } from '../../types/liveLinks';
|
|
3
|
-
import { BaseRepository2 } from '../baseRepository';
|
|
4
|
-
export declare class LiveLinksRepository extends BaseRepository2 {
|
|
5
|
-
/**
|
|
6
|
-
* Create a new live link
|
|
7
|
-
* @param params - The parameters to create a live link
|
|
8
|
-
* id: the liveLink id, required. It should be a valid UUID.
|
|
9
|
-
* name: the liveLink name, required
|
|
10
|
-
* clientId: the client id, required
|
|
11
|
-
* startDate: the start date, optional
|
|
12
|
-
* endDate: the end date, optional
|
|
13
|
-
* deviceAccess: the device access, required. Values: 'full', 'limited'
|
|
14
|
-
* devices: array of devices the liveLink have access to, required if deviceAccess is 'limited'
|
|
15
|
-
* createdBy: the user who created the live link, optional
|
|
16
|
-
* @returns The created live link
|
|
17
|
-
*/
|
|
18
|
-
createLiveLink(params: CreateLiveLinkParams): Promise<LiveLink>;
|
|
19
|
-
/**
|
|
20
|
-
* Update a live link
|
|
21
|
-
* @param params - The parameters to update a live link
|
|
22
|
-
* filters.id: the liveLink id, required. It should be a valid UUID.
|
|
23
|
-
* At least one value must be provided:
|
|
24
|
-
* values.name: the liveLink name, optional
|
|
25
|
-
* values.status: the liveLink status, optional
|
|
26
|
-
* values.startDate: the start date, optional
|
|
27
|
-
* values.endDate: the end date, optional
|
|
28
|
-
* values.deviceAccess: the device access, optional. Values: 'full', 'limited'
|
|
29
|
-
* values.devices: array of devices the liveLink have access to, optional
|
|
30
|
-
* values.modifiedBy: the user who modified the live link, optional
|
|
31
|
-
* @returns True if the live link was updated
|
|
32
|
-
*/
|
|
33
|
-
updateLiveLink(params: UpdateLiveLinkParams): Promise<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Get live links
|
|
36
|
-
* @param params - The parameters to get live links
|
|
37
|
-
* One of the following filters is required:
|
|
38
|
-
* filters.id: the liveLink id, optional. It should be a valid UUID.
|
|
39
|
-
* filters.clientId: the client id, optional
|
|
40
|
-
* filters.status: the liveLink status, optional
|
|
41
|
-
* filters.name: the liveLink name for partial match, optional
|
|
42
|
-
* filters.imeis: array of devices the liveLink have access to for partial match, optional
|
|
43
|
-
* pagingOptions.pageSize: the page size, optional. Default: 100
|
|
44
|
-
* pagingOptions.pageIndex: the page index, optional. Default: 0
|
|
45
|
-
* sortOptions.sortField: the sort field, optional. Default: 'id'
|
|
46
|
-
* sortOptions.sortOrder: the sort order, optional. Default: 'DESC'
|
|
47
|
-
* @returns The live links
|
|
48
|
-
*/
|
|
49
|
-
getLiveLinks(params: GetLiveLinksParams): Promise<LiveLink[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Get live links count
|
|
52
|
-
* @param params - The parameters to get live links count
|
|
53
|
-
* filters.clientId: the client id, required
|
|
54
|
-
* filters.status: the liveLink status, optional
|
|
55
|
-
* filters.name: the liveLink name for partial match, optional
|
|
56
|
-
* filters.imeis: array of devices the liveLink have access to for partial match, optional
|
|
57
|
-
* @returns The live links count
|
|
58
|
-
*/
|
|
59
|
-
getLiveLinksCount(params: GetLiveLinksCountParams): Promise<number>;
|
|
60
|
-
/**
|
|
61
|
-
* Get trackers with location data associated with a live link
|
|
62
|
-
* @param params - The parameters to get live link data
|
|
63
|
-
* filters.id: the liveLink id, required. It should be a valid UUID.
|
|
64
|
-
* filters.clientId: the client id, required
|
|
65
|
-
* filters.minSendTime: the min send time, optional
|
|
66
|
-
* pagingOptions.pageSize: the page size, optional. Default: 100
|
|
67
|
-
* pagingOptions.pageIndex: the page index, optional. Default: 0
|
|
68
|
-
* @returns The live link data
|
|
69
|
-
*/
|
|
70
|
-
getLiveLinkData(params: GetLiveLinkDataParams): Promise<LiveLinkData>;
|
|
71
|
-
/**
|
|
72
|
-
* Get total count of trackers with location data associated with a live link
|
|
73
|
-
* @param params - The parameters to get live link data count
|
|
74
|
-
* filters.id: the liveLink id, required. It should be a valid UUID.
|
|
75
|
-
* filters.clientId: the client id, required
|
|
76
|
-
* filters.minSendTime: the min send time, optional
|
|
77
|
-
* @returns The live link data count
|
|
78
|
-
*/
|
|
79
|
-
getLiveLinkDataCount(params: GetLiveLinkDataCountParams): Promise<number>;
|
|
80
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { BaseRepository2 } from '../baseRepository';
|
|
2
|
-
import { DeviceStatusRepository } from '../deviceStatus';
|
|
3
|
-
import { createLiveLink } from './createLiveLink';
|
|
4
|
-
import { getLiveLinkData } from './getLiveLinkData';
|
|
5
|
-
import { getLiveLinkDataCount } from './getLiveLinkDataCount';
|
|
6
|
-
import { getLiveLinks } from './getLiveLinks';
|
|
7
|
-
import { getLiveLinksCount } from './getLiveLinksCount';
|
|
8
|
-
import { updateLiveLink } from './updateLiveLink';
|
|
9
|
-
export class LiveLinksRepository extends BaseRepository2 {
|
|
10
|
-
/**
|
|
11
|
-
* Create a new live link
|
|
12
|
-
* @param params - The parameters to create a live link
|
|
13
|
-
* id: the liveLink id, required. It should be a valid UUID.
|
|
14
|
-
* name: the liveLink name, required
|
|
15
|
-
* clientId: the client id, required
|
|
16
|
-
* startDate: the start date, optional
|
|
17
|
-
* endDate: the end date, optional
|
|
18
|
-
* deviceAccess: the device access, required. Values: 'full', 'limited'
|
|
19
|
-
* devices: array of devices the liveLink have access to, required if deviceAccess is 'limited'
|
|
20
|
-
* createdBy: the user who created the live link, optional
|
|
21
|
-
* @returns The created live link
|
|
22
|
-
*/
|
|
23
|
-
async createLiveLink(params) {
|
|
24
|
-
this.logger.trace(params, 'LiveLinksRepository::createLiveLink started with params');
|
|
25
|
-
const result = await createLiveLink(this.dataSource, params, this.logger);
|
|
26
|
-
this.logger.trace(result, 'LiveLinksRepository::createLiveLink result');
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Update a live link
|
|
31
|
-
* @param params - The parameters to update a live link
|
|
32
|
-
* filters.id: the liveLink id, required. It should be a valid UUID.
|
|
33
|
-
* At least one value must be provided:
|
|
34
|
-
* values.name: the liveLink name, optional
|
|
35
|
-
* values.status: the liveLink status, optional
|
|
36
|
-
* values.startDate: the start date, optional
|
|
37
|
-
* values.endDate: the end date, optional
|
|
38
|
-
* values.deviceAccess: the device access, optional. Values: 'full', 'limited'
|
|
39
|
-
* values.devices: array of devices the liveLink have access to, optional
|
|
40
|
-
* values.modifiedBy: the user who modified the live link, optional
|
|
41
|
-
* @returns True if the live link was updated
|
|
42
|
-
*/
|
|
43
|
-
async updateLiveLink(params) {
|
|
44
|
-
this.logger.trace(params, 'LiveLinksRepository::updateLiveLink started with params');
|
|
45
|
-
const result = await updateLiveLink(this.dataSource, params, this.logger);
|
|
46
|
-
this.logger.trace({ result }, 'LiveLinksRepository::updateLiveLink result');
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get live links
|
|
51
|
-
* @param params - The parameters to get live links
|
|
52
|
-
* One of the following filters is required:
|
|
53
|
-
* filters.id: the liveLink id, optional. It should be a valid UUID.
|
|
54
|
-
* filters.clientId: the client id, optional
|
|
55
|
-
* filters.status: the liveLink status, optional
|
|
56
|
-
* filters.name: the liveLink name for partial match, optional
|
|
57
|
-
* filters.imeis: array of devices the liveLink have access to for partial match, optional
|
|
58
|
-
* pagingOptions.pageSize: the page size, optional. Default: 100
|
|
59
|
-
* pagingOptions.pageIndex: the page index, optional. Default: 0
|
|
60
|
-
* sortOptions.sortField: the sort field, optional. Default: 'id'
|
|
61
|
-
* sortOptions.sortOrder: the sort order, optional. Default: 'DESC'
|
|
62
|
-
* @returns The live links
|
|
63
|
-
*/
|
|
64
|
-
async getLiveLinks(params) {
|
|
65
|
-
this.logger.trace(params, 'LiveLinksRepository::getLiveLinks started with params');
|
|
66
|
-
const result = await getLiveLinks(this.dataSource, params, this.logger);
|
|
67
|
-
this.logger.trace(result, 'LiveLinksRepository::getLiveLinks result');
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get live links count
|
|
72
|
-
* @param params - The parameters to get live links count
|
|
73
|
-
* filters.clientId: the client id, required
|
|
74
|
-
* filters.status: the liveLink status, optional
|
|
75
|
-
* filters.name: the liveLink name for partial match, optional
|
|
76
|
-
* filters.imeis: array of devices the liveLink have access to for partial match, optional
|
|
77
|
-
* @returns The live links count
|
|
78
|
-
*/
|
|
79
|
-
async getLiveLinksCount(params) {
|
|
80
|
-
this.logger.trace(params, 'LiveLinksRepository::getLiveLinksCount started with params');
|
|
81
|
-
const result = await getLiveLinksCount(this.dataSource, params, this.logger);
|
|
82
|
-
this.logger.trace({ result }, 'LiveLinksRepository::getLiveLinksCount result');
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get trackers with location data associated with a live link
|
|
87
|
-
* @param params - The parameters to get live link data
|
|
88
|
-
* filters.id: the liveLink id, required. It should be a valid UUID.
|
|
89
|
-
* filters.clientId: the client id, required
|
|
90
|
-
* filters.minSendTime: the min send time, optional
|
|
91
|
-
* pagingOptions.pageSize: the page size, optional. Default: 100
|
|
92
|
-
* pagingOptions.pageIndex: the page index, optional. Default: 0
|
|
93
|
-
* @returns The live link data
|
|
94
|
-
*/
|
|
95
|
-
async getLiveLinkData(params) {
|
|
96
|
-
this.logger.trace(params, 'LiveLinksRepository::getLiveLinkData started with params');
|
|
97
|
-
const deviceStatusRepository = new DeviceStatusRepository({
|
|
98
|
-
dataSource: this.dataSource,
|
|
99
|
-
logger: this.logger,
|
|
100
|
-
});
|
|
101
|
-
const result = await getLiveLinkData(this.dataSource, params, this.logger, deviceStatusRepository);
|
|
102
|
-
this.logger.trace(result, 'LiveLinksRepository::getLiveLinkData result');
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get total count of trackers with location data associated with a live link
|
|
107
|
-
* @param params - The parameters to get live link data count
|
|
108
|
-
* filters.id: the liveLink id, required. It should be a valid UUID.
|
|
109
|
-
* filters.clientId: the client id, required
|
|
110
|
-
* filters.minSendTime: the min send time, optional
|
|
111
|
-
* @returns The live link data count
|
|
112
|
-
*/
|
|
113
|
-
async getLiveLinkDataCount(params) {
|
|
114
|
-
this.logger.trace(params, 'LiveLinksRepository::getLiveLinkDataCount started with params');
|
|
115
|
-
const deviceStatusRepository = new DeviceStatusRepository({
|
|
116
|
-
dataSource: this.dataSource,
|
|
117
|
-
logger: this.logger,
|
|
118
|
-
});
|
|
119
|
-
const result = await getLiveLinkDataCount(this.dataSource, params, this.logger, deviceStatusRepository);
|
|
120
|
-
this.logger.trace({ result }, 'LiveLinksRepository::getLiveLinkDataCount result');
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingUR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E,6CAA6C,CAAC,CAAA;QAExE,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAC3D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,+DAA+D,CAAC,CAAA;QAE1F,MAAM,sBAAsB,GAAG,IAAI,sBAAsB,CAAC;YACxD,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC,IAAI,CAAC,UAAU,EACf,MAAM,EACN,IAAI,CAAC,MAAM,EACX,sBAAsB,CACvB,CAAA;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,kDAAkD,CAAC,CAAA;QAEjF,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
-
import { UpdateLiveLinkParams } from '../../types/liveLinks';
|
|
3
|
-
import { Logger } from '../../types/logger';
|
|
4
|
-
export declare const updateLiveLink: (novaDataSource: NovaDataSource, params: UpdateLiveLinkParams, logger: Logger) => Promise<boolean>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { LiveLink } from '../../entities/liveLink';
|
|
2
|
-
import { anyAttributeHasValue } from '../../utils/anyAttributeHasValue';
|
|
3
|
-
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
4
|
-
export const updateLiveLink = async (novaDataSource, params, logger) => {
|
|
5
|
-
if (!params?.filters?.id) {
|
|
6
|
-
logger.warn({ params }, 'LiveLinksRepository::updateLiveLink - missing required parameters');
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
if (!anyAttributeHasValue(params?.values)) {
|
|
10
|
-
logger.warn({ params }, 'LiveLinksRepository::updateLiveLink - missing fields to update');
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const binaryBuffer = uuidStringToBinaryBuffer(params?.filters?.id);
|
|
14
|
-
if (!binaryBuffer?.length) {
|
|
15
|
-
logger.warn({ params }, 'LiveLinksRepository::updateLiveLink - id should be a valid UUID');
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
if (params.values?.deviceAccess === 'limited' && !params?.values.devices) {
|
|
19
|
-
logger.warn({ params }, 'LiveLinksRepository::updateLiveLink - devices should be provided if deviceAccess is limited');
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return novaDataSource.safeQuery(async (dataSource) => {
|
|
23
|
-
const liveLinksRepository = dataSource.getRepository(LiveLink);
|
|
24
|
-
const queryBuilder = liveLinksRepository
|
|
25
|
-
.createQueryBuilder()
|
|
26
|
-
.update(LiveLink)
|
|
27
|
-
.set({
|
|
28
|
-
...params.values,
|
|
29
|
-
modifiedAt: new Date(),
|
|
30
|
-
})
|
|
31
|
-
.where('id = :id', { id: binaryBuffer });
|
|
32
|
-
const result = await queryBuilder.execute();
|
|
33
|
-
return result.affected > 0;
|
|
34
|
-
}, 'LiveLinksRepository::updateLiveLink');
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=updateLiveLink.js.map
|