@spytecgps/nova-orm 0.0.226 → 1.0.2
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 +2 -1
- package/dist/index.js.LICENSE.txt +39 -0
- package/dist/repositories/devices/allImeisAreActiveForClient.d.ts +4 -0
- package/dist/repositories/devices/allImeisAreActiveForClient.js +24 -0
- package/dist/repositories/devices/index.d.ts +9 -1
- package/dist/repositories/devices/index.js +15 -0
- package/dist/types/devices.d.ts +4 -0
- package/package.json +1 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
*/
|
|
3
|
+
|
|
4
|
+
/*! *****************************************************************************
|
|
5
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
7
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
8
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
11
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
12
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
13
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
14
|
+
|
|
15
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
16
|
+
and limitations under the License.
|
|
17
|
+
***************************************************************************** */
|
|
18
|
+
|
|
19
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2009 The Closure Library Authors
|
|
24
|
+
* Copyright 2020 Daniel Wirtz / The long.js Authors.
|
|
25
|
+
*
|
|
26
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27
|
+
* you may not use this file except in compliance with the License.
|
|
28
|
+
* You may obtain a copy of the License at
|
|
29
|
+
*
|
|
30
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
+
*
|
|
32
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
+
* See the License for the specific language governing permissions and
|
|
36
|
+
* limitations under the License.
|
|
37
|
+
*
|
|
38
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
39
|
+
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { AllImeisAreActiveForClientParams } from '../../types/devices';
|
|
3
|
+
import { Logger } from '../../types/logger';
|
|
4
|
+
export declare const allImeisAreActiveForClient: (novaDataSource: NovaDataSource, params: AllImeisAreActiveForClientParams, logger: Logger) => Promise<boolean>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Device } from '../../entities';
|
|
2
|
+
import { DeviceStatus } from '../../types/enums';
|
|
3
|
+
export const allImeisAreActiveForClient = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.clientId && !params?.imeiList?.length) {
|
|
5
|
+
logger.warn({ params }, 'DevicesRepository::allImeisAreActiveForClient missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const devicesRepository = dataSource.getRepository(Device);
|
|
10
|
+
const queryBuilder = devicesRepository
|
|
11
|
+
.createQueryBuilder('device')
|
|
12
|
+
.where('device.imei IN (:...imeiList)', {
|
|
13
|
+
imeiList: params.imeiList,
|
|
14
|
+
})
|
|
15
|
+
.andWhere('device.clientId = :clientId', {
|
|
16
|
+
clientId: params.clientId,
|
|
17
|
+
})
|
|
18
|
+
.andWhere('device.status = :status', {
|
|
19
|
+
status: DeviceStatus.Active,
|
|
20
|
+
});
|
|
21
|
+
const count = await queryBuilder.getCount();
|
|
22
|
+
return count === params.imeiList.length;
|
|
23
|
+
}, 'DevicesRepository::getDevicesImeis');
|
|
24
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientDeviceSetting, Device, DeviceCustomConfiguration, DeviceReplacement, DeviceType, IccidStatus, ImeiIccidCarrier } from '../../entities';
|
|
2
|
-
import { CanceledDeviceWithActiveSimCard, CarrierStatus, CreateClientDeviceSettingParams, CreateDeviceParams, CreateDeviceReplacementParams, CreateDeviceTypeParams, DeleteDeviceParams, DeviceTypeModelWithDeviceCount, DeviceWithUsersInfo, GenerateIdentifierKeyParams, GetCanceledDevicesWithActiveSimCardsParams, GetCarrierStatusUpdatedBeforeParams, GetClientDeviceSettingParams, GetClientDeviceSettingsParams, GetDeviceCustomConfigParams, GetDeviceParams, GetDevicesParams, GetDeviceTypeByImeiParams, GetDeviceTypesModelsOrderedByDeviceCountParams, GetDeviceTypesParams, GetDeviceWithUsersInfoParams, GetFilteredImeisWithStatusParams, GetIccidStatusParams, GetImeiIccidCarrierParams, GetImeiIccidCarriersParams, UpdateClientDeviceSettingParams, UpdateDeviceParams, UpdateDeviceTypeParams, UpdateIccidStatusParams, UpdateImeiIccidCarrierParams, UpsertIccidStatusParams } from '../../types/devices';
|
|
2
|
+
import { AllImeisAreActiveForClientParams, CanceledDeviceWithActiveSimCard, CarrierStatus, CreateClientDeviceSettingParams, CreateDeviceParams, CreateDeviceReplacementParams, CreateDeviceTypeParams, DeleteDeviceParams, DeviceTypeModelWithDeviceCount, DeviceWithUsersInfo, GenerateIdentifierKeyParams, GetCanceledDevicesWithActiveSimCardsParams, GetCarrierStatusUpdatedBeforeParams, GetClientDeviceSettingParams, GetClientDeviceSettingsParams, GetDeviceCustomConfigParams, GetDeviceParams, GetDevicesParams, GetDeviceTypeByImeiParams, GetDeviceTypesModelsOrderedByDeviceCountParams, GetDeviceTypesParams, GetDeviceWithUsersInfoParams, GetFilteredImeisWithStatusParams, GetIccidStatusParams, GetImeiIccidCarrierParams, GetImeiIccidCarriersParams, UpdateClientDeviceSettingParams, UpdateDeviceParams, UpdateDeviceTypeParams, UpdateIccidStatusParams, UpdateImeiIccidCarrierParams, UpsertIccidStatusParams } from '../../types/devices';
|
|
3
3
|
import { BaseRepository } from './../baseRepository';
|
|
4
4
|
export declare class DevicesRepository extends BaseRepository {
|
|
5
5
|
/**
|
|
@@ -22,6 +22,14 @@ export declare class DevicesRepository extends BaseRepository {
|
|
|
22
22
|
* - projectionOptions.withIccidCarrier: Whether to get the iccid carrier object
|
|
23
23
|
*/
|
|
24
24
|
getDevices(params: GetDevicesParams): Promise<Device[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if all imeis are active for a client
|
|
27
|
+
* @param {AllImeisAreActiveForClientParams} params containing information to check if all imeis are active for a client
|
|
28
|
+
* - imeis: The imeis to check
|
|
29
|
+
* - clientId: The client id
|
|
30
|
+
* @returns {Promise<boolean>} Whether all imeis are active for a client
|
|
31
|
+
*/
|
|
32
|
+
allImeisAreActiveForClient(params: AllImeisAreActiveForClientParams): Promise<boolean>;
|
|
25
33
|
/**
|
|
26
34
|
* Get filtered imeis with status
|
|
27
35
|
* @param {GetFilteredImeisWithStatusParams} params containing information to get filtered imeis with status
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NovaDataSource } from '../../novaDataSource';
|
|
2
2
|
import { BaseRepository } from './../baseRepository';
|
|
3
|
+
import { allImeisAreActiveForClient } from './allImeisAreActiveForClient';
|
|
3
4
|
import { createClientDeviceSetting } from './createClientDeviceSetting';
|
|
4
5
|
import { createDevice } from './createDevice';
|
|
5
6
|
import { createDeviceReplacement } from './createDeviceReplacement';
|
|
@@ -60,6 +61,20 @@ export class DevicesRepository extends BaseRepository {
|
|
|
60
61
|
this.logger.trace(result, 'DevicesRepository::getDevices result');
|
|
61
62
|
return result;
|
|
62
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if all imeis are active for a client
|
|
66
|
+
* @param {AllImeisAreActiveForClientParams} params containing information to check if all imeis are active for a client
|
|
67
|
+
* - imeis: The imeis to check
|
|
68
|
+
* - clientId: The client id
|
|
69
|
+
* @returns {Promise<boolean>} Whether all imeis are active for a client
|
|
70
|
+
*/
|
|
71
|
+
async allImeisAreActiveForClient(params) {
|
|
72
|
+
this.logger.trace(params, 'DevicesRepository::allImeisAreActiveForClient started with params');
|
|
73
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
74
|
+
const result = await allImeisAreActiveForClient(novaDataSource, params, this.logger);
|
|
75
|
+
this.logger.trace({ result }, 'DevicesRepository::allImeisAreActiveForClient result');
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
63
78
|
/**
|
|
64
79
|
* Get filtered imeis with status
|
|
65
80
|
* @param {GetFilteredImeisWithStatusParams} params containing information to get filtered imeis with status
|
package/dist/types/devices.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export interface GetDevicesParams {
|
|
|
23
23
|
withClientDeviceSettings: boolean;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
export interface AllImeisAreActiveForClientParams {
|
|
27
|
+
imeiList: string[];
|
|
28
|
+
clientId: number;
|
|
29
|
+
}
|
|
26
30
|
export interface GetFilteredImeisWithStatusParams {
|
|
27
31
|
filters: {
|
|
28
32
|
imeiList: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spytecgps/nova-orm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "ORM with PlanetScale",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"typescript": "^4.9.5",
|
|
27
27
|
"webpack": "^5.72.0",
|
|
28
28
|
"webpack-cli": "^4.9.2",
|
|
29
|
-
"webpack-node-externals": "^3.0.0",
|
|
30
29
|
"yarn": "^1.22.19"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|