@spytecgps/nova-orm 0.0.25 → 0.0.26

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.
@@ -0,0 +1,5 @@
1
+ import { ClientDeviceSetting } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateClientDeviceSettingParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createClientDeviceSetting: (novaDataSource: NovaDataSource, params: CreateClientDeviceSettingParams, logger: Logger) => Promise<ClientDeviceSetting>;
@@ -0,0 +1,5 @@
1
+ import { Device } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateDeviceParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createDevice: (novaDataSource: NovaDataSource, params: CreateDeviceParams, logger: Logger) => Promise<Device>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { DeleteDeviceParams } from '../../types/devices';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const deleteDevice: (novaDataSource: NovaDataSource, params: DeleteDeviceParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { GenerateIdentifierKeyParams } from '../../types/devices';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const generateDeviceIdentifierKey: (novaDataSource: NovaDataSource, params: GenerateIdentifierKeyParams, logger: Logger) => Promise<string>;
@@ -0,0 +1,5 @@
1
+ import { ClientDeviceSetting } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetClientDeviceSettingParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getClientDeviceSetting: (novaDataSource: NovaDataSource, params: GetClientDeviceSettingParams, logger: Logger) => Promise<ClientDeviceSetting>;
@@ -0,0 +1,5 @@
1
+ import { ClientDeviceSetting } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetClientDeviceSettingsParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getClientDeviceSettings: (novaDataSource: NovaDataSource, params: GetClientDeviceSettingsParams, logger: Logger) => Promise<ClientDeviceSetting[]>;
@@ -0,0 +1,5 @@
1
+ import { Device } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetDeviceParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getDevice: (novaDataSource: NovaDataSource, params: GetDeviceParams, logger: Logger) => Promise<Device>;
@@ -0,0 +1,5 @@
1
+ import { Device } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetDevicesParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getDevices: (novaDataSource: NovaDataSource, params: GetDevicesParams, logger: Logger) => Promise<Device[]>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { GetFilteredImeisWithStatusParams } from '../../types/devices';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const getFilteredImeisWithStatus: (novaDataSource: NovaDataSource, params: GetFilteredImeisWithStatusParams, logger: Logger) => Promise<string[]>;
@@ -0,0 +1,5 @@
1
+ import { ImeiIccidCarrier } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetImeiIccidCarrierParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getImeiIccidCarrier: (novaDataSource: NovaDataSource, params: GetImeiIccidCarrierParams, logger: Logger) => Promise<ImeiIccidCarrier>;
@@ -0,0 +1,5 @@
1
+ import { ImeiIccidCarrier } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetImeiIccidCarriersParams } from '../../types/devices';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getImeiIccidCarriers: (novaDataSource: NovaDataSource, params: GetImeiIccidCarriersParams, logger: Logger) => Promise<ImeiIccidCarrier[]>;
@@ -1,28 +1,178 @@
1
- import { Device, DeviceType } from '../../entities';
2
- import { GetDeviceByImeiParams, GetDevicesByDeviceTypeIdParams, GetDeviceTypesParams } from '../../types/devices';
1
+ import { ClientDeviceSetting, Device, DeviceType, ImeiIccidCarrier } from '../../entities';
2
+ import { CreateClientDeviceSettingParams, CreateDeviceParams, DeleteDeviceParams, GenerateIdentifierKeyParams, GetClientDeviceSettingParams, GetClientDeviceSettingsParams, GetDeviceParams, GetDevicesParams, GetDeviceTypesParams, GetFilteredImeisWithStatusParams, GetImeiIccidCarrierParams, GetImeiIccidCarriersParams, UpdateClientDeviceSettingParams, UpdateDeviceParams, UpdateImeiIccidCarrierParams } from '../../types/devices';
3
3
  import { BaseRepository } from './../baseRepository';
4
4
  export declare class DevicesRepository extends BaseRepository {
5
5
  /**
6
- * Get device by imei
7
- * @param {GetDeviceByImeiParams} params containing information to get a device by imei
6
+ * Get device with filters
7
+ * @param {GetDeviceParams} params containing information to get a device with filters
8
8
  * - filters.imei: The imei of the device
9
+ * - filters.id: The id of the device
9
10
  * - projectionOptions.withDeviceType: Whether to get the device type object
10
11
  * - projectionOptions.withIccidCarrier: Whether to get the iccid carrier object
11
12
  */
12
- getDeviceByImei(params: GetDeviceByImeiParams): Promise<Device>;
13
+ getDevice(params: GetDeviceParams): Promise<Device>;
13
14
  /**
14
15
  * Get devices by type id
15
- * @param {GetDevicesByDeviceTypeIdParams} params containing information to get devices by type id
16
+ * @param {GetDevicesParams} params containing information to get devices by type id
16
17
  * - filters.deviceTypeId: The device type id
17
- * - filters.onlyActiveDevices: Whether to get only active devices
18
+ * - filters.status: The device status
19
+ * - filters.clientId: The client id
20
+ * - filters.imeiList: The imei list
18
21
  * - projectionOptions.withDeviceType: Whether to get the device type object
19
22
  * - projectionOptions.withIccidCarrier: Whether to get the iccid carrier object
20
23
  */
21
- getDevicesByDeviceTypeId(params: GetDevicesByDeviceTypeIdParams): Promise<Device[]>;
24
+ getDevices(params: GetDevicesParams): Promise<Device[]>;
25
+ /**
26
+ * Get filtered imeis with status
27
+ * @param {GetFilteredImeisWithStatusParams} params containing information to get filtered imeis with status
28
+ * - filters.imeiList: The imei list to filter
29
+ * - filters.status: The device status
30
+ * @returns {Promise<string>} The imei list filtered by status
31
+ */
32
+ getFilteredImeisWithStatus(params: GetFilteredImeisWithStatusParams): Promise<string[]>;
33
+ /**
34
+ * Create device
35
+ * @param {CreateDeviceParams} params containing information to create a device
36
+ * - identifier: The device identifier
37
+ * - imei: The imei of the device
38
+ * - clientId: The client id
39
+ * - deviceTypeId: The device type id
40
+ * - iccid: The iccid of the device
41
+ * - name: The name of the device
42
+ * - color: The color of the device
43
+ * - icon: The icon of the device
44
+ * - status: The status of the device
45
+ * - forward: Whether to forward the device
46
+ * - description: The description of the device
47
+ * - dataSourceTypeId: The data source type id of the device
48
+ * - assetCategoryId: The asset category id of the device
49
+ * - usageRegion: The usage region of the device
50
+ * - createdBy: The user who created the device
51
+ *
52
+ * @returns {Promise<Device>} The created device
53
+ */
54
+ createDevice(params: CreateDeviceParams): Promise<Device>;
55
+ /**
56
+ * Update device
57
+ * @param {UpdateDeviceParams} params containing information to update a device
58
+ * - filters.imei: The imei of the device
59
+ * - filters.status: The status of the device
60
+ * - values.clientId: The client id
61
+ * - values.deviceTypeId: The device type id
62
+ * - values.iccid: The iccid of the device
63
+ * - values.name: The name of the device
64
+ * - values.color: The color of the device
65
+ * - values.icon: The icon of the device
66
+ * - values.status: The status of the device
67
+ * - values.forward: Whether to forward the device
68
+ * - values.description: The description of the device
69
+ * - values.dataSourceTypeId: The data source type id of the device
70
+ * - values.assetCategoryId: The asset category id of the device
71
+ * - values.usageRegion: The usage region of the device
72
+ * - values.modifiedBy: The user who updated the device
73
+ * @returns {Promise<boolean>} Whether the device was updated
74
+ */
75
+ updateDevice(params: UpdateDeviceParams): Promise<boolean>;
76
+ /**
77
+ * Delete device
78
+ * @param {DeleteDeviceParams} params containing information to delete a device
79
+ * - filters.imei: The imei of the device
80
+ *
81
+ * @returns {Promise<boolean>} Whether the device was deleted
82
+ */
83
+ deleteDevice(params: DeleteDeviceParams): Promise<boolean>;
84
+ /**
85
+ * Generate device identifier key from device type and device identifier
86
+ * @param {GenerateIdentifierKeyParams} params containing information to generate a device identifier key
87
+ * - deviceTypeId: The device type id
88
+ * - deviceIdentifier: The device identifier
89
+ * @returns {Promise<string>} The generated device identifier key
90
+ */
91
+ generateDeviceIdentifierKey(params: GenerateIdentifierKeyParams): Promise<string>;
22
92
  /**
23
93
  * Get device types
24
94
  * @param {GetDeviceTypesParams} params containing information to get device types
25
95
  * - filters.onlyWithRelatedIccidCarrier: Whether to get only device types with iccid carrier
26
96
  */
27
97
  getDeviceTypes(params: GetDeviceTypesParams): Promise<DeviceType[]>;
98
+ /**
99
+ * Get ImeiIccidCarrier
100
+ * @param {GetImeiIccidCarrierParams} params containing information to get the ImeiIccidCarrier
101
+ * - filters.imei: The imei of the device
102
+ * - filters.iccid: The iccid of the device
103
+ * @returns {Promise<ImeiIccidCarrier>} The imei iccid carrier
104
+ */
105
+ getImeiIccidCarrier(params: GetImeiIccidCarrierParams): Promise<ImeiIccidCarrier>;
106
+ /**
107
+ * Get ImeiIccidCarriers from a list of imeis
108
+ * @param {GetImeiIccidCarriersParams} params containing information to get the ImeiIccidCarriers
109
+ * - filters.imeis: The imeis of the devices
110
+ * @returns {Promise<ImeiIccidCarrier[]>} The imei iccid carriers
111
+ */
112
+ getImeiIccidCarriers(params: GetImeiIccidCarriersParams): Promise<ImeiIccidCarrier[]>;
113
+ /**
114
+ * Update the ImeiIccidCarrier
115
+ * @param {UpdateImeiIccidCarrierParams} params containing information to update the ImeiIccidCarrier
116
+ * - filters.imei: The imei of the device to update
117
+ * - filters.iccid: The iccid of the device to update
118
+ * - values.carrierId: The carrier id
119
+ * - values.phone: The phone or MSISDN of the device
120
+ * - values.deviceTypeId: The device type id
121
+ * - values.serviceProviderProductId: The service provider product id
122
+ * - values.isValid: Whether the imei iccid carrier is valid
123
+ * - values.realModel: The real model of the device
124
+ * - values.po: The purchase order number of the device
125
+ * - values.outOfInventory: Whether the device is out of inventory
126
+ * - values.apn: The apn of the device
127
+ *
128
+ * @returns {Promise<boolean>} Whether the imei iccid carrier was updated
129
+ */
130
+ updateImeiIccidCarrier(params: UpdateImeiIccidCarrierParams): Promise<boolean>;
131
+ /**
132
+ * Get a ClientDeviceSetting
133
+ * @param {GetClientDeviceSettingParams} params containing information to get a ClientDeviceSetting
134
+ * - filters.imei: The imei of the device
135
+ * - filters.clientId: The client id
136
+ * @returns {Promise<ClientDeviceSetting>} The ClientDeviceSetting
137
+ */
138
+ getClientDeviceSetting(params: GetClientDeviceSettingParams): Promise<ClientDeviceSetting>;
139
+ /**
140
+ * Get a list of ClientDeviceSettings with filters
141
+ * @param {GetClientDeviceSettingsParams} params containing information to get ClientDeviceSettings
142
+ * - filters.clientId: The client id
143
+ * @returns {Promise<ClientDeviceSetting[]>} An array of ClientDeviceSettings matching the filters
144
+ */
145
+ getClientDeviceSettings(params: GetClientDeviceSettingsParams): Promise<ClientDeviceSetting[]>;
146
+ /**
147
+ * Create a ClientDeviceSetting
148
+ * @param {CreateClientDeviceSettingParams} params containing information to create a ClientDeviceSetting
149
+ * - values.imei: The imei of the device
150
+ * - values.clientId: The client id
151
+ * - values.generateTrips: Whether to generate trips
152
+ * - values.movingPingFrequency: The moving ping frequency
153
+ * - values.stoppedPingFrequency: The stopped ping frequency
154
+ * - values.fixedStatus: The fixed status
155
+ * - values.stopThresholdMinutes: The threshold in minutes to consider that the device is stopped
156
+ * - values.offlineThresholdMinutes: The threshold in minutes to consider that the device is offline
157
+ * - values.movementThresholdSpeed: The threshold for the speed to consider that the device is moving
158
+ * - values.externalBatteryInformation: The external battery information
159
+ * @returns {Promise<ClientDeviceSetting>} The created ClientDeviceSetting
160
+ */
161
+ createClientDeviceSetting(params: CreateClientDeviceSettingParams): Promise<ClientDeviceSetting>;
162
+ /**
163
+ * Update a ClientDeviceSetting
164
+ * @param {UpdateClientDeviceSettingParams} params containing information to update a ClientDeviceSetting
165
+ * - filters.imei: The imei of the device
166
+ * - filters.clientId: The client id
167
+ * - values.generateTrips: Whether to generate trips
168
+ * - values.movingPingFrequency: The moving ping frequency
169
+ * - values.stoppedPingFrequency: The stopped ping frequency
170
+ * - values.fixedStatus: The fixed status
171
+ * - values.stopThresholdMinutes: The threshold in minutes to consider that the device is stopped
172
+ * - values.offlineThresholdMinutes: The threshold in minutes to consider that the device is offline
173
+ * - values.movementThresholdSpeed: The threshold for the speed to consider that the device is moving
174
+ * - values.externalBatteryInformation: The external battery information
175
+ * @returns {Promise<boolean>} Whether the ClientDeviceSetting was updated
176
+ */
177
+ updateClientDeviceSetting(params: UpdateClientDeviceSettingParams): Promise<boolean>;
28
178
  }
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateClientDeviceSettingParams } from '../../types/devices';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateClientDeviceSetting: (novaDataSource: NovaDataSource, params: UpdateClientDeviceSettingParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateDeviceParams } from '../../types/devices';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateDevice: (novaDataSource: NovaDataSource, params: UpdateDeviceParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateImeiIccidCarrierParams } from '../../types/devices';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateImeiIccidCarrier: (novaDataSource: NovaDataSource, params: UpdateImeiIccidCarrierParams, logger: Logger) => Promise<boolean>;
@@ -1,24 +1,156 @@
1
- export interface GetDeviceByImeiParams {
1
+ import { DeviceStatus } from './enums';
2
+ export interface GetDeviceParams {
2
3
  filters: {
3
- imei: string;
4
+ id?: number;
5
+ imei?: string;
4
6
  };
5
7
  projectionOptions: {
6
8
  withDeviceType: boolean;
7
9
  withIccidCarrier: boolean;
10
+ withClientDeviceSettings: boolean;
8
11
  };
9
12
  }
10
- export interface GetDevicesByDeviceTypeIdParams {
13
+ export interface GetDevicesParams {
11
14
  filters: {
12
- deviceTypeId: number;
13
- onlyActiveDevices: boolean;
15
+ deviceTypeId?: number;
16
+ status?: DeviceStatus;
17
+ clientId?: number;
18
+ imeiList?: string[];
14
19
  };
15
20
  projectionOptions: {
16
21
  withDeviceType: boolean;
17
22
  withIccidCarrier: boolean;
23
+ withClientDeviceSettings: boolean;
24
+ };
25
+ }
26
+ export interface GetFilteredImeisWithStatusParams {
27
+ filters: {
28
+ imeiList: string[];
29
+ status: DeviceStatus;
18
30
  };
19
31
  }
32
+ export interface CreateDeviceParams {
33
+ values: {
34
+ imei: string;
35
+ clientId: number;
36
+ deviceTypeId: number;
37
+ identifier?: string;
38
+ iccid?: string;
39
+ name?: string;
40
+ color?: string;
41
+ icon?: string;
42
+ status?: string;
43
+ forward?: boolean;
44
+ description?: string;
45
+ dataSourceTypeId?: number;
46
+ assetCategoryId?: number;
47
+ usageRegion?: string;
48
+ createdBy?: string;
49
+ };
50
+ updateParamsIfDeviceExists?: UpdateDeviceParams;
51
+ }
52
+ export interface UpdateDeviceParams {
53
+ filters: {
54
+ imei: string;
55
+ status?: DeviceStatus;
56
+ };
57
+ values: {
58
+ clientId?: number;
59
+ deviceTypeId?: number;
60
+ iccid?: string;
61
+ name?: string;
62
+ color?: string;
63
+ icon?: string;
64
+ status?: DeviceStatus;
65
+ forward?: boolean;
66
+ description?: string;
67
+ dataSourceTypeId?: number;
68
+ assetCategoryId?: number;
69
+ usageRegion?: string;
70
+ modifiedBy?: string;
71
+ };
72
+ }
73
+ export interface DeleteDeviceParams {
74
+ filters: {
75
+ imei: string;
76
+ };
77
+ }
78
+ export interface GenerateIdentifierKeyParams {
79
+ deviceTypeId: number;
80
+ deviceIdentifier: string;
81
+ }
20
82
  export interface GetDeviceTypesParams {
21
83
  filters: {
22
- onlyWithRelatedIccidCarrier: boolean;
84
+ deviceTypeIdList?: number[];
85
+ brand?: string;
86
+ model?: string;
87
+ onlyWithRelatedIccidCarrier?: boolean;
88
+ };
89
+ }
90
+ export interface GetImeiIccidCarrierParams {
91
+ filters: {
92
+ imei?: string;
93
+ iccid?: string;
94
+ };
95
+ }
96
+ export interface GetImeiIccidCarriersParams {
97
+ filters: {
98
+ imeiList: string[];
99
+ };
100
+ }
101
+ export interface UpdateImeiIccidCarrierParams {
102
+ filters: {
103
+ imei?: string;
104
+ iccid?: string;
105
+ };
106
+ values: {
107
+ carrier?: number;
108
+ phone?: string;
109
+ deviceTypeId?: number;
110
+ serviceProviderProductId?: number;
111
+ isValid?: boolean;
112
+ realModel?: string;
113
+ po?: string;
114
+ outOfInventory?: boolean;
115
+ apn?: string;
116
+ };
117
+ }
118
+ export interface GetClientDeviceSettingParams {
119
+ filters: {
120
+ imei: string;
121
+ clientId: number;
122
+ };
123
+ }
124
+ export interface GetClientDeviceSettingsParams {
125
+ filters: {
126
+ clientId: number;
127
+ };
128
+ }
129
+ export interface CreateClientDeviceSettingParams {
130
+ imei: string;
131
+ clientId: number;
132
+ generateTrips?: boolean;
133
+ movingPingFrequency?: number;
134
+ stoppedPingFrequency?: number;
135
+ fixedStatus?: string;
136
+ stopThresholdMinutes?: number;
137
+ offlineThresholdMinutes?: number;
138
+ movementThresholdSpeed?: number;
139
+ externalBatteryInformation?: boolean;
140
+ }
141
+ export interface UpdateClientDeviceSettingParams {
142
+ filters: {
143
+ imei: string;
144
+ clientId: number;
145
+ };
146
+ values: {
147
+ generateTrips?: boolean;
148
+ movingPingFrequency?: number;
149
+ stoppedPingFrequency?: number;
150
+ fixedStatus?: string;
151
+ stopThresholdMinutes?: number;
152
+ offlineThresholdMinutes?: number;
153
+ movementThresholdSpeed?: number;
154
+ externalBatteryInformation?: boolean;
23
155
  };
24
156
  }
@@ -0,0 +1,5 @@
1
+ import { ValueTransformer } from 'typeorm';
2
+ export declare class BoolToNumberTransformer implements ValueTransformer {
3
+ to(value: boolean | null): number | null;
4
+ from(value: number): boolean | null;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { Logger, LogLevel } from '../types/logger';
2
+ export declare class ConsoleLogger implements Logger {
3
+ fatal: (msgOrObj: string | object, msg?: string, ...args: any[]) => void;
4
+ error: (msgOrObj: string | object, msg?: string, ...args: any[]) => void;
5
+ warn: (msgOrObj: string | object, msg?: string, ...args: any[]) => void;
6
+ info: (msgOrObj: string | object, msg?: string, ...args: any[]) => void;
7
+ debug: (msgOrObj: string | object, msg?: string, ...args: any[]) => void;
8
+ trace: (msgOrObj: string | object, msg?: string, ...args: any[]) => void;
9
+ log: (level: LogLevel, msgOrObj: string | object, msg?: string, ...args: any[]) => void;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,5 +0,0 @@
1
- import { Device } from '../../entities';
2
- import { NovaDataSource } from '../../novaDataSource';
3
- import { GetDeviceByImeiParams } from '../../types/devices';
4
- import { Logger } from '../../types/logger';
5
- export declare const getDeviceByImei: (novaDataSource: NovaDataSource, params: GetDeviceByImeiParams, logger: Logger) => Promise<Device>;
@@ -1,5 +0,0 @@
1
- import { Device } from '../../entities';
2
- import { NovaDataSource } from '../../novaDataSource';
3
- import { GetDevicesByDeviceTypeIdParams } from '../../types/devices';
4
- import { Logger } from '../../types/logger';
5
- export declare const getDevicesByDeviceTypeId: (novaDataSource: NovaDataSource, params: GetDevicesByDeviceTypeIdParams, logger: Logger) => Promise<Device[]>;
@@ -1,2 +0,0 @@
1
- import { Logger, LogLevel } from '../types/logger';
2
- export declare const writeToLog: (logger: Logger, level: LogLevel, obj: any, message: string) => void;