@spytecgps/nova-orm 0.0.27 → 0.0.29

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.
@@ -1,5 +1,6 @@
1
1
  import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, QueryRunner, ReplicationMode, Repository, SelectQueryBuilder } from 'typeorm';
2
2
  import { Logger } from './types/logger';
3
+ export type queryBuilderHandler<T> = (novaDataSource: NovaDataSource) => Promise<T>;
3
4
  export interface NovaDataSourceConfig {
4
5
  /**
5
6
  * Database username.
@@ -66,4 +67,5 @@ export declare class NovaDataSource {
66
67
  * if you perform reads you can use slave databases.
67
68
  */
68
69
  createQueryRunner(mode?: ReplicationMode): QueryRunner;
70
+ safeQuery<T>(queryBuilderHandler: queryBuilderHandler<T>, tag?: string): Promise<T>;
69
71
  }
@@ -0,0 +1,5 @@
1
+ import { DeviceTypeFirmware } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateDeviceFirmwareParams } from '../../types/firmwares';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createDeviceFirmware: (novaDataSource: NovaDataSource, params: CreateDeviceFirmwareParams, logger: Logger) => Promise<DeviceTypeFirmware>;
@@ -0,0 +1,5 @@
1
+ import { FirmwareUpgradeTask } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateFirmwareUpgradeTaskParams } from '../../types/firmwares';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createFirmwareUpgradeTask: (novaDataSource: NovaDataSource, params: CreateFirmwareUpgradeTaskParams, logger: Logger) => Promise<FirmwareUpgradeTask>;
@@ -0,0 +1,4 @@
1
+ import { DeviceTypeFirmware } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetDeviceFirmwaresParams } from '../../types/firmwares';
4
+ export declare const getDeviceFirmwares: (novaDataSource: NovaDataSource, params: GetDeviceFirmwaresParams) => Promise<DeviceTypeFirmware[]>;
@@ -0,0 +1,5 @@
1
+ import { FirmwareUpgradeTask } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetFirmwareUpgradeTasksParams } from '../../types/firmwares';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getFirmwareUpgradeTasks: (novaDataSource: NovaDataSource, params: GetFirmwareUpgradeTasksParams, logger: Logger) => Promise<FirmwareUpgradeTask[]>;
@@ -0,0 +1,73 @@
1
+ import { DeviceTypeFirmware, FirmwareUpgradeTask } from '../../entities';
2
+ import { CreateDeviceFirmwareParams, CreateFirmwareUpgradeTaskParams, GetDeviceFirmwaresParams, GetFirmwareUpgradeTasksParams, UpdateFirmwareUpgradeTaskParams } from '../../types/firmwares';
3
+ import { BaseRepository } from '../baseRepository';
4
+ export declare class FirmwaresRepository extends BaseRepository {
5
+ /**
6
+ * Get all devices firmwares.
7
+ * @param {GetDeviceFirmwaresParams} params containing information to get a device with filters.
8
+ * If no params or filter is specified, all devices firmwares will be returned.
9
+ * - filters.deviceTypeId: The device type id of the device
10
+ * - projectionOptions.withDeviceType: Whether to get the device type object
11
+ * @returns A list of devices firmwares.
12
+ */
13
+ getDeviceFirmwares(params?: GetDeviceFirmwaresParams): Promise<DeviceTypeFirmware[]>;
14
+ /**
15
+ * Create a new device firmware.
16
+ * @param {CreateDeviceFirmwareParams} params containing information to create a devicetype firmware.
17
+ * - deviceTypeId: The device type id
18
+ * - description: The description of the firmware version
19
+ * - enabled: Whether the firmware version is enabled or not
20
+ * - firmwareCode: The firmware version code
21
+ * - firmwareVersion: The firmware version after the firmware version is upgraded
22
+ * - firmwareUrl: The url to download the firmware
23
+ * - releaseDate: The date when the firmware version is released
24
+ * - sourceFirmwareVersion: The source firmware version that needs to match to apply this new firmware version. It can be null, if not precise version is needed.
25
+ * - upgradeType: The upgrade type depending on the module type
26
+ * - 0: BB
27
+ * - 1: MCU
28
+ * - 2: BLE
29
+ * - 7: MODEM
30
+ * @returns The newly created entity.
31
+ */
32
+ createDeviceFirmware(params: CreateDeviceFirmwareParams): Promise<DeviceTypeFirmware>;
33
+ /**
34
+ * Create a new firmware upgrade task.
35
+ * @param {CreateFirmwareUpgradeTaskParams} params containing information to create a firmware upgrade task.
36
+ * - id: The firmware upgrade task id
37
+ * - deviceTypeFirmwareId: The device type firmware id
38
+ * - clientId: The client id
39
+ * - deviceId: The device id
40
+ * - status: The status of the firmware upgrade task
41
+ * - behaviorName: The behavior name
42
+ * - behaviorParams: The behavior params
43
+ * - createdAt: The date when the firmware upgrade task is created
44
+ * - modifiedAt: The date when the firmware upgrade task is modified
45
+ * - preConfig: The pre config of the device before sending the upgrade command
46
+ * - postConfig: The post config of the device after sending the upgrade command *
47
+ * @returns The newly created entity.
48
+ */
49
+ createFirmwareUpgradeTask(params: CreateFirmwareUpgradeTaskParams): Promise<FirmwareUpgradeTask>;
50
+ /**
51
+ * Get firmware upgrade tasks based on the filters.
52
+ * @param {GetFirmwareUpgradeTasksParams} params containing information to get a firmware upgrade task with filters.
53
+ * At leas one filter must be specified.
54
+ * - filters.deviceId: The device id
55
+ * - filters.firmwareId: The firmware id
56
+ * - filters.taskId: The task id
57
+ * - projectionOptions.withDeviceFirmware: Whether to get the device firmware object
58
+ * @returns {FirmwareUpgradeTask[]} A list of firmware upgrade tasks.
59
+ */
60
+ getFirmwareUpgradeTasks(params: GetFirmwareUpgradeTasksParams): Promise<FirmwareUpgradeTask[]>;
61
+ /**
62
+ * Partially update firmware upgrade tasks based.
63
+ * @param {UpdateFirmwareUpgradeTaskParams} params containing information to update a firmware upgrade task.
64
+ * - id: The firmware upgrade task id
65
+ * - behaviorName: The behavior name
66
+ * - behaviorParams: The behavior params
67
+ * - status: The status of the firmware upgrade task
68
+ * - preConfig: The pre config of the device before sending the upgrade command
69
+ * - postConfig: The post config of the device after sending the upgrade command
70
+ * @returns {boolea} Whether the firmware upgrade task is updated or not.
71
+ */
72
+ updateFirmwareUpgradeTasks(params: UpdateFirmwareUpgradeTaskParams): Promise<boolean>;
73
+ }
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateFirmwareUpgradeTaskParams } from '../../types/firmwares';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateFirmwareUpgradeTasks: (novaDataSource: NovaDataSource, params: UpdateFirmwareUpgradeTaskParams, logger: Logger) => Promise<boolean>;
@@ -1,5 +1,6 @@
1
1
  import { BoundariesRepository } from './boundaries';
2
2
  import { ClientsRepository } from './clients';
3
3
  import { DevicesRepository } from './devices';
4
+ import { FirmwaresRepository } from './firmwares';
4
5
  import { SecurityRepository } from './security';
5
- export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository };
6
+ export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository, FirmwaresRepository, };
@@ -0,0 +1,61 @@
1
+ export interface GetDeviceFirmwaresParams {
2
+ filters: {
3
+ deviceTypeId?: number;
4
+ firmwareId?: number;
5
+ };
6
+ projectionOptions?: {
7
+ withDeviceType: boolean;
8
+ };
9
+ }
10
+ export interface GetFirmwareUpgradeTasksParams {
11
+ filters: {
12
+ deviceId?: number;
13
+ firmwareId?: number;
14
+ taskId?: string;
15
+ };
16
+ projectionOptions?: {
17
+ withDeviceFirmware: boolean;
18
+ };
19
+ }
20
+ export type UpgradeType = '0' | '1' | '2' | '7';
21
+ export interface CreateDeviceFirmwareParams {
22
+ deviceTypeId: number;
23
+ sourceFirmwareVersion?: string;
24
+ firmwareVersion: string;
25
+ firmwareCode: string;
26
+ firmwareUrl: string;
27
+ releaseDate: Date;
28
+ description: string;
29
+ enabled: boolean;
30
+ upgradeType: UpgradeType;
31
+ }
32
+ export declare enum FirmwareUpgradeTaskStatus {
33
+ Queued = "Queued",
34
+ QueuedWaitingForConfig = "QueuedWaitingForConfig",
35
+ QueuedWaitingForVersionMessage = "QueuedWaitingForVersionMessage",
36
+ InProgress = "InProgress",
37
+ Completed = "Completed",
38
+ Canceled = "Canceled",
39
+ Failed = "Failed"
40
+ }
41
+ export interface CreateFirmwareUpgradeTaskParams {
42
+ id: string;
43
+ deviceTypeFirmwareId: number;
44
+ clientId: number;
45
+ deviceId: number;
46
+ status: FirmwareUpgradeTaskStatus;
47
+ behaviorName?: string;
48
+ behaviorParams?: object;
49
+ createdAt?: Date;
50
+ modifiedAt?: Date;
51
+ preConfig?: string;
52
+ postConfig?: string;
53
+ }
54
+ export interface UpdateFirmwareUpgradeTaskParams {
55
+ id: string;
56
+ status?: FirmwareUpgradeTaskStatus;
57
+ behaviorName?: string;
58
+ behaviorParams?: object;
59
+ preConfig?: string;
60
+ postConfig?: string;
61
+ }
@@ -1,6 +1,7 @@
1
1
  import * as Boundaries from './boundaries';
2
2
  import * as Clients from './clients';
3
3
  import * as Devices from './devices';
4
+ import * as Firmwares from './firmwares';
4
5
  import * as Logger from './logger';
5
6
  import * as Security from './security';
6
- export { Logger, Devices, Security, Boundaries, Clients };
7
+ export { Logger, Devices, Firmwares, Security, Boundaries, Clients };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",