@dascompany/database 1.0.2 → 2.1.0
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.
- package/dist/ConnectionFactory.d.ts +14 -0
- package/dist/ConnectionFactory.js +47 -0
- package/dist/index.d.ts +5 -79
- package/dist/index.js +4 -64
- package/dist/query/QueryOptions.d.ts +1 -1
- package/dist/types/QueryOptionsI.d.ts +1 -1
- package/package.json +1 -1
- package/dist/DatabaseConnection.d.ts +0 -11
- package/dist/DatabaseConnection.js +0 -28
- package/dist/SQL.json +0 -162
- package/dist/TableConnection.d.ts +0 -74
- package/dist/TableConnection.js +0 -144
- package/dist/mappers/AddressMapper.d.ts +0 -9
- package/dist/mappers/AddressMapper.js +0 -17
- package/dist/mappers/ClientMapper.d.ts +0 -9
- package/dist/mappers/ClientMapper.js +0 -24
- package/dist/mappers/CompanyDataMapper.d.ts +0 -9
- package/dist/mappers/CompanyDataMapper.js +0 -17
- package/dist/mappers/CompanyDetailsMapper.d.ts +0 -9
- package/dist/mappers/CompanyDetailsMapper.js +0 -22
- package/dist/mappers/ContactDetailsMapper.d.ts +0 -9
- package/dist/mappers/ContactDetailsMapper.js +0 -18
- package/dist/mappers/DeliveryDetailsMapper.d.ts +0 -9
- package/dist/mappers/DeliveryDetailsMapper.js +0 -17
- package/dist/mappers/DeliveryMethodsMapper.d.ts +0 -9
- package/dist/mappers/DeliveryMethodsMapper.js +0 -17
- package/dist/mappers/DeliveryStatusMapper.d.ts +0 -9
- package/dist/mappers/DeliveryStatusMapper.js +0 -15
- package/dist/mappers/FileConnectionMapper.d.ts +0 -9
- package/dist/mappers/FileConnectionMapper.js +0 -17
- package/dist/mappers/FileMapper.d.ts +0 -9
- package/dist/mappers/FileMapper.js +0 -17
- package/dist/mappers/InvoiceDetailsMapper.d.ts +0 -9
- package/dist/mappers/InvoiceDetailsMapper.js +0 -17
- package/dist/mappers/OrderMapper.d.ts +0 -9
- package/dist/mappers/OrderMapper.js +0 -19
- package/dist/mappers/OrderProductMapper.d.ts +0 -9
- package/dist/mappers/OrderProductMapper.js +0 -15
- package/dist/mappers/PaymentDetailsMapper.d.ts +0 -9
- package/dist/mappers/PaymentDetailsMapper.js +0 -17
- package/dist/mappers/PaymentMethodsMapper.d.ts +0 -9
- package/dist/mappers/PaymentMethodsMapper.js +0 -17
- package/dist/mappers/PaymentStatusMapper.d.ts +0 -9
- package/dist/mappers/PaymentStatusMapper.js +0 -15
- package/dist/mappers/PersonalDataMapper.d.ts +0 -9
- package/dist/mappers/PersonalDataMapper.js +0 -17
- package/dist/mappers/ProductMapper.d.ts +0 -9
- package/dist/mappers/ProductMapper.js +0 -20
- package/dist/mappers/StatusMapper.d.ts +0 -9
- package/dist/mappers/StatusMapper.js +0 -15
- package/dist/reader/AddressesReader.d.ts +0 -6
- package/dist/reader/AddressesReader.js +0 -24
- package/dist/reader/ClientAccountReader.d.ts +0 -13
- package/dist/reader/ClientAccountReader.js +0 -47
- package/dist/reader/CompanyDataReader.d.ts +0 -4
- package/dist/reader/CompanyDataReader.js +0 -27
- package/dist/reader/CompanyDetailsReader.d.ts +0 -4
- package/dist/reader/CompanyDetailsReader.js +0 -15
- package/dist/reader/ContactDetailsReader.d.ts +0 -4
- package/dist/reader/ContactDetailsReader.js +0 -16
- package/dist/reader/DeliveryDetailsReader.d.ts +0 -4
- package/dist/reader/DeliveryDetailsReader.js +0 -26
- package/dist/reader/DeliveryMethodReader.d.ts +0 -6
- package/dist/reader/DeliveryMethodReader.js +0 -18
- package/dist/reader/DeliveryStatusReader.d.ts +0 -5
- package/dist/reader/DeliveryStatusReader.js +0 -31
- package/dist/reader/FileConnectionsReader.d.ts +0 -6
- package/dist/reader/FileConnectionsReader.js +0 -25
- package/dist/reader/FilesReader.d.ts +0 -12
- package/dist/reader/FilesReader.js +0 -46
- package/dist/reader/InvoiceDetailsReader.d.ts +0 -4
- package/dist/reader/InvoiceDetailsReader.js +0 -21
- package/dist/reader/OrderProductsReader.d.ts +0 -7
- package/dist/reader/OrderProductsReader.js +0 -51
- package/dist/reader/OrderReader.d.ts +0 -12
- package/dist/reader/OrderReader.js +0 -53
- package/dist/reader/OrderStatusReader.d.ts +0 -6
- package/dist/reader/OrderStatusReader.js +0 -29
- package/dist/reader/PersonalDataReader.d.ts +0 -5
- package/dist/reader/PersonalDataReader.js +0 -27
- package/dist/reader/ProductReader.d.ts +0 -11
- package/dist/reader/ProductReader.js +0 -62
- package/dist/reader/StatusTypesReader.d.ts +0 -3
- package/dist/reader/StatusTypesReader.js +0 -8
- package/dist/reader/payment/PaymentDetailsReader.d.ts +0 -5
- package/dist/reader/payment/PaymentDetailsReader.js +0 -27
- package/dist/reader/payment/PaymentMethodReader.d.ts +0 -6
- package/dist/reader/payment/PaymentMethodReader.js +0 -18
- package/dist/reader/payment/PaymentStatusesReader.d.ts +0 -5
- package/dist/reader/payment/PaymentStatusesReader.js +0 -30
- package/dist/repo/AddressesRepo.d.ts +0 -5
- package/dist/repo/AddressesRepo.js +0 -14
- package/dist/repo/ClientAccountRepo.d.ts +0 -7
- package/dist/repo/ClientAccountRepo.js +0 -24
- package/dist/repo/CompanyDataRepo.d.ts +0 -4
- package/dist/repo/CompanyDataRepo.js +0 -11
- package/dist/repo/CompanyDetailsRepo.d.ts +0 -5
- package/dist/repo/CompanyDetailsRepo.js +0 -14
- package/dist/repo/ContactDetailsRepo.d.ts +0 -6
- package/dist/repo/ContactDetailsRepo.js +0 -19
- package/dist/repo/DeliveryDetailsRepo.d.ts +0 -5
- package/dist/repo/DeliveryDetailsRepo.js +0 -14
- package/dist/repo/DeliveryMethodRepo.d.ts +0 -4
- package/dist/repo/DeliveryMethodRepo.js +0 -11
- package/dist/repo/FileConnectionsRepo.d.ts +0 -7
- package/dist/repo/FileConnectionsRepo.js +0 -25
- package/dist/repo/FilesRepo.d.ts +0 -7
- package/dist/repo/FilesRepo.js +0 -26
- package/dist/repo/InvoiceDetailsRepo.d.ts +0 -5
- package/dist/repo/InvoiceDetailsRepo.js +0 -14
- package/dist/repo/OrderProductsRepo.d.ts +0 -7
- package/dist/repo/OrderProductsRepo.js +0 -37
- package/dist/repo/OrderRepo.d.ts +0 -5
- package/dist/repo/OrderRepo.js +0 -14
- package/dist/repo/OrderStatusRepo.d.ts +0 -7
- package/dist/repo/OrderStatusRepo.js +0 -27
- package/dist/repo/PaymentDetailsRepo.d.ts +0 -5
- package/dist/repo/PaymentDetailsRepo.js +0 -14
- package/dist/repo/PaymentMethodRepo.d.ts +0 -4
- package/dist/repo/PaymentMethodRepo.js +0 -11
- package/dist/repo/PersonalDataRepo.d.ts +0 -5
- package/dist/repo/PersonalDataRepo.js +0 -16
- package/dist/repo/ProductRepo.d.ts +0 -6
- package/dist/repo/ProductRepo.js +0 -20
- package/dist/stockObjects/Address.d.ts +0 -33
- package/dist/stockObjects/Address.js +0 -69
- package/dist/stockObjects/Client.d.ts +0 -24
- package/dist/stockObjects/Client.js +0 -57
- package/dist/stockObjects/CompanyData.d.ts +0 -21
- package/dist/stockObjects/CompanyData.js +0 -51
- package/dist/stockObjects/CompanyDetails.d.ts +0 -17
- package/dist/stockObjects/CompanyDetails.js +0 -34
- package/dist/stockObjects/ContactDetails.d.ts +0 -12
- package/dist/stockObjects/ContactDetails.js +0 -26
- package/dist/stockObjects/DeliveryDetails.d.ts +0 -16
- package/dist/stockObjects/DeliveryDetails.js +0 -37
- package/dist/stockObjects/DeliveryMethods.d.ts +0 -12
- package/dist/stockObjects/DeliveryMethods.js +0 -26
- package/dist/stockObjects/DeliveryStatus.d.ts +0 -18
- package/dist/stockObjects/DeliveryStatus.js +0 -42
- package/dist/stockObjects/File.d.ts +0 -21
- package/dist/stockObjects/File.js +0 -50
- package/dist/stockObjects/FileConnection.d.ts +0 -18
- package/dist/stockObjects/FileConnection.js +0 -42
- package/dist/stockObjects/InvoiceDetails.d.ts +0 -12
- package/dist/stockObjects/InvoiceDetails.js +0 -26
- package/dist/stockObjects/Order.d.ts +0 -41
- package/dist/stockObjects/Order.js +0 -102
- package/dist/stockObjects/OrderProduct.d.ts +0 -15
- package/dist/stockObjects/OrderProduct.js +0 -33
- package/dist/stockObjects/PaymentDetails.d.ts +0 -12
- package/dist/stockObjects/PaymentDetails.js +0 -26
- package/dist/stockObjects/PaymentMethods.d.ts +0 -12
- package/dist/stockObjects/PaymentMethods.js +0 -26
- package/dist/stockObjects/PaymentStatus.d.ts +0 -13
- package/dist/stockObjects/PaymentStatus.js +0 -26
- package/dist/stockObjects/PersonalData.d.ts +0 -42
- package/dist/stockObjects/PersonalData.js +0 -81
- package/dist/stockObjects/Product.d.ts +0 -70
- package/dist/stockObjects/Product.js +0 -163
- package/dist/stockObjects/Status.d.ts +0 -23
- package/dist/stockObjects/Status.js +0 -50
- package/dist/tables/clients/ClientAccountsTable.d.ts +0 -17
- package/dist/tables/clients/ClientAccountsTable.js +0 -74
- package/dist/tables/files/FileConnectionsTable.d.ts +0 -12
- package/dist/tables/files/FileConnectionsTable.js +0 -41
- package/dist/tables/files/FilesTable.d.ts +0 -17
- package/dist/tables/files/FilesTable.js +0 -65
- package/dist/tables/orders/OrdersProductsTable.d.ts +0 -12
- package/dist/tables/orders/OrdersProductsTable.js +0 -42
- package/dist/tables/orders/OrdersTable.d.ts +0 -15
- package/dist/tables/orders/OrdersTable.js +0 -60
- package/dist/tables/orders/PaymentDetailsTable.d.ts +0 -10
- package/dist/tables/orders/PaymentDetailsTable.js +0 -34
- package/dist/tables/orders/PaymentStatusTypesTable.d.ts +0 -7
- package/dist/tables/orders/PaymentStatusTypesTable.js +0 -10
- package/dist/tables/orders/PaymentStatusesTable.d.ts +0 -9
- package/dist/tables/orders/PaymentStatusesTable.js +0 -30
- package/dist/tables/orders/StatusTypesTable.d.ts +0 -4
- package/dist/tables/orders/StatusTypesTable.js +0 -9
- package/dist/tables/orders/StatusesTable.d.ts +0 -10
- package/dist/tables/orders/StatusesTable.js +0 -34
- package/dist/tables/personalInformation/AddressesTable.d.ts +0 -10
- package/dist/tables/personalInformation/AddressesTable.js +0 -37
- package/dist/tables/personalInformation/CompanyDetailsTable.d.ts +0 -11
- package/dist/tables/personalInformation/CompanyDetailsTable.js +0 -38
- package/dist/tables/personalInformation/ContactDetailsTable.d.ts +0 -10
- package/dist/tables/personalInformation/ContactDetailsTable.js +0 -34
- package/dist/tables/personalInformation/DeliveryDetailsTable.d.ts +0 -10
- package/dist/tables/personalInformation/DeliveryDetailsTable.js +0 -35
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.d.ts +0 -7
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.js +0 -10
- package/dist/tables/personalInformation/DeliveryStatusesTable.d.ts +0 -9
- package/dist/tables/personalInformation/DeliveryStatusesTable.js +0 -31
- package/dist/tables/personalInformation/InvoiceDetailsTable.d.ts +0 -10
- package/dist/tables/personalInformation/InvoiceDetailsTable.js +0 -34
- package/dist/tables/personalInformation/PersonalDataTable.d.ts +0 -10
- package/dist/tables/personalInformation/PersonalDataTable.js +0 -37
- package/dist/tables/public/AdminAccountsTable.d.ts +0 -13
- package/dist/tables/public/AdminAccountsTable.js +0 -64
- package/dist/tables/public/ProductsTable.d.ts +0 -18
- package/dist/tables/public/ProductsTable.js +0 -89
- package/dist/tables/settings/CompanyDataTable.d.ts +0 -10
- package/dist/tables/settings/CompanyDataTable.js +0 -37
- package/dist/tables/settings/DeliveryMethodsTable.d.ts +0 -12
- package/dist/tables/settings/DeliveryMethodsTable.js +0 -43
- package/dist/tables/settings/PaymentMethodsTable.d.ts +0 -12
- package/dist/tables/settings/PaymentMethodsTable.js +0 -43
- package/dist/types/AddressI.d.ts +0 -9
- package/dist/types/AddressI.js +0 -1
- package/dist/types/ClaimI.d.ts +0 -4
- package/dist/types/ClaimI.js +0 -1
- package/dist/types/ClientAccountI.d.ts +0 -10
- package/dist/types/ClientAccountI.js +0 -1
- package/dist/types/CompanyDataI.d.ts +0 -8
- package/dist/types/CompanyDataI.js +0 -1
- package/dist/types/CompanyDetailsI.d.ts +0 -5
- package/dist/types/CompanyDetailsI.js +0 -1
- package/dist/types/ContactDetailsI.d.ts +0 -7
- package/dist/types/ContactDetailsI.js +0 -1
- package/dist/types/DeliveryDetailsI.d.ts +0 -9
- package/dist/types/DeliveryDetailsI.js +0 -1
- package/dist/types/DeliveryMethodI.d.ts +0 -5
- package/dist/types/DeliveryMethodI.js +0 -1
- package/dist/types/FileConnectionI.d.ts +0 -6
- package/dist/types/FileConnectionI.js +0 -1
- package/dist/types/FileConnectionTypeE.d.ts +0 -4
- package/dist/types/FileConnectionTypeE.js +0 -5
- package/dist/types/FileI.d.ts +0 -6
- package/dist/types/FileI.js +0 -1
- package/dist/types/InvoiceDetailsI.d.ts +0 -7
- package/dist/types/InvoiceDetailsI.js +0 -1
- package/dist/types/OrderI.d.ts +0 -12
- package/dist/types/OrderI.js +0 -1
- package/dist/types/OrderProductI.d.ts +0 -14
- package/dist/types/OrderProductI.js +0 -1
- package/dist/types/PaymentDetailsI.d.ts +0 -6
- package/dist/types/PaymentDetailsI.js +0 -1
- package/dist/types/PaymentMethodE.d.ts +0 -5
- package/dist/types/PaymentMethodE.js +0 -6
- package/dist/types/PaymentMethodI.d.ts +0 -5
- package/dist/types/PaymentMethodI.js +0 -1
- package/dist/types/PaymentStatusE.d.ts +0 -6
- package/dist/types/PaymentStatusE.js +0 -7
- package/dist/types/PersonalDataI.d.ts +0 -10
- package/dist/types/PersonalDataI.js +0 -1
- package/dist/types/ProductI.d.ts +0 -20
- package/dist/types/ProductI.js +0 -1
- package/dist/types/StatusI.d.ts +0 -7
- package/dist/types/StatusI.js +0 -1
- package/dist/types/rows/AddressRow.d.ts +0 -9
- package/dist/types/rows/AddressRow.js +0 -1
- package/dist/types/rows/ClientAccountRow.d.ts +0 -10
- package/dist/types/rows/ClientAccountRow.js +0 -1
- package/dist/types/rows/CompanyDataRow.d.ts +0 -8
- package/dist/types/rows/CompanyDataRow.js +0 -1
- package/dist/types/rows/CompanyDetailsRow.d.ts +0 -5
- package/dist/types/rows/CompanyDetailsRow.js +0 -1
- package/dist/types/rows/ContactDetailsRow.d.ts +0 -5
- package/dist/types/rows/ContactDetailsRow.js +0 -1
- package/dist/types/rows/DeliveryDetailsRow.d.ts +0 -6
- package/dist/types/rows/DeliveryDetailsRow.js +0 -1
- package/dist/types/rows/DeliveryMethodRow.d.ts +0 -5
- package/dist/types/rows/DeliveryMethodRow.js +0 -1
- package/dist/types/rows/DeliveryStatusRow.d.ts +0 -7
- package/dist/types/rows/DeliveryStatusRow.js +0 -1
- package/dist/types/rows/FileConnectionRow.d.ts +0 -6
- package/dist/types/rows/FileConnectionRow.js +0 -1
- package/dist/types/rows/FileRow.d.ts +0 -9
- package/dist/types/rows/FileRow.js +0 -1
- package/dist/types/rows/InvoiceDetailsRow.d.ts +0 -5
- package/dist/types/rows/InvoiceDetailsRow.js +0 -1
- package/dist/types/rows/OrderProductRow.d.ts +0 -10
- package/dist/types/rows/OrderProductRow.js +0 -1
- package/dist/types/rows/OrderRow.d.ts +0 -15
- package/dist/types/rows/OrderRow.js +0 -1
- package/dist/types/rows/PaymentDetailsRow.d.ts +0 -6
- package/dist/types/rows/PaymentDetailsRow.js +0 -1
- package/dist/types/rows/PaymentMethodRow.d.ts +0 -5
- package/dist/types/rows/PaymentMethodRow.js +0 -1
- package/dist/types/rows/PaymentStatusRow.d.ts +0 -6
- package/dist/types/rows/PaymentStatusRow.js +0 -1
- package/dist/types/rows/PersonalDataRow.d.ts +0 -8
- package/dist/types/rows/PersonalDataRow.js +0 -1
- package/dist/types/rows/ProductRow.d.ts +0 -17
- package/dist/types/rows/ProductRow.js +0 -1
- package/dist/types/rows/StatusRow.d.ts +0 -8
- package/dist/types/rows/StatusRow.js +0 -1
- package/dist/utils/calculateNetToGrossPrice.d.ts +0 -1
- package/dist/utils/calculateNetToGrossPrice.js +0 -7
- package/dist/utils/correctPhoneNumber.d.ts +0 -1
- package/dist/utils/correctPhoneNumber.js +0 -14
- /package/dist/{utils → types}/OrderByI.d.ts +0 -0
- /package/dist/{utils → types}/OrderByI.js +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class ProductMapper {
|
|
3
|
-
product;
|
|
4
|
-
productTable;
|
|
5
|
-
constructor(product) {
|
|
6
|
-
this.productTable = DatabaseConnection.get().products;
|
|
7
|
-
this.product = product;
|
|
8
|
-
}
|
|
9
|
-
async save() {
|
|
10
|
-
if (this.product.getId() && !this.product.getDeleted())
|
|
11
|
-
await this.productTable.update(this.product);
|
|
12
|
-
else
|
|
13
|
-
await this.productTable.insert(this.product);
|
|
14
|
-
}
|
|
15
|
-
async delete() {
|
|
16
|
-
const id = this.product.getId();
|
|
17
|
-
if (id)
|
|
18
|
-
await this.productTable.delete(id);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Status from "../stockObjects/Status";
|
|
2
|
-
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
-
export default class StatusMapper implements StockObjectMapper {
|
|
4
|
-
private status;
|
|
5
|
-
private statusTable;
|
|
6
|
-
constructor(status: Status);
|
|
7
|
-
save(): Promise<void>;
|
|
8
|
-
delete(): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class StatusMapper {
|
|
3
|
-
status;
|
|
4
|
-
statusTable;
|
|
5
|
-
constructor(status) {
|
|
6
|
-
this.statusTable = DatabaseConnection.get().statuses;
|
|
7
|
-
this.status = status;
|
|
8
|
-
}
|
|
9
|
-
async save() {
|
|
10
|
-
await this.statusTable.insert(this.status);
|
|
11
|
-
}
|
|
12
|
-
async delete() {
|
|
13
|
-
throw Error('method not implemented');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class AddressesReader {
|
|
3
|
-
static async get(addressId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const address = await connection.addresses.select(addressId);
|
|
6
|
-
return this.getCorrectData(address);
|
|
7
|
-
}
|
|
8
|
-
static async getCompanyAddress() {
|
|
9
|
-
const connection = DatabaseConnection.get();
|
|
10
|
-
const address = await connection.addresses.select(1);
|
|
11
|
-
return this.getCorrectData(address);
|
|
12
|
-
}
|
|
13
|
-
static getCorrectData(address) {
|
|
14
|
-
return {
|
|
15
|
-
id: address.id,
|
|
16
|
-
country: address.country,
|
|
17
|
-
city: address.city,
|
|
18
|
-
postalCode: address.postal_code,
|
|
19
|
-
street: address.street,
|
|
20
|
-
houseNumber: address.house_number,
|
|
21
|
-
apartmentNumber: address.apartment_number,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import QueryOptions from "../query/QueryOptions";
|
|
2
|
-
import ClientAccountI from "../types/ClientAccountI";
|
|
3
|
-
export default class ClientAccountReader {
|
|
4
|
-
static get(accountId: number): Promise<ClientAccountI>;
|
|
5
|
-
static getAll(queryOptions: QueryOptions): Promise<{
|
|
6
|
-
clientAccounts: ClientAccountI[];
|
|
7
|
-
quantity: number;
|
|
8
|
-
}>;
|
|
9
|
-
static getForEmail(email: string): Promise<ClientAccountI>;
|
|
10
|
-
static getIdForEmail(email: string): Promise<number>;
|
|
11
|
-
private static correctClientsFromRows;
|
|
12
|
-
private static correctData;
|
|
13
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class ClientAccountReader {
|
|
3
|
-
static async get(accountId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const account = await connection.accounts.select(accountId);
|
|
6
|
-
return this.correctData(account);
|
|
7
|
-
}
|
|
8
|
-
static async getAll(queryOptions) {
|
|
9
|
-
const connection = DatabaseConnection.get();
|
|
10
|
-
const clientAccounts = await connection.accounts.selectAll(queryOptions);
|
|
11
|
-
const quantity = await connection.accounts.count(queryOptions);
|
|
12
|
-
return {
|
|
13
|
-
clientAccounts: this.correctClientsFromRows(clientAccounts),
|
|
14
|
-
quantity
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
static async getForEmail(email) {
|
|
18
|
-
const connection = DatabaseConnection.get();
|
|
19
|
-
const account = await connection.accounts.selectForEmail(email);
|
|
20
|
-
return this.correctData(account);
|
|
21
|
-
}
|
|
22
|
-
static async getIdForEmail(email) {
|
|
23
|
-
const connection = DatabaseConnection.get();
|
|
24
|
-
const accountId = await connection.accounts.getIdForEmail(email);
|
|
25
|
-
return accountId;
|
|
26
|
-
}
|
|
27
|
-
static correctClientsFromRows(dataRows) {
|
|
28
|
-
const clients = [];
|
|
29
|
-
for (const dataRow of dataRows) {
|
|
30
|
-
const client = this.correctData(dataRow);
|
|
31
|
-
clients.push(client);
|
|
32
|
-
}
|
|
33
|
-
return clients;
|
|
34
|
-
}
|
|
35
|
-
static correctData(client) {
|
|
36
|
-
return {
|
|
37
|
-
id: client.id,
|
|
38
|
-
email: client.email,
|
|
39
|
-
createdAt: client.created_at,
|
|
40
|
-
activated: client.activated,
|
|
41
|
-
deleted: client.deleted,
|
|
42
|
-
contactDetailsId: client.contact_details_id,
|
|
43
|
-
deliveryDetailsId: client.delivery_details_id,
|
|
44
|
-
invoiceDetailsId: client.invoice_details_id,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import AddressesReader from "./AddressesReader";
|
|
3
|
-
export default class CompanyDataReader {
|
|
4
|
-
static async get() {
|
|
5
|
-
const connection = DatabaseConnection.get();
|
|
6
|
-
const companyData = await connection.companyData.select();
|
|
7
|
-
if (companyData) {
|
|
8
|
-
const address = companyData?.address_id ? await AddressesReader.get(companyData.address_id) : null;
|
|
9
|
-
return {
|
|
10
|
-
id: companyData.id,
|
|
11
|
-
name: companyData.name,
|
|
12
|
-
taxNumber: companyData.tax_number,
|
|
13
|
-
phoneNumber: companyData.phone_number,
|
|
14
|
-
address: address
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
return {
|
|
19
|
-
id: 0,
|
|
20
|
-
name: '',
|
|
21
|
-
taxNumber: '',
|
|
22
|
-
phoneNumber: '',
|
|
23
|
-
address: null
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class CompanyDetailsReader {
|
|
3
|
-
static async get(companyDetailsId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const companyDetails = await connection.companyDetails.select(companyDetailsId);
|
|
6
|
-
if (companyDetails)
|
|
7
|
-
return {
|
|
8
|
-
id: companyDetails.id,
|
|
9
|
-
name: companyDetails.name,
|
|
10
|
-
taxNumber: companyDetails.tax_number
|
|
11
|
-
};
|
|
12
|
-
else
|
|
13
|
-
throw Error(`no companyDetails found for id: ${companyDetailsId}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import AddressesReader from "./AddressesReader";
|
|
3
|
-
import PersonalDataReader from "./PersonalDataReader";
|
|
4
|
-
export default class ContactDetailsReader {
|
|
5
|
-
static async get(contactDetailsId) {
|
|
6
|
-
const connection = DatabaseConnection.get();
|
|
7
|
-
const contactDetails = await connection.contactDetails.select(contactDetailsId);
|
|
8
|
-
const personalData = await PersonalDataReader.get(contactDetails.personal_data_id);
|
|
9
|
-
const address = contactDetails.address_id ? await AddressesReader.get(contactDetails.address_id) : null;
|
|
10
|
-
return {
|
|
11
|
-
id: contactDetails.id,
|
|
12
|
-
personalData,
|
|
13
|
-
address
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import AddressesReader from "./AddressesReader";
|
|
3
|
-
import DeliveryMethodReader from "./DeliveryMethodReader";
|
|
4
|
-
import PersonalDataReader from "./PersonalDataReader";
|
|
5
|
-
export default class DeliveryDetailsReader {
|
|
6
|
-
static async get(deliveryDetailsId) {
|
|
7
|
-
const connection = DatabaseConnection.get();
|
|
8
|
-
const deliveryDetails = await connection.deliveryDetails.select(deliveryDetailsId);
|
|
9
|
-
const id = deliveryDetails.id;
|
|
10
|
-
let personalData = null;
|
|
11
|
-
let address = null;
|
|
12
|
-
let deliveryMethod = null;
|
|
13
|
-
if (deliveryDetails.personal_data_id)
|
|
14
|
-
personalData = await PersonalDataReader.get(deliveryDetails.personal_data_id);
|
|
15
|
-
if (deliveryDetails.address_id)
|
|
16
|
-
address = await AddressesReader.get(deliveryDetails.address_id);
|
|
17
|
-
if (deliveryDetails.delivery_method_id)
|
|
18
|
-
deliveryMethod = await DeliveryMethodReader.get(deliveryDetails.delivery_method_id);
|
|
19
|
-
return {
|
|
20
|
-
id,
|
|
21
|
-
personalData,
|
|
22
|
-
address,
|
|
23
|
-
deliveryMethod
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class DeliveryMethodReader {
|
|
3
|
-
static async get(id) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const deliveryMethod = await connection.deliveryMethods.select(id);
|
|
6
|
-
return deliveryMethod;
|
|
7
|
-
}
|
|
8
|
-
static async getAll() {
|
|
9
|
-
const connection = DatabaseConnection.get();
|
|
10
|
-
const deliveryMethods = await connection.deliveryMethods.selectAll();
|
|
11
|
-
return deliveryMethods;
|
|
12
|
-
}
|
|
13
|
-
static async getAllActive() {
|
|
14
|
-
const connection = DatabaseConnection.get();
|
|
15
|
-
const deliveryMethods = await connection.deliveryMethods.selectAllActive();
|
|
16
|
-
return deliveryMethods;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class DeliveryStatusReader {
|
|
3
|
-
static async get(deliveryDetailsId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const deliveryStatus = await connection.deliveryStatuses.select(deliveryDetailsId);
|
|
6
|
-
if (deliveryStatus)
|
|
7
|
-
return await this.correctDeliveryStatus(deliveryStatus);
|
|
8
|
-
else
|
|
9
|
-
return {};
|
|
10
|
-
}
|
|
11
|
-
static async getAll(deliveryDetailsId) {
|
|
12
|
-
const connection = DatabaseConnection.get();
|
|
13
|
-
const deliveryStatusesData = await connection.deliveryStatuses.selectAll(deliveryDetailsId);
|
|
14
|
-
const deliveryStatuses = [];
|
|
15
|
-
for (let i = 0; i < deliveryStatusesData.length; i++) {
|
|
16
|
-
const deliveryStatus = await this.correctDeliveryStatus(deliveryStatusesData[i]);
|
|
17
|
-
deliveryStatuses.push(deliveryStatus);
|
|
18
|
-
}
|
|
19
|
-
return deliveryStatuses;
|
|
20
|
-
}
|
|
21
|
-
static async correctDeliveryStatus(deliveryStatus) {
|
|
22
|
-
const connection = DatabaseConnection.get();
|
|
23
|
-
const deliveryStatusType = await connection.deliveryStatusTypes.select(deliveryStatus.delivery_status_type_id);
|
|
24
|
-
return {
|
|
25
|
-
id: deliveryStatus.id,
|
|
26
|
-
type: deliveryStatusType,
|
|
27
|
-
userId: deliveryStatus.user_id,
|
|
28
|
-
createdAt: deliveryStatus.created_at
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class FileConnectionsReader {
|
|
3
|
-
static async getAllForFileId(fileId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const fileConnections = await connection.fileConnections.selectForFileId(fileId);
|
|
6
|
-
return this.correctFileConnections(fileConnections);
|
|
7
|
-
}
|
|
8
|
-
static correctFileConnections(fileConnectionsRows) {
|
|
9
|
-
const fileConnections = [];
|
|
10
|
-
for (let i = 0; i < fileConnectionsRows.length; i++) {
|
|
11
|
-
const fileConnection = this.correctFileConnection(fileConnectionsRows[i]);
|
|
12
|
-
fileConnections.push(fileConnection);
|
|
13
|
-
}
|
|
14
|
-
return fileConnections;
|
|
15
|
-
}
|
|
16
|
-
static correctFileConnection(fileConnections) {
|
|
17
|
-
const correctFileConnection = {
|
|
18
|
-
fileId: fileConnections.file_id,
|
|
19
|
-
connectionType: fileConnections.connection_type,
|
|
20
|
-
connectionId: fileConnections.connection_id,
|
|
21
|
-
sequence: fileConnections.sequence
|
|
22
|
-
};
|
|
23
|
-
return correctFileConnection;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
|
-
import FileI from "../types/FileI";
|
|
3
|
-
import QueryOptionsI from "../types/QueryOptionsI";
|
|
4
|
-
export default class FilesReader {
|
|
5
|
-
static get(fileId: number): Promise<FileI>;
|
|
6
|
-
static getAll(queryOptions: QueryOptionsI): Promise<FileI[]>;
|
|
7
|
-
static isExist(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
|
-
static getQuantity(queryOptions: any): Promise<number>;
|
|
9
|
-
static getForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<FileI[]>;
|
|
10
|
-
private static correctFiles;
|
|
11
|
-
private static correctFile;
|
|
12
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class FilesReader {
|
|
3
|
-
static async get(fileId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const file = await connection.files.select(fileId);
|
|
6
|
-
return this.correctFile(file);
|
|
7
|
-
}
|
|
8
|
-
static async getAll(queryOptions) {
|
|
9
|
-
const connection = DatabaseConnection.get();
|
|
10
|
-
const file = await connection.files.selectAll(queryOptions);
|
|
11
|
-
return this.correctFiles(file);
|
|
12
|
-
}
|
|
13
|
-
static async isExist(queryOptions) {
|
|
14
|
-
const connection = DatabaseConnection.get();
|
|
15
|
-
const fileId = await connection.files.selectId(queryOptions);
|
|
16
|
-
return fileId;
|
|
17
|
-
}
|
|
18
|
-
static async getQuantity(queryOptions) {
|
|
19
|
-
const connection = DatabaseConnection.get();
|
|
20
|
-
const quantity = await connection.files.count(queryOptions);
|
|
21
|
-
return quantity;
|
|
22
|
-
}
|
|
23
|
-
static async getForConnection(connectionType, connectionId) {
|
|
24
|
-
const connection = DatabaseConnection.get();
|
|
25
|
-
const files = await connection.files.selectForConnection(connectionType, connectionId);
|
|
26
|
-
return this.correctFiles(files);
|
|
27
|
-
}
|
|
28
|
-
static correctFiles(fileRows) {
|
|
29
|
-
const fileConnections = [];
|
|
30
|
-
for (let i = 0; i < fileRows.length; i++) {
|
|
31
|
-
const fileConnection = this.correctFile(fileRows[i]);
|
|
32
|
-
fileConnections.push(fileConnection);
|
|
33
|
-
}
|
|
34
|
-
return fileConnections;
|
|
35
|
-
}
|
|
36
|
-
static correctFile(file) {
|
|
37
|
-
const correctFile = {
|
|
38
|
-
id: file.id,
|
|
39
|
-
name: file.name,
|
|
40
|
-
catalog: file.catalog,
|
|
41
|
-
type: file.type,
|
|
42
|
-
createdAt: file.created_at
|
|
43
|
-
};
|
|
44
|
-
return correctFile;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import AddressesReader from "./AddressesReader";
|
|
3
|
-
import PersonalDataReader from "./PersonalDataReader";
|
|
4
|
-
export default class InvoiceDetailsReader {
|
|
5
|
-
static async get(invoiceDetailsId) {
|
|
6
|
-
const connection = DatabaseConnection.get();
|
|
7
|
-
const invoiceDetails = await connection.invoiceDetails.select(invoiceDetailsId);
|
|
8
|
-
const id = invoiceDetails.id;
|
|
9
|
-
let personalData = null;
|
|
10
|
-
let address = null;
|
|
11
|
-
if (invoiceDetails.personal_data_id)
|
|
12
|
-
personalData = await PersonalDataReader.get(invoiceDetails.personal_data_id);
|
|
13
|
-
if (invoiceDetails.address_id)
|
|
14
|
-
address = await AddressesReader.get(invoiceDetails.address_id);
|
|
15
|
-
return {
|
|
16
|
-
id,
|
|
17
|
-
personalData,
|
|
18
|
-
address
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import OrderProductI from "../types/OrderProductI";
|
|
2
|
-
export default class OrderProductsReader {
|
|
3
|
-
static getAll(orderId: number): Promise<OrderProductI[]>;
|
|
4
|
-
static getForOrder(orderId: number): Promise<any[]>;
|
|
5
|
-
private static correctOrderProducts;
|
|
6
|
-
private static correctProduct;
|
|
7
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
|
-
import FilesReader from "./FilesReader";
|
|
4
|
-
export default class OrderProductsReader {
|
|
5
|
-
static async getAll(orderId) {
|
|
6
|
-
const connection = DatabaseConnection.get();
|
|
7
|
-
const orderProducts = await connection.ordersProducts.selectAllActive(orderId);
|
|
8
|
-
const correctProducts = await this.correctOrderProducts(orderProducts);
|
|
9
|
-
return correctProducts;
|
|
10
|
-
}
|
|
11
|
-
static async getForOrder(orderId) {
|
|
12
|
-
const connection = DatabaseConnection.get();
|
|
13
|
-
const products = await connection.ordersProducts.selectAllActive(orderId);
|
|
14
|
-
const correctProducts = [];
|
|
15
|
-
for (let i = 0; i < products.length; i++) {
|
|
16
|
-
const correctProduct = {
|
|
17
|
-
id: products[i].id,
|
|
18
|
-
orderId: products[i].order_id,
|
|
19
|
-
productId: products[i].product_id,
|
|
20
|
-
netPrice: products[i].net_price,
|
|
21
|
-
};
|
|
22
|
-
correctProducts.push(correctProduct);
|
|
23
|
-
}
|
|
24
|
-
return correctProducts;
|
|
25
|
-
}
|
|
26
|
-
static async correctOrderProducts(products) {
|
|
27
|
-
const correctProducts = [];
|
|
28
|
-
for (let i = 0; i < products.length; i++) {
|
|
29
|
-
const correctProduct = await this.correctProduct(products[i]);
|
|
30
|
-
correctProducts.push(correctProduct);
|
|
31
|
-
}
|
|
32
|
-
return correctProducts;
|
|
33
|
-
}
|
|
34
|
-
static async correctProduct(orderProduct) {
|
|
35
|
-
const file = await FilesReader.get(orderProduct.file_id);
|
|
36
|
-
const correctProduct = {
|
|
37
|
-
id: orderProduct.id,
|
|
38
|
-
orderId: orderProduct.order_id,
|
|
39
|
-
product: {
|
|
40
|
-
id: orderProduct.product_id,
|
|
41
|
-
sku: orderProduct.sku,
|
|
42
|
-
title: orderProduct.title,
|
|
43
|
-
netPrice: orderProduct.net_price,
|
|
44
|
-
grossPrice: calculateNetToGrossPrice(orderProduct.net_price, orderProduct.vat),
|
|
45
|
-
vat: orderProduct.vat,
|
|
46
|
-
file,
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return correctProduct;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import OrderI from "../types/OrderI";
|
|
2
|
-
import QueryOptionsI from "../types/QueryOptionsI";
|
|
3
|
-
export default class OrderReader {
|
|
4
|
-
static get(orderId: number): Promise<OrderI>;
|
|
5
|
-
static getForClient(clientAccountId: number): Promise<OrderI[]>;
|
|
6
|
-
static getAll(queryOptions: QueryOptionsI): Promise<{
|
|
7
|
-
orders: OrderI[];
|
|
8
|
-
quantity: number;
|
|
9
|
-
}>;
|
|
10
|
-
private static correctOrders;
|
|
11
|
-
private static correctOrder;
|
|
12
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import OrderProductsReader from "./OrderProductsReader";
|
|
3
|
-
import OrderStatusReader from "./OrderStatusReader";
|
|
4
|
-
export default class OrderReader {
|
|
5
|
-
static async get(orderId) {
|
|
6
|
-
const connection = DatabaseConnection.get();
|
|
7
|
-
const orderData = await connection.orders.select(orderId);
|
|
8
|
-
return this.correctOrder(orderData);
|
|
9
|
-
}
|
|
10
|
-
static async getForClient(clientAccountId) {
|
|
11
|
-
const connection = DatabaseConnection.get();
|
|
12
|
-
const orders = await connection.orders.selectForClient(clientAccountId);
|
|
13
|
-
const correctOrders = [];
|
|
14
|
-
for (let i = 0; i < orders.length; i++) {
|
|
15
|
-
const correctOrder = await this.correctOrder(orders[i]);
|
|
16
|
-
const products = await OrderProductsReader.getAll(orders[i].id);
|
|
17
|
-
correctOrders.push({ ...correctOrder, products });
|
|
18
|
-
}
|
|
19
|
-
return correctOrders;
|
|
20
|
-
}
|
|
21
|
-
static async getAll(queryOptions) {
|
|
22
|
-
const connection = DatabaseConnection.get();
|
|
23
|
-
const orderRows = await connection.orders.selectAll(queryOptions);
|
|
24
|
-
const quantity = await connection.orders.count(queryOptions);
|
|
25
|
-
const orders = await this.correctOrders(orderRows);
|
|
26
|
-
return { orders, quantity };
|
|
27
|
-
}
|
|
28
|
-
static async correctOrders(orderRows) {
|
|
29
|
-
const orders = [];
|
|
30
|
-
for (let i = 0; i < orderRows.length; i++) {
|
|
31
|
-
const order = await this.correctOrder(orderRows[i]);
|
|
32
|
-
orders.push(order);
|
|
33
|
-
}
|
|
34
|
-
return orders;
|
|
35
|
-
}
|
|
36
|
-
static async correctOrder(order) {
|
|
37
|
-
const status = await OrderStatusReader.get(order.id);
|
|
38
|
-
const correctOrder = {
|
|
39
|
-
id: order.id,
|
|
40
|
-
email: order.email,
|
|
41
|
-
price: order.price,
|
|
42
|
-
createdAt: order.created_at,
|
|
43
|
-
clientId: order.client_id,
|
|
44
|
-
contactDetailsId: order.contact_details_id,
|
|
45
|
-
deliveryDetailsId: order.delivery_details_id,
|
|
46
|
-
invoiceDetailsId: order.invoice_details_id,
|
|
47
|
-
paymentDetailsId: order.payment_details_id,
|
|
48
|
-
zsiId: order.zsi_id,
|
|
49
|
-
status
|
|
50
|
-
};
|
|
51
|
-
return correctOrder;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
export default class OrderStatusReader {
|
|
3
|
-
static async get(orderId) {
|
|
4
|
-
const connection = DatabaseConnection.get();
|
|
5
|
-
const statusRow = await connection.statuses.select(orderId);
|
|
6
|
-
return this.correctStatus(statusRow);
|
|
7
|
-
}
|
|
8
|
-
static async getAll(orderId) {
|
|
9
|
-
const connection = DatabaseConnection.get();
|
|
10
|
-
const statuses = await connection.statuses.selectAll(orderId);
|
|
11
|
-
const correctStatuss = [];
|
|
12
|
-
for (let i = 0; i < statuses.length; i++) {
|
|
13
|
-
const correctStatus = this.correctStatus(statuses[i]);
|
|
14
|
-
correctStatuss.push(correctStatus);
|
|
15
|
-
}
|
|
16
|
-
return correctStatuss;
|
|
17
|
-
}
|
|
18
|
-
static correctStatus(status) {
|
|
19
|
-
const correctStatus = {
|
|
20
|
-
id: status.id,
|
|
21
|
-
orderId: status.order_id,
|
|
22
|
-
createdAt: status.created_at,
|
|
23
|
-
userId: status.user_id,
|
|
24
|
-
typeId: status.type_id,
|
|
25
|
-
typeName: status.type_name,
|
|
26
|
-
};
|
|
27
|
-
return correctStatus;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import correctPhoneNumber from "../utils/correctPhoneNumber";
|
|
3
|
-
import CompanyDetailsReader from "./CompanyDetailsReader";
|
|
4
|
-
export default class PersonalDataReader {
|
|
5
|
-
static async get(personalDataId) {
|
|
6
|
-
const connection = DatabaseConnection.get();
|
|
7
|
-
const data = await connection.personalData.select(personalDataId);
|
|
8
|
-
const correctData = this.getCorrectData(data);
|
|
9
|
-
if (data.company_details_id) {
|
|
10
|
-
correctData.companyDetails = await CompanyDetailsReader.get(data.company_details_id);
|
|
11
|
-
correctData.isCompany = true;
|
|
12
|
-
}
|
|
13
|
-
return correctData;
|
|
14
|
-
}
|
|
15
|
-
static getCorrectData(data) {
|
|
16
|
-
const phoneNumber = correctPhoneNumber(data.phone_number);
|
|
17
|
-
return {
|
|
18
|
-
id: data.id,
|
|
19
|
-
firstName: data.first_name,
|
|
20
|
-
lastName: data.last_name,
|
|
21
|
-
email: data.email,
|
|
22
|
-
phoneNumber,
|
|
23
|
-
companyDetails: null,
|
|
24
|
-
isCompany: false
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|