@spytecgps/nova-orm 0.0.19 → 0.0.20

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,87 @@
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
+ * - clientTypeId: client type id, optional
19
+ * - dataSourceTypeId: data source type id, optional
20
+ * - sievaUserName: sieva user name, optional
21
+ * - sievaBatchId: sieva batch id, optional
22
+ * - salesforceId: salesforce id, optional
23
+ * - accumaticaId: accumatica id, optional
24
+ * - expirationDate: expiration date, optional
25
+ * - useType: use type, optional
26
+ * - btCustomerId: bt customer id, optional
27
+ * - activationCampaign: activation campaign, optional
28
+ * - organizationId: organization id, optional
29
+ * @returns {Promise<Client>} The created client
30
+ */
31
+ createClient(params: CreateClientParams): Promise<Client>;
32
+ /**
33
+ * Create client
34
+ * @param {UpdateClientParams} params containing information to update a client
35
+ * - filters.clientId: The id of the client to update
36
+ * - values.name: client name, optional
37
+ * - values.email: client email, optional
38
+ * - values.uuid: client uuid, optional
39
+ * - values.clientTypeId: client type id, optional
40
+ * - values.dataSourceTypeId: data source type id, optional
41
+ * - values.sievaUserName: sieva user name, optional
42
+ * - values.sievaBatchId: sieva batch id, optional
43
+ * - values.salesforceId: salesforce id, optional
44
+ * - values.accumaticaId: accumatica id, optional
45
+ * - values.expirationDate: expiration date, optional
46
+ * - values.useType: use type, optional
47
+ * - values.btCustomerId: bt customer id, optional
48
+ * - values.activationCampaign: activation campaign, optional
49
+ * - values.organizationId: organization id, optional
50
+ * @returns {Promise<boolean>} True if the client was updated, false otherwise
51
+ */
52
+ updateClient(params: UpdateClientParams): Promise<boolean>;
53
+ /**
54
+ * Delete a client and its configurations
55
+ * @param {DeleteClientParams} params containing information to delete a client
56
+ * - filters.clientId: The id of the client to delete
57
+ * @returns {Promise<boolean>} True if the client was deleted, false otherwise
58
+ */
59
+ deleteClientAndConfigurations(params: DeleteClientParams): Promise<boolean>;
60
+ /**
61
+ * Get a client configuration
62
+ * @param {GetClientConfigurationParams} params containing information to get a client configuration
63
+ * - filters.clientId: The client id
64
+ */
65
+ getClientConfiguration(params: GetClientConfigurationParams): Promise<ClientConfiguration>;
66
+ /**
67
+ * Create a client configuration
68
+ * @param {CreateClientConfigurationParams} params containing information to create a client configuration
69
+ * - clientId: The client id
70
+ * - movementTripThreshold: The movement trip threshold
71
+ * - stopTripThreshold: The stop trip threshold
72
+ * - mapUpdateMode: The map update mode
73
+ * - maxUsersAllowed: The max users allowed
74
+ */
75
+ createClientConfiguration(params: CreateClientConfigurationParams): Promise<ClientConfiguration>;
76
+ /**
77
+ * Update a client configuration
78
+ * @param {UpdateClientConfigurationParams} params containing information to update a client configuration
79
+ * - filters.clientId: The client id
80
+ * - values.movementTripThreshold: The movement trip threshold, optional
81
+ * - values.stopTripThreshold: The stop trip threshold, optional
82
+ * - values.mapUpdateMode: The map update mode, optional
83
+ * - values.maxUsersAllowed: The max users allowed, optional
84
+ * @returns {Promise<boolean>} True if the client configuration was updated, false otherwise
85
+ */
86
+ updateClientConfiguration(params: UpdateClientConfigurationParams): Promise<boolean>;
87
+ }
@@ -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,72 @@
1
+ import { HapnClientType } from './enums';
2
+ export interface GetClientParams {
3
+ filters: {
4
+ clientId?: number;
5
+ email?: string;
6
+ };
7
+ }
8
+ export interface CreateClientParams {
9
+ name: string;
10
+ uuid: string;
11
+ email: string;
12
+ clientTypeId?: HapnClientType;
13
+ dataSourceTypeId?: number;
14
+ sievaUserName?: string;
15
+ sievaBatchId?: number;
16
+ salesforceId?: string;
17
+ accumaticaId?: string;
18
+ expirationDate?: Date;
19
+ useType?: string;
20
+ btCustomerId?: string;
21
+ activationCampaign?: string;
22
+ organizationId?: number;
23
+ }
24
+ export interface UpdateClientParams {
25
+ filters: {
26
+ clientId: number;
27
+ };
28
+ values: {
29
+ name?: string;
30
+ uuid?: string;
31
+ email?: string;
32
+ clientTypeId?: HapnClientType;
33
+ dataSourceTypeId?: number;
34
+ sievaUserName?: string;
35
+ sievaBatchId?: number;
36
+ salesforceId?: string;
37
+ accumaticaId?: string;
38
+ expirationDate?: Date;
39
+ useType?: string;
40
+ btCustomerId?: string;
41
+ activationCampaign?: string;
42
+ organizationId?: number;
43
+ };
44
+ }
45
+ export interface DeleteClientParams {
46
+ filters: {
47
+ clientId: number;
48
+ };
49
+ }
50
+ export interface GetClientConfigurationParams {
51
+ filters: {
52
+ clientId: number;
53
+ };
54
+ }
55
+ export interface CreateClientConfigurationParams {
56
+ clientId: number;
57
+ movementTripThreshold?: number;
58
+ stopTripThreshold?: number;
59
+ mapUpdateMode?: number;
60
+ maxUsersAllowed?: number;
61
+ }
62
+ export interface UpdateClientConfigurationParams {
63
+ filters: {
64
+ clientId: number;
65
+ };
66
+ values: {
67
+ movementTripThreshold?: number;
68
+ stopTripThreshold?: number;
69
+ mapUpdateMode?: number;
70
+ maxUsersAllowed?: number;
71
+ };
72
+ }
@@ -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 };
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.20",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",