@dascompany/product 4.5.1 → 4.5.3
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/DatabaseConnection.d.ts +57 -0
- package/dist/DatabaseConnection.js +165 -0
- package/dist/SQL.json +153 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/lib/errors/CilentAccountExistWithThisEmail.d.ts +3 -0
- package/dist/lib/errors/CilentAccountExistWithThisEmail.js +5 -0
- package/dist/mappers/AddressMapper.d.ts +9 -0
- package/dist/mappers/AddressMapper.js +22 -0
- package/dist/mappers/AdminMapper.d.ts +9 -0
- package/dist/mappers/AdminMapper.js +24 -0
- package/dist/mappers/ClientMapper.d.ts +9 -0
- package/dist/mappers/ClientMapper.js +24 -0
- package/dist/mappers/CompanyDataMapper.d.ts +9 -0
- package/dist/mappers/CompanyDataMapper.js +17 -0
- package/dist/mappers/CompanyDetailsMapper.d.ts +9 -0
- package/dist/mappers/CompanyDetailsMapper.js +27 -0
- package/dist/mappers/DeliveryDetailsMapper.d.ts +9 -0
- package/dist/mappers/DeliveryDetailsMapper.js +30 -0
- package/dist/mappers/DeliveryMethodsMapper.d.ts +9 -0
- package/dist/mappers/DeliveryMethodsMapper.js +17 -0
- package/dist/mappers/DeliveryStatusMapper.d.ts +9 -0
- package/dist/mappers/DeliveryStatusMapper.js +15 -0
- package/dist/mappers/FileConnectionMapper.d.ts +9 -0
- package/dist/mappers/FileConnectionMapper.js +18 -0
- package/dist/mappers/FileMapper.d.ts +9 -0
- package/dist/mappers/FileMapper.js +17 -0
- package/dist/mappers/OrderMapper.d.ts +9 -0
- package/dist/mappers/OrderMapper.js +19 -0
- package/dist/mappers/OrderProductMapper.d.ts +9 -0
- package/dist/mappers/OrderProductMapper.js +19 -0
- package/dist/mappers/PaymentDetailsMapper.d.ts +9 -0
- package/dist/mappers/PaymentDetailsMapper.js +17 -0
- package/dist/mappers/PaymentMethodsMapper.d.ts +9 -0
- package/dist/mappers/PaymentMethodsMapper.js +17 -0
- package/dist/mappers/PaymentStatusMapper.d.ts +9 -0
- package/dist/mappers/PaymentStatusMapper.js +15 -0
- package/dist/mappers/PersonalDataMapper.d.ts +9 -0
- package/dist/mappers/PersonalDataMapper.js +22 -0
- package/dist/mappers/ProductMapper.d.ts +9 -0
- package/dist/mappers/ProductMapper.js +20 -0
- package/dist/mappers/StatusMapper.d.ts +9 -0
- package/dist/mappers/StatusMapper.js +15 -0
- package/dist/reader/AccountCartReader.d.ts +6 -0
- package/dist/reader/AccountCartReader.js +25 -0
- package/dist/reader/AccountCompanyDetailsReader.d.ts +5 -0
- package/dist/reader/AccountCompanyDetailsReader.js +17 -0
- package/dist/reader/AccountDeliveryDetailsReader.d.ts +5 -0
- package/dist/reader/AccountDeliveryDetailsReader.js +17 -0
- package/dist/reader/AddressesReader.d.ts +6 -0
- package/dist/reader/AddressesReader.js +18 -0
- package/dist/reader/AdminReader.d.ts +10 -0
- package/dist/reader/AdminReader.js +37 -0
- package/dist/reader/ClientAccountReader.d.ts +10 -0
- package/dist/reader/ClientAccountReader.js +39 -0
- package/dist/reader/CompanyDataReader.d.ts +4 -0
- package/dist/reader/CompanyDataReader.js +39 -0
- package/dist/reader/CompanyDetailsReader.d.ts +5 -0
- package/dist/reader/CompanyDetailsReader.js +18 -0
- package/dist/reader/DeliveryDetailsReader.d.ts +5 -0
- package/dist/reader/DeliveryDetailsReader.js +26 -0
- package/dist/reader/DeliveryMethodReader.d.ts +6 -0
- package/dist/reader/DeliveryMethodReader.js +11 -0
- package/dist/reader/DeliveryStatusReader.d.ts +6 -0
- package/dist/reader/DeliveryStatusReader.js +29 -0
- package/dist/reader/FileConnectionsReader.d.ts +7 -0
- package/dist/reader/FileConnectionsReader.js +24 -0
- package/dist/reader/FilesReader.d.ts +11 -0
- package/dist/reader/FilesReader.js +43 -0
- package/dist/reader/MarketPlacesReader.d.ts +8 -0
- package/dist/reader/MarketPlacesReader.js +28 -0
- package/dist/reader/OrderProductsReader.d.ts +7 -0
- package/dist/reader/OrderProductsReader.js +40 -0
- package/dist/reader/OrderReader.d.ts +10 -0
- package/dist/reader/OrderReader.js +57 -0
- package/dist/reader/OrderStatusReader.d.ts +6 -0
- package/dist/reader/OrderStatusReader.js +29 -0
- package/dist/reader/PersonalDataReader.d.ts +6 -0
- package/dist/reader/PersonalDataReader.js +19 -0
- package/dist/reader/ProductReader.d.ts +11 -0
- package/dist/reader/ProductReader.js +64 -0
- package/dist/reader/StatusTypesReader.d.ts +8 -0
- package/dist/reader/StatusTypesReader.js +11 -0
- package/dist/reader/payment/PaymentDetailsReader.d.ts +5 -0
- package/dist/reader/payment/PaymentDetailsReader.js +29 -0
- package/dist/reader/payment/PaymentMethodReader.d.ts +6 -0
- package/dist/reader/payment/PaymentMethodReader.js +11 -0
- package/dist/reader/payment/PaymentStatusesReader.d.ts +6 -0
- package/dist/reader/payment/PaymentStatusesReader.js +28 -0
- package/dist/repo/AddressesRepo.d.ts +6 -0
- package/dist/repo/AddressesRepo.js +13 -0
- package/dist/repo/AdminRepo.d.ts +8 -0
- package/dist/repo/AdminRepo.js +20 -0
- package/dist/repo/ClientAccountRepo.d.ts +6 -0
- package/dist/repo/ClientAccountRepo.js +13 -0
- package/dist/repo/CompanyDataRepo.d.ts +4 -0
- package/dist/repo/CompanyDataRepo.js +10 -0
- package/dist/repo/CompanyDetailsRepo.d.ts +6 -0
- package/dist/repo/CompanyDetailsRepo.js +13 -0
- package/dist/repo/DeliveryDetailsRepo.d.ts +6 -0
- package/dist/repo/DeliveryDetailsRepo.js +13 -0
- package/dist/repo/DeliveryMethodRepo.d.ts +5 -0
- package/dist/repo/DeliveryMethodRepo.js +10 -0
- package/dist/repo/FileConnectionsRepo.d.ts +8 -0
- package/dist/repo/FileConnectionsRepo.js +23 -0
- package/dist/repo/FilesRepo.d.ts +7 -0
- package/dist/repo/FilesRepo.js +24 -0
- package/dist/repo/OrderProductsRepo.d.ts +7 -0
- package/dist/repo/OrderProductsRepo.js +21 -0
- package/dist/repo/OrderRepo.d.ts +6 -0
- package/dist/repo/OrderRepo.js +13 -0
- package/dist/repo/PaymentDetailsRepo.d.ts +6 -0
- package/dist/repo/PaymentDetailsRepo.js +13 -0
- package/dist/repo/PaymentMethodRepo.d.ts +5 -0
- package/dist/repo/PaymentMethodRepo.js +10 -0
- package/dist/repo/PersonalDataRepo.d.ts +6 -0
- package/dist/repo/PersonalDataRepo.js +15 -0
- package/dist/repo/ProductRepo.d.ts +6 -0
- package/dist/repo/ProductRepo.js +14 -0
- package/dist/stockObjects/AccountCartItem.ts.d.ts +21 -0
- package/dist/stockObjects/AccountCartItem.ts.js +44 -0
- package/dist/stockObjects/Address.d.ts +32 -0
- package/dist/stockObjects/Address.js +69 -0
- package/dist/stockObjects/Admin.d.ts +24 -0
- package/dist/stockObjects/Admin.js +57 -0
- package/dist/stockObjects/Client.d.ts +27 -0
- package/dist/stockObjects/Client.js +93 -0
- package/dist/stockObjects/CompanyData.d.ts +35 -0
- package/dist/stockObjects/CompanyData.js +90 -0
- package/dist/stockObjects/CompanyDetails.d.ts +14 -0
- package/dist/stockObjects/CompanyDetails.js +34 -0
- package/dist/stockObjects/DeliveryDetails.d.ts +15 -0
- package/dist/stockObjects/DeliveryDetails.js +37 -0
- package/dist/stockObjects/DeliveryMethods.d.ts +11 -0
- package/dist/stockObjects/DeliveryMethods.js +26 -0
- package/dist/stockObjects/DeliveryStatus.d.ts +17 -0
- package/dist/stockObjects/DeliveryStatus.js +42 -0
- package/dist/stockObjects/File.d.ts +24 -0
- package/dist/stockObjects/File.js +60 -0
- package/dist/stockObjects/FileConnection.d.ts +17 -0
- package/dist/stockObjects/FileConnection.js +42 -0
- package/dist/stockObjects/Order.d.ts +42 -0
- package/dist/stockObjects/Order.js +109 -0
- package/dist/stockObjects/OrderProduct.d.ts +16 -0
- package/dist/stockObjects/OrderProduct.js +38 -0
- package/dist/stockObjects/PaymentDetails.d.ts +11 -0
- package/dist/stockObjects/PaymentDetails.js +26 -0
- package/dist/stockObjects/PaymentMethods.d.ts +11 -0
- package/dist/stockObjects/PaymentMethods.js +26 -0
- package/dist/stockObjects/PaymentStatus.d.ts +12 -0
- package/dist/stockObjects/PaymentStatus.js +26 -0
- package/dist/stockObjects/PersonalData.d.ts +24 -0
- package/dist/stockObjects/PersonalData.js +53 -0
- package/dist/stockObjects/Product.d.ts +81 -0
- package/dist/stockObjects/Product.js +200 -0
- package/dist/stockObjects/Status.d.ts +17 -0
- package/dist/stockObjects/Status.js +42 -0
- package/dist/tables/TableNames.d.ts +28 -0
- package/dist/tables/TableNames.js +29 -0
- package/dist/tables/clients/AccountCartTable.d.ts +11 -0
- package/dist/tables/clients/AccountCartTable.js +35 -0
- package/dist/tables/clients/AccountCompanyDetailsTable.d.ts +7 -0
- package/dist/tables/clients/AccountCompanyDetailsTable.js +22 -0
- package/dist/tables/clients/AccountDeliveryDetailsTable.d.ts +7 -0
- package/dist/tables/clients/AccountDeliveryDetailsTable.js +22 -0
- package/dist/tables/clients/ClientAccountsTable.d.ts +14 -0
- package/dist/tables/clients/ClientAccountsTable.js +65 -0
- package/dist/tables/files/FileConnectionsTable.d.ts +9 -0
- package/dist/tables/files/FileConnectionsTable.js +25 -0
- package/dist/tables/files/FilesTable.d.ts +15 -0
- package/dist/tables/files/FilesTable.js +65 -0
- package/dist/tables/orders/OrdersProductsTable.d.ts +10 -0
- package/dist/tables/orders/OrdersProductsTable.js +36 -0
- package/dist/tables/orders/OrdersTable.d.ts +13 -0
- package/dist/tables/orders/OrdersTable.js +54 -0
- package/dist/tables/orders/PaymentDetailsTable.d.ts +10 -0
- package/dist/tables/orders/PaymentDetailsTable.js +33 -0
- package/dist/tables/orders/PaymentStatusTypesTable.d.ts +7 -0
- package/dist/tables/orders/PaymentStatusTypesTable.js +9 -0
- package/dist/tables/orders/PaymentStatusesTable.d.ts +9 -0
- package/dist/tables/orders/PaymentStatusesTable.js +28 -0
- package/dist/tables/orders/StatusTypesTable.d.ts +8 -0
- package/dist/tables/orders/StatusTypesTable.js +14 -0
- package/dist/tables/orders/StatusesTable.d.ts +10 -0
- package/dist/tables/orders/StatusesTable.js +32 -0
- package/dist/tables/personalInformation/AddressesTable.d.ts +11 -0
- package/dist/tables/personalInformation/AddressesTable.js +41 -0
- package/dist/tables/personalInformation/CompanyDetailsTable.d.ts +11 -0
- package/dist/tables/personalInformation/CompanyDetailsTable.js +38 -0
- package/dist/tables/personalInformation/DeliveryDetailsTable.d.ts +11 -0
- package/dist/tables/personalInformation/DeliveryDetailsTable.js +39 -0
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.d.ts +7 -0
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.js +9 -0
- package/dist/tables/personalInformation/DeliveryStatusesTable.d.ts +9 -0
- package/dist/tables/personalInformation/DeliveryStatusesTable.js +29 -0
- package/dist/tables/personalInformation/PersonalDataTable.d.ts +11 -0
- package/dist/tables/personalInformation/PersonalDataTable.js +40 -0
- package/dist/tables/public/AdminAccountsTable.d.ts +14 -0
- package/dist/tables/public/AdminAccountsTable.js +66 -0
- package/dist/tables/public/ProductsTable.d.ts +15 -0
- package/dist/tables/public/ProductsTable.js +83 -0
- package/dist/tables/settings/CompanyDataTable.d.ts +10 -0
- package/dist/tables/settings/CompanyDataTable.js +42 -0
- package/dist/tables/settings/DeliveryMethodsTable.d.ts +11 -0
- package/dist/tables/settings/DeliveryMethodsTable.js +39 -0
- package/dist/tables/settings/MarketPlacesTable.d.ts +5 -0
- package/dist/tables/settings/MarketPlacesTable.js +9 -0
- package/dist/tables/settings/PaymentMethodsTable.d.ts +11 -0
- package/dist/tables/settings/PaymentMethodsTable.js +39 -0
- package/dist/types/ChoiceTypeE.d.ts +8 -0
- package/dist/types/ChoiceTypeE.js +9 -0
- package/dist/types/OrderConfirmationTypeE.d.ts +5 -0
- package/dist/types/OrderConfirmationTypeE.js +6 -0
- package/dist/types/OrderHashI.d.ts +5 -0
- package/dist/types/OrderHashI.js +1 -0
- package/dist/types/rows/OrderHashRow.d.ts +5 -0
- package/dist/types/rows/OrderHashRow.js +1 -0
- package/dist/utils/AccountCart.d.ts +6 -0
- package/dist/utils/AccountCart.js +20 -0
- package/dist/utils/PriceConverter.d.ts +5 -0
- package/dist/utils/PriceConverter.js +14 -0
- package/dist/utils/correctPhoneNumber.d.ts +1 -0
- package/dist/utils/correctPhoneNumber.js +14 -0
- package/dist/utils/createQueryOptionsForId.d.ts +2 -0
- package/dist/utils/createQueryOptionsForId.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class DeliveryMethodsMapper {
|
|
3
|
+
deliveryMethods;
|
|
4
|
+
deliveryMethodsTable;
|
|
5
|
+
constructor(deliveryMethods) {
|
|
6
|
+
this.deliveryMethodsTable = DatabaseConnection.getInstance().deliveryMethods;
|
|
7
|
+
this.deliveryMethods = deliveryMethods;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.deliveryMethods.getId())
|
|
11
|
+
await this.deliveryMethodsTable.update(this.deliveryMethods);
|
|
12
|
+
else
|
|
13
|
+
await this.deliveryMethodsTable.insert(this.deliveryMethods);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import DeliveryStatus from "../stockObjects/DeliveryStatus";
|
|
3
|
+
export default class DeliveryStatusMapper implements StockObjectMapper {
|
|
4
|
+
private deliveryStatus;
|
|
5
|
+
private deliveryStatusesTable;
|
|
6
|
+
constructor(deliveryStatus: DeliveryStatus);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class DeliveryStatusMapper {
|
|
3
|
+
deliveryStatus;
|
|
4
|
+
deliveryStatusesTable;
|
|
5
|
+
constructor(deliveryStatus) {
|
|
6
|
+
this.deliveryStatusesTable = DatabaseConnection.getInstance().deliveryStatuses;
|
|
7
|
+
this.deliveryStatus = deliveryStatus;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
await this.deliveryStatusesTable.insert(this.deliveryStatus);
|
|
11
|
+
}
|
|
12
|
+
async delete() {
|
|
13
|
+
throw Error('Method not implemented');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from '@dascompany/database';
|
|
2
|
+
import FileConnection from '../stockObjects/FileConnection';
|
|
3
|
+
export default class FileConnectionMapper implements StockObjectMapper {
|
|
4
|
+
private fileConnection;
|
|
5
|
+
private fileConnectionsTable;
|
|
6
|
+
constructor(fileConnection: FileConnection);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DatabaseConnection from '../DatabaseConnection';
|
|
2
|
+
import createQueryOptionsForId from '../utils/createQueryOptionsForId';
|
|
3
|
+
export default class FileConnectionMapper {
|
|
4
|
+
fileConnection;
|
|
5
|
+
fileConnectionsTable;
|
|
6
|
+
constructor(fileConnection) {
|
|
7
|
+
this.fileConnectionsTable = DatabaseConnection.getInstance().fileConnections;
|
|
8
|
+
this.fileConnection = fileConnection;
|
|
9
|
+
}
|
|
10
|
+
async save() {
|
|
11
|
+
const id = this.fileConnection.getId();
|
|
12
|
+
if (id)
|
|
13
|
+
await this.fileConnectionsTable.delete(createQueryOptionsForId(id));
|
|
14
|
+
await this.fileConnectionsTable.insert(this.fileConnection);
|
|
15
|
+
}
|
|
16
|
+
async delete() {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import File from "../stockObjects/File";
|
|
3
|
+
export default class FileMapper implements StockObjectMapper {
|
|
4
|
+
private file;
|
|
5
|
+
private filesTable;
|
|
6
|
+
constructor(file: File);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class FileMapper {
|
|
3
|
+
file;
|
|
4
|
+
filesTable;
|
|
5
|
+
constructor(file) {
|
|
6
|
+
this.filesTable = DatabaseConnection.getInstance().files;
|
|
7
|
+
this.file = file;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.file.getId())
|
|
11
|
+
await this.filesTable.update(this.file);
|
|
12
|
+
else
|
|
13
|
+
await this.filesTable.insert(this.file);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import Order from "../stockObjects/Order";
|
|
3
|
+
export default class OrderMapper implements StockObjectMapper {
|
|
4
|
+
private order;
|
|
5
|
+
private orderTable;
|
|
6
|
+
constructor(order: Order);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class OrderMapper {
|
|
3
|
+
order;
|
|
4
|
+
orderTable;
|
|
5
|
+
constructor(order) {
|
|
6
|
+
this.orderTable = DatabaseConnection.getInstance().orders;
|
|
7
|
+
this.order = order;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
const orderId = this.order.getId();
|
|
11
|
+
if (orderId)
|
|
12
|
+
await this.orderTable.update(this.order);
|
|
13
|
+
else
|
|
14
|
+
await this.orderTable.insert(this.order);
|
|
15
|
+
}
|
|
16
|
+
async delete() {
|
|
17
|
+
throw Error('method not implemented');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import OrderProduct from "../stockObjects/OrderProduct";
|
|
3
|
+
export default class OrderProductMapper implements StockObjectMapper {
|
|
4
|
+
private orderProduct;
|
|
5
|
+
private orderProductsTable;
|
|
6
|
+
constructor(orderProduct: OrderProduct);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class OrderProductMapper {
|
|
3
|
+
orderProduct;
|
|
4
|
+
orderProductsTable;
|
|
5
|
+
constructor(orderProduct) {
|
|
6
|
+
this.orderProductsTable = DatabaseConnection.getInstance().ordersProducts;
|
|
7
|
+
this.orderProduct = orderProduct;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
await this.orderProductsTable.insert(this.orderProduct);
|
|
11
|
+
}
|
|
12
|
+
async delete() {
|
|
13
|
+
const orderId = this.orderProduct.getId();
|
|
14
|
+
if (orderId)
|
|
15
|
+
await this.orderProductsTable.delete(orderId);
|
|
16
|
+
else
|
|
17
|
+
throw new Error('Can`t remove the order and product connection without providing its ID');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import PaymentDetails from "../stockObjects/PaymentDetails";
|
|
3
|
+
export default class PaymentDetailsMapper implements StockObjectMapper {
|
|
4
|
+
private paymentDetails;
|
|
5
|
+
private paymentDetailsTable;
|
|
6
|
+
constructor(paymentDetails: PaymentDetails);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class PaymentDetailsMapper {
|
|
3
|
+
paymentDetails;
|
|
4
|
+
paymentDetailsTable;
|
|
5
|
+
constructor(paymentDetails) {
|
|
6
|
+
this.paymentDetailsTable = DatabaseConnection.getInstance().paymentDetails;
|
|
7
|
+
this.paymentDetails = paymentDetails;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.paymentDetails.getId())
|
|
11
|
+
await this.paymentDetailsTable.update(this.paymentDetails);
|
|
12
|
+
else
|
|
13
|
+
await this.paymentDetailsTable.insert(this.paymentDetails);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import PaymentMethods from "../stockObjects/PaymentMethods";
|
|
3
|
+
export default class PaymentMethodsMapper implements StockObjectMapper {
|
|
4
|
+
private paymentMethods;
|
|
5
|
+
private paymentMethodsTable;
|
|
6
|
+
constructor(paymentMethods: PaymentMethods);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class PaymentMethodsMapper {
|
|
3
|
+
paymentMethods;
|
|
4
|
+
paymentMethodsTable;
|
|
5
|
+
constructor(paymentMethods) {
|
|
6
|
+
this.paymentMethodsTable = DatabaseConnection.getInstance().paymentMethods;
|
|
7
|
+
this.paymentMethods = paymentMethods;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.paymentMethods.getId())
|
|
11
|
+
await this.paymentMethodsTable.update(this.paymentMethods);
|
|
12
|
+
else
|
|
13
|
+
await this.paymentMethodsTable.insert(this.paymentMethods);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import PaymentStatus from "../stockObjects/PaymentStatus";
|
|
3
|
+
export default class PaymentStatusMapper implements StockObjectMapper {
|
|
4
|
+
private paymentStatus;
|
|
5
|
+
private paymentStatusesTable;
|
|
6
|
+
constructor(paymentStatus: PaymentStatus);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class PaymentStatusMapper {
|
|
3
|
+
paymentStatus;
|
|
4
|
+
paymentStatusesTable;
|
|
5
|
+
constructor(paymentStatus) {
|
|
6
|
+
this.paymentStatusesTable = DatabaseConnection.getInstance().paymentStatuses;
|
|
7
|
+
this.paymentStatus = paymentStatus;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
await this.paymentStatusesTable.insert(this.paymentStatus);
|
|
11
|
+
}
|
|
12
|
+
async delete() {
|
|
13
|
+
throw Error('Method not implemented');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import PersonalData from "../stockObjects/PersonalData";
|
|
3
|
+
export default class PersonalDataMapper implements StockObjectMapper {
|
|
4
|
+
private personalData;
|
|
5
|
+
private personalDataTable;
|
|
6
|
+
constructor(personalData: PersonalData);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class PersonalDataMapper {
|
|
3
|
+
personalData;
|
|
4
|
+
personalDataTable;
|
|
5
|
+
constructor(personalData) {
|
|
6
|
+
this.personalDataTable = DatabaseConnection.getInstance().personalData;
|
|
7
|
+
this.personalData = personalData;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.personalData.getId())
|
|
11
|
+
await this.personalDataTable.update(this.personalData);
|
|
12
|
+
else
|
|
13
|
+
await this.personalDataTable.insert(this.personalData);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
const id = this.personalData.getId();
|
|
17
|
+
if (id)
|
|
18
|
+
await this.personalDataTable.delete(id);
|
|
19
|
+
else
|
|
20
|
+
throw Error('Uncreated personalData cannot be deleted');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import Product from "../stockObjects/Product";
|
|
3
|
+
export default class ProductMapper implements StockObjectMapper {
|
|
4
|
+
private product;
|
|
5
|
+
private productTable;
|
|
6
|
+
constructor(product: Product);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class ProductMapper {
|
|
3
|
+
product;
|
|
4
|
+
productTable;
|
|
5
|
+
constructor(product) {
|
|
6
|
+
this.productTable = DatabaseConnection.getInstance().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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StockObjectMapper } from "@dascompany/database";
|
|
2
|
+
import Status from "../stockObjects/Status";
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class StatusMapper {
|
|
3
|
+
status;
|
|
4
|
+
statusTable;
|
|
5
|
+
constructor(status) {
|
|
6
|
+
this.statusTable = DatabaseConnection.getInstance().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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
3
|
+
export default class AccountCartReader {
|
|
4
|
+
static async getAll(accountId) {
|
|
5
|
+
const queryOptions = new QueryOptions();
|
|
6
|
+
queryOptions.setWhere([{ name: 'account_id', type: ParameterType.bigint, value: accountId }]);
|
|
7
|
+
const accountCart = await DatabaseConnection.getInstance().accountCart.select(queryOptions);
|
|
8
|
+
return this.correctAccountCart(accountCart);
|
|
9
|
+
}
|
|
10
|
+
static async get(queryOptions) {
|
|
11
|
+
const accountCart = await DatabaseConnection.getInstance().accountCart.select(queryOptions);
|
|
12
|
+
return this.correctAccountCart(accountCart);
|
|
13
|
+
}
|
|
14
|
+
static async correctAccountCart(accountCart) {
|
|
15
|
+
const correctAccountCart = [];
|
|
16
|
+
for (let i = 0; i < accountCart.length; i++) {
|
|
17
|
+
correctAccountCart.push({
|
|
18
|
+
id: accountCart[i].product_id,
|
|
19
|
+
installation: accountCart[i].installation,
|
|
20
|
+
quantity: accountCart[i].quantity
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return correctAccountCart;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
3
|
+
import CompanyDetailsReader from "./CompanyDetailsReader";
|
|
4
|
+
export default class AccountCompanyDetailsReader {
|
|
5
|
+
static async getAll(accountId) {
|
|
6
|
+
const accountCompanyDetails = await DatabaseConnection.getInstance().accountCompanyDetails.selectAll(accountId);
|
|
7
|
+
return this.correctAccountCompanyDetails(accountCompanyDetails);
|
|
8
|
+
}
|
|
9
|
+
static async correctAccountCompanyDetails(accountCompanyDetails) {
|
|
10
|
+
const correctAccountCompanyDetails = [];
|
|
11
|
+
for (let i = 0; i < accountCompanyDetails.length; i++) {
|
|
12
|
+
const companyDetails = await CompanyDetailsReader.get(createQueryOptionsForId(accountCompanyDetails[i].company_details_id));
|
|
13
|
+
correctAccountCompanyDetails.push(companyDetails);
|
|
14
|
+
}
|
|
15
|
+
return correctAccountCompanyDetails;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
3
|
+
import DeliveryDetailsReader from "./DeliveryDetailsReader";
|
|
4
|
+
export default class AccountDeliveryDetailsReader {
|
|
5
|
+
static async getAll(accountId) {
|
|
6
|
+
const accountDeliveryDetails = await DatabaseConnection.getInstance().accountDeliveryDetails.selectAll(accountId);
|
|
7
|
+
return this.correctAccountDeliveryDetails(accountDeliveryDetails);
|
|
8
|
+
}
|
|
9
|
+
static async correctAccountDeliveryDetails(accountDeliveryDetails) {
|
|
10
|
+
const correctAccountDeliveryDetails = [];
|
|
11
|
+
for (let i = 0; i < accountDeliveryDetails.length; i++) {
|
|
12
|
+
const deliveryDetails = await DeliveryDetailsReader.get(createQueryOptionsForId(accountDeliveryDetails[i].delivery_details_id));
|
|
13
|
+
correctAccountDeliveryDetails.push(deliveryDetails);
|
|
14
|
+
}
|
|
15
|
+
return correctAccountDeliveryDetails;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class AddressesReader {
|
|
3
|
+
static async get(queryOptions) {
|
|
4
|
+
const address = await DatabaseConnection.getInstance().addresses.select(queryOptions);
|
|
5
|
+
return this.getCorrectData(address);
|
|
6
|
+
}
|
|
7
|
+
static getCorrectData(address) {
|
|
8
|
+
return {
|
|
9
|
+
id: address.id,
|
|
10
|
+
country: address.country,
|
|
11
|
+
city: address.city,
|
|
12
|
+
postalCode: address.postal_code,
|
|
13
|
+
street: address.street,
|
|
14
|
+
houseNumber: address.house_number,
|
|
15
|
+
apartmentNumber: address.apartment_number,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
2
|
+
import AdminI from "../types/AdminI";
|
|
3
|
+
export default class AdminReader {
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<AdminI>;
|
|
5
|
+
static getId(queryOptions: QueryOptions): Promise<string>;
|
|
6
|
+
static getAll(queryOptions?: QueryOptions): Promise<AdminI[]>;
|
|
7
|
+
static getQuantity(queryOptions: QueryOptions): Promise<number>;
|
|
8
|
+
private static correctAdmins;
|
|
9
|
+
private static correctAdmin;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class AdminReader {
|
|
3
|
+
static async get(queryOptions) {
|
|
4
|
+
const account = await DatabaseConnection.getInstance().adminAccounts.select(queryOptions);
|
|
5
|
+
return this.correctAdmin(account);
|
|
6
|
+
}
|
|
7
|
+
static async getId(queryOptions) {
|
|
8
|
+
return await DatabaseConnection.getInstance().adminAccounts.selectId(queryOptions);
|
|
9
|
+
}
|
|
10
|
+
static async getAll(queryOptions) {
|
|
11
|
+
const adminAccounts = await DatabaseConnection.getInstance().adminAccounts.selectAll(queryOptions);
|
|
12
|
+
return this.correctAdmins(adminAccounts);
|
|
13
|
+
}
|
|
14
|
+
static async getQuantity(queryOptions) {
|
|
15
|
+
const quantity = await DatabaseConnection.getInstance().adminAccounts.count(queryOptions);
|
|
16
|
+
return Number(quantity);
|
|
17
|
+
}
|
|
18
|
+
static correctAdmins(admins) {
|
|
19
|
+
const correctAdmins = [];
|
|
20
|
+
for (let i = 0; i < admins.length; i++) {
|
|
21
|
+
const correctAdmin = this.correctAdmin(admins[i]);
|
|
22
|
+
correctAdmins.push(correctAdmin);
|
|
23
|
+
}
|
|
24
|
+
return correctAdmins;
|
|
25
|
+
}
|
|
26
|
+
static correctAdmin(admin) {
|
|
27
|
+
return {
|
|
28
|
+
id: admin.id,
|
|
29
|
+
email: admin.email,
|
|
30
|
+
firstName: admin.first_name,
|
|
31
|
+
lastName: admin.last_name,
|
|
32
|
+
activated: admin.activated,
|
|
33
|
+
deleted: admin.deleted,
|
|
34
|
+
createdAt: admin.created_at
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
2
|
+
import ClientAccountI from "../types/ClientAccountI";
|
|
3
|
+
export default class ClientAccountReader {
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<ClientAccountI>;
|
|
5
|
+
static getAll(queryOptions?: QueryOptions): Promise<ClientAccountI[]>;
|
|
6
|
+
static getQuantity(queryOptions: QueryOptions): Promise<number>;
|
|
7
|
+
static getId(queryOptions: QueryOptions): Promise<string | null>;
|
|
8
|
+
private static correctClientsFromRows;
|
|
9
|
+
private static correctData;
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class ClientAccountReader {
|
|
3
|
+
static async get(queryOptions) {
|
|
4
|
+
const account = await DatabaseConnection.getInstance().clientAccounts.select(queryOptions);
|
|
5
|
+
return this.correctData(account);
|
|
6
|
+
}
|
|
7
|
+
static async getAll(queryOptions) {
|
|
8
|
+
const clientAccounts = await DatabaseConnection.getInstance().clientAccounts.selectAll(queryOptions);
|
|
9
|
+
return this.correctClientsFromRows(clientAccounts);
|
|
10
|
+
}
|
|
11
|
+
static async getQuantity(queryOptions) {
|
|
12
|
+
const quantity = await DatabaseConnection.getInstance().clientAccounts.count(queryOptions);
|
|
13
|
+
return Number(quantity);
|
|
14
|
+
}
|
|
15
|
+
static async getId(queryOptions) {
|
|
16
|
+
const accountId = await DatabaseConnection.getInstance().clientAccounts.selectId(queryOptions);
|
|
17
|
+
return accountId;
|
|
18
|
+
}
|
|
19
|
+
static correctClientsFromRows(dataRows) {
|
|
20
|
+
const clients = [];
|
|
21
|
+
for (const dataRow of dataRows) {
|
|
22
|
+
const client = this.correctData(dataRow);
|
|
23
|
+
clients.push(client);
|
|
24
|
+
}
|
|
25
|
+
return clients;
|
|
26
|
+
}
|
|
27
|
+
static correctData(client) {
|
|
28
|
+
return {
|
|
29
|
+
id: client.id,
|
|
30
|
+
email: client.email,
|
|
31
|
+
createdAt: client.created_at,
|
|
32
|
+
activated: client.activated,
|
|
33
|
+
deleted: client.deleted,
|
|
34
|
+
personalDataId: client.personal_data_id,
|
|
35
|
+
deliveryDetailsId: client.delivery_details_id,
|
|
36
|
+
companyDetailsId: client.company_details_id,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./AddressesReader";
|
|
3
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
4
|
+
export default class CompanyDataReader {
|
|
5
|
+
static async get() {
|
|
6
|
+
const companyData = await DatabaseConnection.getInstance().companyData.select();
|
|
7
|
+
if (companyData) {
|
|
8
|
+
const address = companyData?.address_id ? await AddressesReader.get(createQueryOptionsForId(companyData.address_id)) : null;
|
|
9
|
+
return {
|
|
10
|
+
id: companyData.id,
|
|
11
|
+
name: companyData.name,
|
|
12
|
+
email: companyData.email,
|
|
13
|
+
phoneNumber: companyData.phone_number,
|
|
14
|
+
registartionNumber: companyData.registration_number,
|
|
15
|
+
taxNumber: companyData.tax_number,
|
|
16
|
+
swiftNumber: companyData.swift_number,
|
|
17
|
+
regonNumber: companyData.regon_number,
|
|
18
|
+
bankAccountNumber: companyData.bank_account_number,
|
|
19
|
+
bankName: companyData.bank_name,
|
|
20
|
+
address: address
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return {
|
|
25
|
+
id: '',
|
|
26
|
+
name: '',
|
|
27
|
+
email: '',
|
|
28
|
+
phoneNumber: '',
|
|
29
|
+
registartionNumber: '',
|
|
30
|
+
taxNumber: '',
|
|
31
|
+
swiftNumber: '',
|
|
32
|
+
regonNumber: '',
|
|
33
|
+
bankAccountNumber: '',
|
|
34
|
+
bankName: '',
|
|
35
|
+
address: null
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./AddressesReader";
|
|
3
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
4
|
+
export default class CompanyDetailsReader {
|
|
5
|
+
static async get(queryOptions) {
|
|
6
|
+
const companyDetails = await DatabaseConnection.getInstance().companyDetails.select(queryOptions);
|
|
7
|
+
const address = await AddressesReader.get(createQueryOptionsForId(companyDetails.address_id));
|
|
8
|
+
if (companyDetails)
|
|
9
|
+
return {
|
|
10
|
+
id: companyDetails.id,
|
|
11
|
+
name: companyDetails.name,
|
|
12
|
+
taxNumber: companyDetails.tax_number,
|
|
13
|
+
address
|
|
14
|
+
};
|
|
15
|
+
else
|
|
16
|
+
throw Error(`no companyDetails found with queryOptions: ${queryOptions}`);
|
|
17
|
+
}
|
|
18
|
+
}
|