@spytecgps/nova-orm 0.0.19 → 0.0.21

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,4 +1,4 @@
1
- import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, Repository, SelectQueryBuilder } from 'typeorm';
1
+ import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, QueryRunner, ReplicationMode, Repository, SelectQueryBuilder } from 'typeorm';
2
2
  import { Logger } from './types/logger';
3
3
  export interface NovaDataSourceConfig {
4
4
  /**
@@ -55,4 +55,15 @@ export declare class NovaDataSource {
55
55
  * Creates a new query builder that can be used to build a SQL query.
56
56
  */
57
57
  createQueryBuilder<Entity extends ObjectLiteral>(entityClass: EntityTarget<Entity>, alias: string): Promise<SelectQueryBuilder<Entity>>;
58
+ /**
59
+ * Creates a query runner used for perform queries on a single database connection.
60
+ * Using query runners you can control your queries to execute using single database connection and
61
+ * manually control your database transaction.
62
+ *
63
+ * Mode is used in replication mode and indicates whatever you want to connect
64
+ * to master database or any of slave databases.
65
+ * If you perform writes you must use master database,
66
+ * if you perform reads you can use slave databases.
67
+ */
68
+ createQueryRunner(mode?: ReplicationMode): QueryRunner;
58
69
  }
@@ -0,0 +1,5 @@
1
+ import { Client } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateClientParams } from '../../types/clients';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createClient: (novaDataSource: NovaDataSource, params: CreateClientParams, logger: Logger) => Promise<Client>;
@@ -0,0 +1,5 @@
1
+ import { ClientConfiguration } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateClientConfigurationParams } from '../../types/clients';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createClientConfiguration: (novaDataSource: NovaDataSource, params: CreateClientConfigurationParams, logger: Logger) => Promise<ClientConfiguration>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { DeleteClientParams } from '../../types/clients';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const deleteClientAndConfiguration: (novaDataSource: NovaDataSource, params: DeleteClientParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { Client } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetClientParams } from '../../types/clients';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getClient: (novaDataSource: NovaDataSource, params: GetClientParams, logger: Logger) => Promise<Client>;
@@ -0,0 +1,5 @@
1
+ import { ClientConfiguration } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetClientConfigurationParams } from '../../types/clients';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const getClientConfiguration: (novaDataSource: NovaDataSource, params: GetClientConfigurationParams, logger: Logger) => Promise<ClientConfiguration>;
@@ -0,0 +1,89 @@
1
+ import { Client, ClientConfiguration } from '../../entities';
2
+ import { CreateClientConfigurationParams, CreateClientParams, DeleteClientParams, GetClientConfigurationParams, GetClientParams, UpdateClientConfigurationParams, UpdateClientParams } from '../../types/clients';
3
+ import { BaseRepository } from '../baseRepository';
4
+ export declare class ClientsRepository extends BaseRepository {
5
+ /**
6
+ * Get a client by id or email
7
+ * @param {GetClientParams} params containing information to get a client
8
+ * - filters.clientId: The client id, optional
9
+ * - filters.email: The email, optional
10
+ */
11
+ getClient(params: GetClientParams): Promise<Client>;
12
+ /**
13
+ * Create client
14
+ * @param {CreateClientParams} params containing information to create a client
15
+ * - name: client name
16
+ * - email: client email
17
+ * - uuid: client uuid
18
+ * - appClientId: app client id, optional
19
+ * - clientTypeId: client type id, optional
20
+ * - dataSourceTypeId: data source type id, optional
21
+ * - sievaUserName: sieva user name, optional
22
+ * - sievaBatchId: sieva batch id, optional
23
+ * - salesforceId: salesforce id, optional
24
+ * - accumaticaId: accumatica id, optional
25
+ * - expirationDate: expiration date, optional
26
+ * - useType: use type, optional
27
+ * - btCustomerId: bt customer id, optional
28
+ * - activationCampaign: activation campaign, optional
29
+ * - organizationId: organization id, optional
30
+ * @returns {Promise<Client>} The created client
31
+ */
32
+ createClient(params: CreateClientParams): Promise<Client>;
33
+ /**
34
+ * Create client
35
+ * @param {UpdateClientParams} params containing information to update a client
36
+ * - filters.clientId: The id of the client to update
37
+ * - values.name: client name, optional
38
+ * - values.email: client email, optional
39
+ * - values.uuid: client uuid, optional
40
+ * - values.appClientId: app client id, optional
41
+ * - values.clientTypeId: client type id, optional
42
+ * - values.dataSourceTypeId: data source type id, optional
43
+ * - values.sievaUserName: sieva user name, optional
44
+ * - values.sievaBatchId: sieva batch id, optional
45
+ * - values.salesforceId: salesforce id, optional
46
+ * - values.accumaticaId: accumatica id, optional
47
+ * - values.expirationDate: expiration date, optional
48
+ * - values.useType: use type, optional
49
+ * - values.btCustomerId: bt customer id, optional
50
+ * - values.activationCampaign: activation campaign, optional
51
+ * - values.organizationId: organization id, optional
52
+ * @returns {Promise<boolean>} True if the client was updated, false otherwise
53
+ */
54
+ updateClient(params: UpdateClientParams): Promise<boolean>;
55
+ /**
56
+ * Delete a client and its configurations
57
+ * @param {DeleteClientParams} params containing information to delete a client
58
+ * - filters.clientId: The id of the client to delete
59
+ * @returns {Promise<boolean>} True if the client was deleted, false otherwise
60
+ */
61
+ deleteClientAndConfigurations(params: DeleteClientParams): Promise<boolean>;
62
+ /**
63
+ * Get a client configuration
64
+ * @param {GetClientConfigurationParams} params containing information to get a client configuration
65
+ * - filters.clientId: The client id
66
+ */
67
+ getClientConfiguration(params: GetClientConfigurationParams): Promise<ClientConfiguration>;
68
+ /**
69
+ * Create a client configuration
70
+ * @param {CreateClientConfigurationParams} params containing information to create a client configuration
71
+ * - clientId: The client id
72
+ * - movementTripThreshold: The movement trip threshold
73
+ * - stopTripThreshold: The stop trip threshold
74
+ * - mapUpdateMode: The map update mode
75
+ * - maxUsersAllowed: The max users allowed
76
+ */
77
+ createClientConfiguration(params: CreateClientConfigurationParams): Promise<ClientConfiguration>;
78
+ /**
79
+ * Update a client configuration
80
+ * @param {UpdateClientConfigurationParams} params containing information to update a client configuration
81
+ * - filters.clientId: The client id
82
+ * - values.movementTripThreshold: The movement trip threshold, optional
83
+ * - values.stopTripThreshold: The stop trip threshold, optional
84
+ * - values.mapUpdateMode: The map update mode, optional
85
+ * - values.maxUsersAllowed: The max users allowed, optional
86
+ * @returns {Promise<boolean>} True if the client configuration was updated, false otherwise
87
+ */
88
+ updateClientConfiguration(params: UpdateClientConfigurationParams): Promise<boolean>;
89
+ }
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateClientParams } from '../../types/clients';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateClient: (novaDataSource: NovaDataSource, params: UpdateClientParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateClientConfigurationParams } from '../../types/clients';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateClientConfiguration: (novaDataSource: NovaDataSource, params: UpdateClientConfigurationParams, logger: Logger) => Promise<boolean>;
@@ -1,4 +1,5 @@
1
1
  import { BoundariesRepository } from './boundaries';
2
+ import { ClientsRepository } from './clients';
2
3
  import { DevicesRepository } from './devices';
3
4
  import { SecurityRepository } from './security';
4
- export { SecurityRepository, DevicesRepository, BoundariesRepository };
5
+ export { SecurityRepository, DevicesRepository, BoundariesRepository, ClientsRepository };
@@ -0,0 +1,5 @@
1
+ import { User } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { Logger } from '../../types/logger';
4
+ import { GetUsersConfigurationByImeiParams } from '../../types/user';
5
+ export declare const getUsersConfigurationByImei: (novaDataSource: NovaDataSource, params: GetUsersConfigurationByImeiParams, logger: Logger) => Promise<User[]>;
@@ -0,0 +1,11 @@
1
+ import { User } from '../../entities/user';
2
+ import { GetUsersConfigurationByImeiParams } from '../../types/user';
3
+ import { BaseRepository } from '../baseRepository';
4
+ export declare class UserRepository extends BaseRepository {
5
+ /**
6
+ * Get user data by imei
7
+ * @param {GetUsersConfigurationByImeiParams} params containing information to get a device by imei
8
+ * - filters.imei: The imei of the device
9
+ */
10
+ getUsersConfigurationByImei(params: GetUsersConfigurationByImeiParams): Promise<User[]>;
11
+ }
@@ -0,0 +1,75 @@
1
+ import { HapnClientType } from './enums';
2
+ export interface GetClientParams {
3
+ filters: {
4
+ clientId?: number;
5
+ email?: string;
6
+ appClientId?: string;
7
+ };
8
+ }
9
+ export interface CreateClientParams {
10
+ name: string;
11
+ uuid: string;
12
+ email: string;
13
+ appClientId?: string;
14
+ clientTypeId?: HapnClientType;
15
+ dataSourceTypeId?: number;
16
+ sievaUserName?: string;
17
+ sievaBatchId?: number;
18
+ salesforceId?: string;
19
+ accumaticaId?: string;
20
+ expirationDate?: Date;
21
+ useType?: string;
22
+ btCustomerId?: string;
23
+ activationCampaign?: string;
24
+ organizationId?: number;
25
+ }
26
+ export interface UpdateClientParams {
27
+ filters: {
28
+ clientId: number;
29
+ };
30
+ values: {
31
+ name?: string;
32
+ uuid?: string;
33
+ email?: string;
34
+ appClientId?: string;
35
+ clientTypeId?: HapnClientType;
36
+ dataSourceTypeId?: number;
37
+ sievaUserName?: string;
38
+ sievaBatchId?: number;
39
+ salesforceId?: string;
40
+ accumaticaId?: string;
41
+ expirationDate?: Date;
42
+ useType?: string;
43
+ btCustomerId?: string;
44
+ activationCampaign?: string;
45
+ organizationId?: number;
46
+ };
47
+ }
48
+ export interface DeleteClientParams {
49
+ filters: {
50
+ clientId: number;
51
+ };
52
+ }
53
+ export interface GetClientConfigurationParams {
54
+ filters: {
55
+ clientId: number;
56
+ };
57
+ }
58
+ export interface CreateClientConfigurationParams {
59
+ clientId: number;
60
+ movementTripThreshold?: number;
61
+ stopTripThreshold?: number;
62
+ mapUpdateMode?: number;
63
+ maxUsersAllowed?: number;
64
+ }
65
+ export interface UpdateClientConfigurationParams {
66
+ filters: {
67
+ clientId: number;
68
+ };
69
+ values: {
70
+ movementTripThreshold?: number;
71
+ stopTripThreshold?: number;
72
+ mapUpdateMode?: number;
73
+ maxUsersAllowed?: number;
74
+ };
75
+ }
@@ -12,3 +12,8 @@ export declare enum BoundaryStatus {
12
12
  Inactive = 2,
13
13
  Deleted = 3
14
14
  }
15
+ export declare enum HapnClientType {
16
+ b2c = 1,
17
+ b2b = 2,
18
+ test = 3
19
+ }
@@ -1,5 +1,6 @@
1
1
  import * as Boundaries from './boundaries';
2
+ import * as Clients from './clients';
2
3
  import * as Devices from './devices';
3
4
  import * as Logger from './logger';
4
5
  import * as Security from './security';
5
- export { Logger, Devices, Security, Boundaries };
6
+ export { Logger, Devices, Security, Boundaries, Clients };
@@ -0,0 +1,5 @@
1
+ export interface GetUsersConfigurationByImeiParams {
2
+ filters: {
3
+ imei: string;
4
+ };
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",