@spytecgps/nova-orm 1.0.7 → 1.0.9

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,5 @@
1
1
  import { Enums } from '../..';
2
- import { Billing, BillingSubscriptionBraintree, Client, Device, IccidStatus, ImeiIccidCarrier, } from '../../entities';
2
+ import { Billing, BillingSubscriptionBraintree, Client, CustomerAttribute, Device, IccidStatus, ImeiIccidCarrier, } from '../../entities';
3
3
  export const getCanceledImeis = async (novaDataSource, params, logger) => {
4
4
  if (!params?.filters?.minCancellationDate ||
5
5
  !params?.filters?.maxCancellationDate ||
@@ -17,6 +17,7 @@ export const getCanceledImeis = async (novaDataSource, params, logger) => {
17
17
  .innerJoin(ImeiIccidCarrier, 'imeiIccidCarrier', 'imeiIccidCarrier.imei = billing.imei')
18
18
  .innerJoin(Device, 'device', 'device.imei = billing.imei')
19
19
  .innerJoin(Client, 'client', 'client.id = device.clientId')
20
+ .leftJoin(CustomerAttribute, 'customerAttribute', 'client.id = customerAttribute.clientId')
20
21
  .innerJoin(IccidStatus, 'iccidStatus', 'iccidStatus.iccid = imeiIccidCarrier.iccid')
21
22
  .where(`iccidStatus.processing = :processing`, {
22
23
  processing: false,
@@ -55,8 +56,8 @@ export const getCanceledImeis = async (novaDataSource, params, logger) => {
55
56
  }
56
57
  }
57
58
  if (params.filters.excludeB2B) {
58
- queryBuilder = queryBuilder.andWhere(`client.clientTypeId != :b2bClientTypeId`, {
59
- b2bClientTypeId: Enums.HapnClientType.b2b,
59
+ queryBuilder = queryBuilder.andWhere(`(customerAttribute.enterprise is null OR customerAttribute.enterprise = :enterprise)`, {
60
+ enterprise: false,
60
61
  });
61
62
  }
62
63
  if (params.filters.excludeTest) {
@@ -77,8 +78,12 @@ export const getCanceledImeis = async (novaDataSource, params, logger) => {
77
78
  'billingSubscriptionBraintree.updatedAt as updatedAt',
78
79
  'billingSubscriptionBraintree.status as status',
79
80
  'imeiIccidCarrier.carrier as carrier',
81
+ 'customerAttribute.enterprise as isEnterpriseCustomer',
80
82
  ])
81
83
  .getRawMany();
82
- return result;
84
+ return result.map(row => ({
85
+ ...row,
86
+ isEnterpriseCustomer: row.isEnterpriseCustomer === 1,
87
+ }));
83
88
  }, 'BillingRepository::getCanceledImeis');
84
89
  };
@@ -27,7 +27,7 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
27
27
  }
28
28
  }
29
29
  const excludeB2bCondition = params.filters.excludeB2B
30
- ? `AND client.clientTypeId != ${Enums.HapnClientType.b2b} `
30
+ ? `AND customerAttribute.enterprise != true `
31
31
  : '';
32
32
  const excludeTestCondition = params.filters.excludeTest
33
33
  ? `AND client.clientTypeId != ${Enums.HapnClientType.test} `
@@ -42,7 +42,8 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
42
42
  billingSubscriptionBraintree.createdAt,
43
43
  billingSubscriptionBraintree.updatedAt,
44
44
  billingSubscriptionBraintree.status,
45
- imeiIccidCarrier.carrier
45
+ imeiIccidCarrier.carrier,
46
+ customerAttribute.enterprise as isEnterpriseCustomer
46
47
  FROM
47
48
  billing
48
49
  INNER JOIN
@@ -53,6 +54,8 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
53
54
  device ON device.imei = billing.imei
54
55
  INNER JOIN
55
56
  client ON client.id = device.clientId
57
+ LEFT JOIN
58
+ customerAttribute ON customerAttribute.clientId = client.id
56
59
  INNER JOIN
57
60
  iccidStatus ON iccidStatus.iccid = imeiIccidCarrier.iccid
58
61
  WHERE
@@ -95,6 +98,7 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
95
98
  updatedAt: item.updatedAt,
96
99
  status: item.status,
97
100
  carrier: item.carrier,
101
+ isEnterpriseCustomer: item.isEnterpriseCustomer === 1,
98
102
  }));
99
103
  }, 'BillingRepository::getCanceledImeisMatchingMagentoData');
100
104
  };
@@ -11,7 +11,10 @@ export const updateDevicePairing = async (novaDataSource, params, logger) => {
11
11
  !params?.values?.btmacMain &&
12
12
  !params?.values?.btmacSecondary &&
13
13
  !params?.values?.connectionType &&
14
- !params?.values?.pairingMode) {
14
+ !params?.values?.pairingMode &&
15
+ !params?.values?.mainDeviceStatus &&
16
+ !params?.values?.secondaryDeviceStatus &&
17
+ !params?.values?.notes) {
15
18
  logger.warn({ params }, 'DevicePairingsRepository::updateDevicePairing missing required parameters');
16
19
  return false;
17
20
  }
@@ -173,6 +173,7 @@ export interface CanceledImeiResult {
173
173
  updatedAt: string;
174
174
  status: string;
175
175
  carrier: string;
176
+ isEnterpriseCustomer: boolean;
176
177
  }
177
178
  export interface GetMagentoPlanParams {
178
179
  filters: {
@@ -6,6 +6,9 @@ export interface CreateDevicePairingParams {
6
6
  btmacSecondary: string;
7
7
  pairingMode?: string | null;
8
8
  connectionType?: string | null;
9
+ mainDeviceStatus?: string | null;
10
+ secondaryDeviceStatus?: string | null;
11
+ notes?: string | null;
9
12
  }
10
13
  export interface GetDevicePairingsParams {
11
14
  filters: {
@@ -31,6 +34,9 @@ export interface UpdateDevicePairingParams {
31
34
  btmacSecondary?: string;
32
35
  pairingMode?: string;
33
36
  connectionType?: string;
37
+ mainDeviceStatus?: string | null;
38
+ secondaryDeviceStatus?: string | null;
39
+ notes?: string | null;
34
40
  };
35
41
  }
36
42
  export interface DeleteDevicePairingParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,21 +0,0 @@
1
- export declare class SVRPairingRequest {
2
- id: number;
3
- mainDeviceName: string;
4
- imeiMain: string;
5
- btmacMain: string;
6
- imeiGhost: string;
7
- btmacGhost: string;
8
- ghostConfigured: boolean;
9
- ghostAlreadyReported: boolean;
10
- mainDeviceWithCorrectBBFW: boolean;
11
- mainDeviceWithCorrectMCUFW: boolean;
12
- ghostDeviceWithCorrectBBFW: boolean;
13
- ghostDeviceWithCorrectMCUFW: boolean;
14
- mainDevicePairCommandsQueued: boolean;
15
- mainDevicePairCommandsConfirmed: boolean;
16
- readyToPair: boolean;
17
- installationOK: boolean;
18
- installationFailed: boolean;
19
- pairingLost: boolean;
20
- notes: string;
21
- }
@@ -1,174 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
11
- import { BoolToNumberTransformer } from '../utils/boolToNumberTransformer';
12
- let SVRPairingRequest = class SVRPairingRequest {
13
- id;
14
- mainDeviceName;
15
- imeiMain;
16
- btmacMain;
17
- imeiGhost;
18
- btmacGhost;
19
- ghostConfigured;
20
- ghostAlreadyReported;
21
- mainDeviceWithCorrectBBFW;
22
- mainDeviceWithCorrectMCUFW;
23
- ghostDeviceWithCorrectBBFW;
24
- ghostDeviceWithCorrectMCUFW;
25
- mainDevicePairCommandsQueued;
26
- mainDevicePairCommandsConfirmed;
27
- readyToPair;
28
- installationOK;
29
- installationFailed;
30
- pairingLost;
31
- notes;
32
- };
33
- __decorate([
34
- PrimaryGeneratedColumn({ type: 'int', name: 'id' }),
35
- __metadata("design:type", Number)
36
- ], SVRPairingRequest.prototype, "id", void 0);
37
- __decorate([
38
- Column('varchar', { name: 'mainDeviceName', length: 30 }),
39
- __metadata("design:type", String)
40
- ], SVRPairingRequest.prototype, "mainDeviceName", void 0);
41
- __decorate([
42
- Column('varchar', { name: 'imeiMain', length: 15 }),
43
- __metadata("design:type", String)
44
- ], SVRPairingRequest.prototype, "imeiMain", void 0);
45
- __decorate([
46
- Column('varchar', { name: 'btmacMain', length: 20 }),
47
- __metadata("design:type", String)
48
- ], SVRPairingRequest.prototype, "btmacMain", void 0);
49
- __decorate([
50
- Column('varchar', { name: 'imeiGhost', length: 15 }),
51
- __metadata("design:type", String)
52
- ], SVRPairingRequest.prototype, "imeiGhost", void 0);
53
- __decorate([
54
- Column('varchar', { name: 'btmacGhost', length: 20 }),
55
- __metadata("design:type", String)
56
- ], SVRPairingRequest.prototype, "btmacGhost", void 0);
57
- __decorate([
58
- Column('tinyint', {
59
- name: 'ghostConfigured',
60
- width: 1,
61
- default: 0,
62
- transformer: new BoolToNumberTransformer(),
63
- }),
64
- __metadata("design:type", Boolean)
65
- ], SVRPairingRequest.prototype, "ghostConfigured", void 0);
66
- __decorate([
67
- Column('tinyint', {
68
- name: 'ghostAlreadyReported',
69
- width: 1,
70
- default: 0,
71
- transformer: new BoolToNumberTransformer(),
72
- }),
73
- __metadata("design:type", Boolean)
74
- ], SVRPairingRequest.prototype, "ghostAlreadyReported", void 0);
75
- __decorate([
76
- Column('tinyint', {
77
- name: 'mainDeviceWithCorrectBBFW',
78
- width: 1,
79
- default: 0,
80
- transformer: new BoolToNumberTransformer(),
81
- }),
82
- __metadata("design:type", Boolean)
83
- ], SVRPairingRequest.prototype, "mainDeviceWithCorrectBBFW", void 0);
84
- __decorate([
85
- Column('tinyint', {
86
- name: 'mainDeviceWithCorrectMCUFW',
87
- width: 1,
88
- default: 0,
89
- transformer: new BoolToNumberTransformer(),
90
- }),
91
- __metadata("design:type", Boolean)
92
- ], SVRPairingRequest.prototype, "mainDeviceWithCorrectMCUFW", void 0);
93
- __decorate([
94
- Column('tinyint', {
95
- name: 'ghostDeviceWithCorrectBBFW',
96
- width: 1,
97
- default: 0,
98
- transformer: new BoolToNumberTransformer(),
99
- }),
100
- __metadata("design:type", Boolean)
101
- ], SVRPairingRequest.prototype, "ghostDeviceWithCorrectBBFW", void 0);
102
- __decorate([
103
- Column('tinyint', {
104
- name: 'ghostDeviceWithCorrectMCUFW',
105
- width: 1,
106
- default: 0,
107
- transformer: new BoolToNumberTransformer(),
108
- }),
109
- __metadata("design:type", Boolean)
110
- ], SVRPairingRequest.prototype, "ghostDeviceWithCorrectMCUFW", void 0);
111
- __decorate([
112
- Column('tinyint', {
113
- name: 'mainDevicePairCommandsQueued',
114
- width: 1,
115
- default: 0,
116
- transformer: new BoolToNumberTransformer(),
117
- }),
118
- __metadata("design:type", Boolean)
119
- ], SVRPairingRequest.prototype, "mainDevicePairCommandsQueued", void 0);
120
- __decorate([
121
- Column('tinyint', {
122
- name: 'mainDevicePairCommandsConfirmed',
123
- width: 1,
124
- default: 0,
125
- transformer: new BoolToNumberTransformer(),
126
- }),
127
- __metadata("design:type", Boolean)
128
- ], SVRPairingRequest.prototype, "mainDevicePairCommandsConfirmed", void 0);
129
- __decorate([
130
- Column('tinyint', {
131
- name: 'readyToPair',
132
- width: 1,
133
- default: 0,
134
- transformer: new BoolToNumberTransformer(),
135
- }),
136
- __metadata("design:type", Boolean)
137
- ], SVRPairingRequest.prototype, "readyToPair", void 0);
138
- __decorate([
139
- Column('tinyint', {
140
- name: 'installationOK',
141
- width: 1,
142
- default: 0,
143
- transformer: new BoolToNumberTransformer(),
144
- }),
145
- __metadata("design:type", Boolean)
146
- ], SVRPairingRequest.prototype, "installationOK", void 0);
147
- __decorate([
148
- Column('tinyint', {
149
- name: 'installationFailed',
150
- width: 1,
151
- default: 0,
152
- transformer: new BoolToNumberTransformer(),
153
- }),
154
- __metadata("design:type", Boolean)
155
- ], SVRPairingRequest.prototype, "installationFailed", void 0);
156
- __decorate([
157
- Column('tinyint', {
158
- name: 'pairingLost',
159
- width: 1,
160
- default: 0,
161
- transformer: new BoolToNumberTransformer(),
162
- }),
163
- __metadata("design:type", Boolean)
164
- ], SVRPairingRequest.prototype, "pairingLost", void 0);
165
- __decorate([
166
- Column('varchar', { name: 'notes', nullable: true, length: 1000 }),
167
- __metadata("design:type", String)
168
- ], SVRPairingRequest.prototype, "notes", void 0);
169
- SVRPairingRequest = __decorate([
170
- Index('ixSVRPairingRequestImeiGhost', ['imeiGhost'], {}),
171
- Index('ixSVRPairingRequestImeiMain', ['imeiMain'], {}),
172
- Entity('svrPairingRequest', { schema: 'nova' })
173
- ], SVRPairingRequest);
174
- export { SVRPairingRequest };