@dascompany/product 1.1.2 → 1.1.4
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/{ProductsSchema.d.ts → DatabaseConnection.d.ts} +4 -3
- package/dist/{ProductsSchema.js → DatabaseConnection.js} +8 -1
- package/dist/SQL.json +4 -4
- package/dist/mappers/AddressMapper.js +2 -2
- package/dist/mappers/AdminMapper.js +2 -2
- package/dist/mappers/ClientMapper.js +2 -2
- package/dist/mappers/CompanyDataMapper.js +2 -2
- package/dist/mappers/CompanyDetailsMapper.js +2 -2
- package/dist/mappers/ContactDetailsMapper.js +2 -2
- package/dist/mappers/DeliveryDetailsMapper.js +2 -2
- package/dist/mappers/DeliveryMethodsMapper.js +2 -2
- package/dist/mappers/DeliveryStatusMapper.js +2 -2
- package/dist/mappers/FileConnectionMapper.js +2 -2
- package/dist/mappers/FileMapper.js +2 -2
- package/dist/mappers/InvoiceDetailsMapper.js +2 -2
- package/dist/mappers/OrderMapper.js +2 -2
- package/dist/mappers/OrderProductMapper.js +2 -2
- package/dist/mappers/PaymentDetailsMapper.js +2 -2
- package/dist/mappers/PaymentMethodsMapper.js +2 -2
- package/dist/mappers/PaymentStatusMapper.js +2 -2
- package/dist/mappers/PersonalDataMapper.js +2 -2
- package/dist/mappers/ProductMapper.js +2 -2
- package/dist/mappers/StatusMapper.js +2 -2
- package/dist/reader/AddressesReader.js +3 -5
- package/dist/reader/AdminReader.js +5 -8
- package/dist/reader/ClientAccountReader.js +6 -10
- package/dist/reader/CompanyDataReader.js +2 -3
- package/dist/reader/CompanyDetailsReader.js +2 -3
- package/dist/reader/ContactDetailsReader.js +2 -3
- package/dist/reader/DeliveryDetailsReader.js +2 -3
- package/dist/reader/DeliveryMethodReader.js +4 -7
- package/dist/reader/DeliveryStatusReader.js +4 -7
- package/dist/reader/FileConnectionsReader.js +2 -3
- package/dist/reader/FilesReader.js +6 -11
- package/dist/reader/InvoiceDetailsReader.js +2 -3
- package/dist/reader/OrderProductsReader.js +3 -5
- package/dist/reader/OrderReader.js +5 -8
- package/dist/reader/OrderStatusReader.js +3 -5
- package/dist/reader/PersonalDataReader.js +2 -3
- package/dist/reader/ProductReader.js +6 -11
- package/dist/reader/StatusTypesReader.js +2 -3
- package/dist/reader/payment/PaymentDetailsReader.js +3 -5
- package/dist/reader/payment/PaymentMethodReader.js +4 -7
- package/dist/reader/payment/PaymentStatusesReader.js +4 -7
- package/dist/repo/AddressesRepo.js +2 -3
- package/dist/repo/AdminRepo.js +5 -8
- package/dist/repo/ClientAccountRepo.js +4 -7
- package/dist/repo/CompanyDataRepo.js +2 -3
- package/dist/repo/CompanyDetailsRepo.js +2 -3
- package/dist/repo/ContactDetailsRepo.js +3 -5
- package/dist/repo/DeliveryDetailsRepo.js +2 -3
- package/dist/repo/DeliveryMethodRepo.js +2 -3
- package/dist/repo/FileConnectionsRepo.js +3 -5
- package/dist/repo/FilesRepo.js +3 -5
- package/dist/repo/InvoiceDetailsRepo.js +2 -3
- package/dist/repo/OrderProductsRepo.js +3 -5
- package/dist/repo/OrderRepo.js +2 -3
- package/dist/repo/OrderStatusRepo.js +3 -5
- package/dist/repo/PaymentDetailsRepo.js +2 -3
- package/dist/repo/PaymentMethodRepo.js +2 -3
- package/dist/repo/PersonalDataRepo.js +2 -3
- package/dist/repo/ProductRepo.js +3 -5
- package/dist/stockObjects/Product.d.ts +4 -1
- package/dist/stockObjects/Product.js +9 -1
- package/dist/tables/public/ProductsTable.js +1 -0
- package/package.json +2 -2
- package/dist/ProductConnectionFactory.d.ts +0 -6
- package/dist/ProductConnectionFactory.js +0 -11
- package/dist/ProductServiceConnection.d.ts +0 -9
- package/dist/ProductServiceConnection.js +0 -16
- package/dist/tables/SchemaNames.d.ts +0 -4
- package/dist/tables/SchemaNames.js +0 -5
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import OrderProductsReader from "./OrderProductsReader";
|
|
3
3
|
import OrderStatusReader from "./OrderStatusReader";
|
|
4
4
|
export default class OrderReader {
|
|
5
5
|
static async get(orderId) {
|
|
6
|
-
const
|
|
7
|
-
const orderData = await connection.productsSchema.orders.select(orderId);
|
|
6
|
+
const orderData = await DatabaseConnection.getInstance().orders.select(orderId);
|
|
8
7
|
return this.correctOrder(orderData);
|
|
9
8
|
}
|
|
10
9
|
static async getForClient(clientAccountId) {
|
|
11
|
-
const
|
|
12
|
-
const orders = await connection.productsSchema.orders.selectForClient(clientAccountId);
|
|
10
|
+
const orders = await DatabaseConnection.getInstance().orders.selectForClient(clientAccountId);
|
|
13
11
|
const correctOrders = [];
|
|
14
12
|
for (let i = 0; i < orders.length; i++) {
|
|
15
13
|
const correctOrder = await this.correctOrder(orders[i]);
|
|
@@ -19,9 +17,8 @@ export default class OrderReader {
|
|
|
19
17
|
return correctOrders;
|
|
20
18
|
}
|
|
21
19
|
static async getAll(queryOptions) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const quantity = await connection.productsSchema.orders.count(queryOptions);
|
|
20
|
+
const orderRows = await DatabaseConnection.getInstance().orders.selectAll(queryOptions);
|
|
21
|
+
const quantity = await DatabaseConnection.getInstance().orders.count(queryOptions);
|
|
25
22
|
const orders = await this.correctOrders(orderRows);
|
|
26
23
|
return { orders, quantity };
|
|
27
24
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
export default class OrderStatusReader {
|
|
3
3
|
static async get(orderId) {
|
|
4
|
-
const
|
|
5
|
-
const statusRow = await connection.productsSchema.statuses.select(orderId);
|
|
4
|
+
const statusRow = await DatabaseConnection.getInstance().statuses.select(orderId);
|
|
6
5
|
return this.correctStatus(statusRow);
|
|
7
6
|
}
|
|
8
7
|
static async getAll(orderId) {
|
|
9
|
-
const
|
|
10
|
-
const statuses = await connection.productsSchema.statuses.selectAll(orderId);
|
|
8
|
+
const statuses = await DatabaseConnection.getInstance().statuses.selectAll(orderId);
|
|
11
9
|
const correctStatuss = [];
|
|
12
10
|
for (let i = 0; i < statuses.length; i++) {
|
|
13
11
|
const correctStatus = this.correctStatus(statuses[i]);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import correctPhoneNumber from "../utils/correctPhoneNumber";
|
|
3
3
|
import CompanyDetailsReader from "./CompanyDetailsReader";
|
|
4
4
|
export default class PersonalDataReader {
|
|
5
5
|
static async get(personalDataId) {
|
|
6
|
-
const
|
|
7
|
-
const personalDataRow = await connection.productsSchema.personalData.select(personalDataId);
|
|
6
|
+
const personalDataRow = await DatabaseConnection.getInstance().personalData.select(personalDataId);
|
|
8
7
|
const personalData = this.correctPersonalData(personalDataRow);
|
|
9
8
|
if (personalDataRow.company_details_id) {
|
|
10
9
|
personalData.companyDetails = await CompanyDetailsReader.get(personalDataRow.company_details_id);
|
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
import ProductConnectionFactory from "../ProductConnectionFactory";
|
|
2
1
|
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
3
2
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
4
3
|
import FilesReader from "./FilesReader";
|
|
4
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
5
5
|
export default class ProductReader {
|
|
6
6
|
static async get(productId) {
|
|
7
|
-
const
|
|
8
|
-
const product = await connection.productsSchema.products.select(productId);
|
|
7
|
+
const product = await DatabaseConnection.getInstance().products.select(productId);
|
|
9
8
|
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
10
9
|
return this.correctProduct(product, files);
|
|
11
10
|
}
|
|
12
11
|
static async getForUrl(productUrl) {
|
|
13
|
-
const
|
|
14
|
-
const product = await connection.productsSchema.products.selectForUrl(productUrl);
|
|
12
|
+
const product = await DatabaseConnection.getInstance().products.selectForUrl(productUrl);
|
|
15
13
|
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
16
14
|
return this.correctProduct(product, files);
|
|
17
15
|
}
|
|
18
16
|
static async getAllActive(queryOptions) {
|
|
19
|
-
const
|
|
20
|
-
const products = await connection.productsSchema.products.selectAllActive(queryOptions);
|
|
17
|
+
const products = await DatabaseConnection.getInstance().products.selectAllActive(queryOptions);
|
|
21
18
|
return this.correctProducts(products);
|
|
22
19
|
}
|
|
23
20
|
static async getIdForSku(productSku) {
|
|
24
|
-
|
|
25
|
-
return await connection.productsSchema.products.selectIdForSku(productSku);
|
|
21
|
+
return await DatabaseConnection.getInstance().products.selectIdForSku(productSku);
|
|
26
22
|
}
|
|
27
23
|
static async getQuantity(queryOptions) {
|
|
28
|
-
const
|
|
29
|
-
const quantity = await connection.productsSchema.products.count(queryOptions);
|
|
24
|
+
const quantity = await DatabaseConnection.getInstance().products.count(queryOptions);
|
|
30
25
|
return quantity;
|
|
31
26
|
}
|
|
32
27
|
static async correctProducts(products) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
export default class StatusTypesReader {
|
|
3
3
|
static async get() {
|
|
4
|
-
const
|
|
5
|
-
const statusTypes = await connection.productsSchema.statusTypes.select();
|
|
4
|
+
const statusTypes = await DatabaseConnection.getInstance().statusTypes.select();
|
|
6
5
|
return statusTypes;
|
|
7
6
|
}
|
|
8
7
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
2
|
import PaymentMethodReader from "./PaymentMethodReader";
|
|
3
3
|
import PaymentStatusesReader from "./PaymentStatusesReader";
|
|
4
4
|
export default class PaymentDetailsReader {
|
|
5
5
|
static async get(paymentDetailsId) {
|
|
6
|
-
const
|
|
7
|
-
const paymentDetails = await connection.productsSchema.paymentDetails.select(paymentDetailsId);
|
|
6
|
+
const paymentDetails = await DatabaseConnection.getInstance().paymentDetails.select(paymentDetailsId);
|
|
8
7
|
return await this.correctPaymentDetails(paymentDetails);
|
|
9
8
|
}
|
|
10
9
|
static async getPaymentOrderId(paymentDetailsId) {
|
|
11
|
-
const
|
|
12
|
-
const paymentDetails = await connection.productsSchema.paymentDetails.select(paymentDetailsId);
|
|
10
|
+
const paymentDetails = await DatabaseConnection.getInstance().paymentDetails.select(paymentDetailsId);
|
|
13
11
|
return paymentDetails.payment_order_id;
|
|
14
12
|
}
|
|
15
13
|
static async correctPaymentDetails(paymentDetails) {
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
2
|
export default class PaymentMethodReader {
|
|
3
3
|
static async get(paymentMethodId) {
|
|
4
|
-
const
|
|
5
|
-
const paymentMethod = await connection.productsSchema.paymentMethods.select(paymentMethodId);
|
|
4
|
+
const paymentMethod = await DatabaseConnection.getInstance().paymentMethods.select(paymentMethodId);
|
|
6
5
|
return paymentMethod;
|
|
7
6
|
}
|
|
8
7
|
static async getAll() {
|
|
9
|
-
const
|
|
10
|
-
const paymentMethods = await connection.productsSchema.paymentMethods.selectAll();
|
|
8
|
+
const paymentMethods = await DatabaseConnection.getInstance().paymentMethods.selectAll();
|
|
11
9
|
return paymentMethods;
|
|
12
10
|
}
|
|
13
11
|
static async getAllActive() {
|
|
14
|
-
const
|
|
15
|
-
const paymentMethods = await connection.productsSchema.paymentMethods.selectAllActive();
|
|
12
|
+
const paymentMethods = await DatabaseConnection.getInstance().paymentMethods.selectAllActive();
|
|
16
13
|
return paymentMethods;
|
|
17
14
|
}
|
|
18
15
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
2
|
export default class PaymentStatusesReader {
|
|
3
3
|
static async get(paymentDetailsId) {
|
|
4
|
-
const
|
|
5
|
-
const paymentStatus = await connection.productsSchema.paymentStatuses.select(paymentDetailsId);
|
|
4
|
+
const paymentStatus = await DatabaseConnection.getInstance().paymentStatuses.select(paymentDetailsId);
|
|
6
5
|
if (paymentStatus)
|
|
7
6
|
return await this.correctPaymentStatus(paymentStatus);
|
|
8
7
|
else
|
|
9
8
|
return {};
|
|
10
9
|
}
|
|
11
10
|
static async getAll(paymentDetailsId) {
|
|
12
|
-
const
|
|
13
|
-
const paymentStatusesData = await connection.productsSchema.paymentStatuses.selectAll(paymentDetailsId);
|
|
11
|
+
const paymentStatusesData = await DatabaseConnection.getInstance().paymentStatuses.selectAll(paymentDetailsId);
|
|
14
12
|
const paymentStatuses = [];
|
|
15
13
|
for (let i = 0; i < paymentStatusesData.length; i++) {
|
|
16
14
|
const paymentStatus = await this.correctPaymentStatus(paymentStatusesData[i]);
|
|
@@ -19,8 +17,7 @@ export default class PaymentStatusesReader {
|
|
|
19
17
|
return paymentStatuses;
|
|
20
18
|
}
|
|
21
19
|
static async correctPaymentStatus(paymentStatus) {
|
|
22
|
-
const
|
|
23
|
-
const paymentStatusType = await connection.productsSchema.paymentStatusTypes.select(paymentStatus.payment_status_type_id);
|
|
20
|
+
const paymentStatusType = await DatabaseConnection.getInstance().paymentStatusTypes.select(paymentStatus.payment_status_type_id);
|
|
24
21
|
return {
|
|
25
22
|
id: paymentStatus.id,
|
|
26
23
|
type: paymentStatusType,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Address from "../stockObjects/Address";
|
|
3
3
|
export default class AddressesRepo {
|
|
4
4
|
static async get(addressId) {
|
|
5
|
-
const
|
|
6
|
-
const address = await connection.productsSchema.addresses.select(addressId);
|
|
5
|
+
const address = await DatabaseConnection.getInstance().addresses.select(addressId);
|
|
7
6
|
return this.createAddressFromRow(address);
|
|
8
7
|
}
|
|
9
8
|
static createAddressFromRow(dataRow) {
|
package/dist/repo/AdminRepo.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Admin from "../stockObjects/Admin";
|
|
3
3
|
export default class AdminRepo {
|
|
4
4
|
static async get(accountId) {
|
|
5
|
-
const
|
|
6
|
-
const account = await connection.productsSchema.adminAccounts.select(accountId);
|
|
5
|
+
const account = await DatabaseConnection.getInstance().adminAccounts.select(accountId);
|
|
7
6
|
return this.createAdminFromRow(account);
|
|
8
7
|
}
|
|
9
8
|
static async getIdForEmail(email) {
|
|
10
|
-
|
|
11
|
-
return await connection.productsSchema.adminAccounts.selectForEmail(email);
|
|
9
|
+
return await DatabaseConnection.getInstance().adminAccounts.selectForEmail(email);
|
|
12
10
|
}
|
|
13
11
|
static async getAll(queryOptions) {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const quantity = await connection.productsSchema.adminAccounts.count(queryOptions);
|
|
12
|
+
const adminAccounts = await DatabaseConnection.getInstance().adminAccounts.selectAll(queryOptions);
|
|
13
|
+
const quantity = await DatabaseConnection.getInstance().adminAccounts.count(queryOptions);
|
|
17
14
|
return { adminAccounts: this.createAdminsFromRows(adminAccounts), quantity };
|
|
18
15
|
}
|
|
19
16
|
static createAdminsFromRows(dataRows) {
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Client from "../stockObjects/Client";
|
|
3
3
|
export default class ClientAccountRepo {
|
|
4
4
|
static async get(accountId) {
|
|
5
|
-
const
|
|
6
|
-
const accountData = await connection.productsSchema.clientAccounts.select(accountId);
|
|
5
|
+
const accountData = await DatabaseConnection.getInstance().clientAccounts.select(accountId);
|
|
7
6
|
return this.createCilentAccountFromRow(accountData);
|
|
8
7
|
}
|
|
9
8
|
static async getById(clientId) {
|
|
10
|
-
const
|
|
11
|
-
const client = await connection.productsSchema.clientAccounts.select(clientId);
|
|
9
|
+
const client = await DatabaseConnection.getInstance().clientAccounts.select(clientId);
|
|
12
10
|
return this.createCilentAccountFromRow(client);
|
|
13
11
|
}
|
|
14
12
|
static async getEmailForId(clientId) {
|
|
15
|
-
const
|
|
16
|
-
const email = await connection.productsSchema.clientAccounts.selectEmail(clientId);
|
|
13
|
+
const email = await DatabaseConnection.getInstance().clientAccounts.selectEmail(clientId);
|
|
17
14
|
return email;
|
|
18
15
|
}
|
|
19
16
|
static createCilentAccountFromRow(accountData) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import CompanyData from "../stockObjects/CompanyData";
|
|
3
3
|
export default class CompanyDataRepo {
|
|
4
4
|
static async get() {
|
|
5
|
-
const
|
|
6
|
-
const companyDataRow = await connection.productsSchema.companyData.select();
|
|
5
|
+
const companyDataRow = await DatabaseConnection.getInstance().companyData.select();
|
|
7
6
|
const companyData = new CompanyData(companyDataRow.name, companyDataRow.tax_number, companyDataRow.phone_number, companyDataRow.email, companyDataRow.address_id);
|
|
8
7
|
companyData.setId(companyDataRow.id);
|
|
9
8
|
return companyData;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import CompanyDetails from "../stockObjects/CompanyDetails";
|
|
3
3
|
export default class CompanyDetailsRepo {
|
|
4
4
|
static async get(id) {
|
|
5
|
-
const
|
|
6
|
-
const companyDetailsRow = await connection.productsSchema.companyDetails.select(id);
|
|
5
|
+
const companyDetailsRow = await DatabaseConnection.getInstance().companyDetails.select(id);
|
|
7
6
|
return this.createCompanyDetailsFromRow(companyDetailsRow);
|
|
8
7
|
}
|
|
9
8
|
static createCompanyDetailsFromRow(companyDetailsRow) {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import ContactDetails from "../stockObjects/ContactDetails";
|
|
3
3
|
export default class ContactDetailsRepo {
|
|
4
4
|
static async get(contactDetailsId) {
|
|
5
|
-
const
|
|
6
|
-
const contactDetailsRow = await connection.productsSchema.contactDetails.select(contactDetailsId);
|
|
5
|
+
const contactDetailsRow = await DatabaseConnection.getInstance().contactDetails.select(contactDetailsId);
|
|
7
6
|
return this.createContactDetailsFromRow(contactDetailsRow);
|
|
8
7
|
}
|
|
9
8
|
static async getNextId() {
|
|
10
|
-
const
|
|
11
|
-
const contactDetails = await connection.productsSchema.contactDetails.selectNextId();
|
|
9
|
+
const contactDetails = await DatabaseConnection.getInstance().contactDetails.selectNextId();
|
|
12
10
|
return contactDetails;
|
|
13
11
|
}
|
|
14
12
|
static createContactDetailsFromRow(contactDetailsRow) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import DeliveryDetails from "../stockObjects/DeliveryDetails";
|
|
3
3
|
export default class DeliveryDetailsRepo {
|
|
4
4
|
static async get(deliveryDetailsId) {
|
|
5
|
-
const
|
|
6
|
-
const deliveryDetailsRow = await connection.productsSchema.deliveryDetails.select(deliveryDetailsId);
|
|
5
|
+
const deliveryDetailsRow = await DatabaseConnection.getInstance().deliveryDetails.select(deliveryDetailsId);
|
|
7
6
|
return this.createDeliveryDetailsFromRow(deliveryDetailsRow);
|
|
8
7
|
}
|
|
9
8
|
static createDeliveryDetailsFromRow(deliveryDetailsRow) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import DeliveryMethods from "../stockObjects/DeliveryMethods";
|
|
3
3
|
export default class DeliveryMethodRepo {
|
|
4
4
|
static async get(id) {
|
|
5
|
-
const
|
|
6
|
-
const deliveryMethodsRow = await connection.productsSchema.deliveryMethods.select(id);
|
|
5
|
+
const deliveryMethodsRow = await DatabaseConnection.getInstance().deliveryMethods.select(id);
|
|
7
6
|
const deliveryMethods = new DeliveryMethods(deliveryMethodsRow.key, deliveryMethodsRow.active);
|
|
8
7
|
deliveryMethods.setId(deliveryMethodsRow.id);
|
|
9
8
|
return deliveryMethods;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import FileConnection from "../stockObjects/FileConnection";
|
|
3
3
|
export default class FileConnectionsRepo {
|
|
4
4
|
static async getAllForFileId(fileId) {
|
|
5
|
-
const
|
|
6
|
-
const fileConnections = await connection.productsSchema.fileConnections.selectForFileId(fileId);
|
|
5
|
+
const fileConnections = await DatabaseConnection.getInstance().fileConnections.selectForFileId(fileId);
|
|
7
6
|
return this.correctFileConnections(fileConnections);
|
|
8
7
|
}
|
|
9
8
|
static async deleteAllForConnection(connectionType, connectionId) {
|
|
10
|
-
|
|
11
|
-
return await connection.productsSchema.fileConnections.deleteForConnection(connectionType, connectionId);
|
|
9
|
+
return await DatabaseConnection.getInstance().fileConnections.deleteForConnection(connectionType, connectionId);
|
|
12
10
|
}
|
|
13
11
|
static correctFileConnections(dataRows) {
|
|
14
12
|
const fileConnections = [];
|
package/dist/repo/FilesRepo.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import File from "../stockObjects/File";
|
|
3
3
|
export default class FilesRepo {
|
|
4
4
|
static async get(fileId) {
|
|
5
|
-
const
|
|
6
|
-
const file = await connection.productsSchema.files.select(fileId);
|
|
5
|
+
const file = await DatabaseConnection.getInstance().files.select(fileId);
|
|
7
6
|
return this.createFileFromRow(file);
|
|
8
7
|
}
|
|
9
8
|
static async getAllForConnection(connectionType, connectionId) {
|
|
10
|
-
const
|
|
11
|
-
const files = await connection.productsSchema.files.selectForConnection(connectionType, connectionId);
|
|
9
|
+
const files = await DatabaseConnection.getInstance().files.selectForConnection(connectionType, connectionId);
|
|
12
10
|
return this.createFilesFromRows(files);
|
|
13
11
|
}
|
|
14
12
|
static async createFilesFromRows(dataRows) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import InvoiceDetails from "../stockObjects/InvoiceDetails";
|
|
3
3
|
export default class InvoiceDetailsRepo {
|
|
4
4
|
static async get(invoiceDetailsId) {
|
|
5
|
-
const
|
|
6
|
-
const invoiceDetailsRow = await connection.productsSchema.invoiceDetails.select(invoiceDetailsId);
|
|
5
|
+
const invoiceDetailsRow = await DatabaseConnection.getInstance().invoiceDetails.select(invoiceDetailsId);
|
|
7
6
|
return this.createInvoiceDetailsFromRow(invoiceDetailsRow);
|
|
8
7
|
}
|
|
9
8
|
static createInvoiceDetailsFromRow(invoiceDetailsRow) {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ConnectorE, ParameterType } from "@dascompany/database";
|
|
2
|
-
import
|
|
2
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
3
3
|
import OrderProduct from "../stockObjects/OrderProduct";
|
|
4
4
|
export default class OrderProductsRepo {
|
|
5
5
|
static async getAllActive(orderId) {
|
|
6
|
-
const
|
|
7
|
-
const orderProducts = await connection.productsSchema.ordersProducts.selectAllActive(orderId);
|
|
6
|
+
const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAllActive(orderId);
|
|
8
7
|
return this.createOrdersProductsFromRows(orderProducts);
|
|
9
8
|
}
|
|
10
9
|
static async getAllForIds(orderProductsIds) {
|
|
11
|
-
const connection = ProductConnectionFactory.get();
|
|
12
10
|
const queryOptions = {
|
|
13
11
|
where: {
|
|
14
12
|
connector: ConnectorE.and,
|
|
@@ -17,7 +15,7 @@ export default class OrderProductsRepo {
|
|
|
17
15
|
]
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
|
-
const orderProducts = await
|
|
18
|
+
const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAllForIds(queryOptions);
|
|
21
19
|
return this.createOrdersProductsFromRows(orderProducts);
|
|
22
20
|
}
|
|
23
21
|
static async createOrdersProductsFromRows(dataRows) {
|
package/dist/repo/OrderRepo.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Order from "../stockObjects/Order";
|
|
3
3
|
export default class OrderRepo {
|
|
4
4
|
static async get(orderId) {
|
|
5
|
-
const
|
|
6
|
-
const orderData = await connection.productsSchema.orders.select(orderId);
|
|
5
|
+
const orderData = await DatabaseConnection.getInstance().orders.select(orderId);
|
|
7
6
|
return this.createOrderFromRow(orderData);
|
|
8
7
|
}
|
|
9
8
|
static createOrderFromRow(orderData) {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Status from "../stockObjects/Status";
|
|
3
3
|
export default class OrderStatusRepo {
|
|
4
4
|
static async get(orderId) {
|
|
5
|
-
const
|
|
6
|
-
const status = await connection.productsSchema.statuses.select(orderId);
|
|
5
|
+
const status = await DatabaseConnection.getInstance().statuses.select(orderId);
|
|
7
6
|
return this.createStatusFromRow(status);
|
|
8
7
|
}
|
|
9
8
|
static async getAll(orderId) {
|
|
10
|
-
const
|
|
11
|
-
const statuses = await connection.productsSchema.statuses.selectAll(orderId);
|
|
9
|
+
const statuses = await DatabaseConnection.getInstance().statuses.selectAll(orderId);
|
|
12
10
|
return this.createStatusesFromRows(statuses);
|
|
13
11
|
}
|
|
14
12
|
static async createStatusesFromRows(dataRows) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import PaymentDetails from "../stockObjects/PaymentDetails";
|
|
3
3
|
export default class PaymentDetailsRepo {
|
|
4
4
|
static async get(paymentDetailsId) {
|
|
5
|
-
const
|
|
6
|
-
const paymentDetailsRow = await connection.productsSchema.paymentDetails.select(paymentDetailsId);
|
|
5
|
+
const paymentDetailsRow = await DatabaseConnection.getInstance().paymentDetails.select(paymentDetailsId);
|
|
7
6
|
return this.createPaymentDetailsFromRow(paymentDetailsRow);
|
|
8
7
|
}
|
|
9
8
|
static createPaymentDetailsFromRow(paymentDetailsRow) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import PaymentMethods from "../stockObjects/PaymentMethods";
|
|
3
3
|
export default class PaymentMethodRepo {
|
|
4
4
|
static async get(id) {
|
|
5
|
-
const
|
|
6
|
-
const paymentMethodsRow = await connection.productsSchema.paymentMethods.select(id);
|
|
5
|
+
const paymentMethodsRow = await DatabaseConnection.getInstance().paymentMethods.select(id);
|
|
7
6
|
const paymentMethods = new PaymentMethods(paymentMethodsRow.key, paymentMethodsRow.active);
|
|
8
7
|
paymentMethods.setId(paymentMethodsRow.id);
|
|
9
8
|
return paymentMethods;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import PersonalData from "../stockObjects/PersonalData";
|
|
3
3
|
import correctPhoneNumber from "../utils/correctPhoneNumber";
|
|
4
4
|
export default class PersonalDataRepo {
|
|
5
5
|
static async get(personalDataId) {
|
|
6
|
-
const
|
|
7
|
-
const personalData = await connection.productsSchema.personalData.select(personalDataId);
|
|
6
|
+
const personalData = await DatabaseConnection.getInstance().personalData.select(personalDataId);
|
|
8
7
|
return this.createPersonalDataFromRow(personalData);
|
|
9
8
|
}
|
|
10
9
|
static createPersonalDataFromRow(dataRow) {
|
package/dist/repo/ProductRepo.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import Product from "../stockObjects/Product";
|
|
2
|
-
import
|
|
2
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
3
3
|
export default class ProductRepo {
|
|
4
4
|
static async get(productId) {
|
|
5
|
-
const
|
|
6
|
-
const product = await connection.productsSchema.products.select(productId);
|
|
5
|
+
const product = await DatabaseConnection.getInstance().products.select(productId);
|
|
7
6
|
return this.createProductFromRow(product);
|
|
8
7
|
}
|
|
9
8
|
static async getForSku(productSku) {
|
|
10
|
-
const
|
|
11
|
-
const product = await connection.productsSchema.products.selectForSku(productSku);
|
|
9
|
+
const product = await DatabaseConnection.getInstance().products.selectForSku(productSku);
|
|
12
10
|
return this.createProductFromRow(product);
|
|
13
11
|
}
|
|
14
12
|
static createProductFromRow(productRow) {
|
|
@@ -16,8 +16,9 @@ export default class Product extends StockObject {
|
|
|
16
16
|
private deleted;
|
|
17
17
|
private createdAt;
|
|
18
18
|
private file;
|
|
19
|
+
private jsonData;
|
|
19
20
|
private files;
|
|
20
|
-
constructor(sku: string, url: string, title: string, description: string, netPrice: number, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, deleted?: boolean);
|
|
21
|
+
constructor(sku: string, url: string, title: string, description: string, netPrice: number, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, jsonData: any, deleted?: boolean);
|
|
21
22
|
getSku(): string;
|
|
22
23
|
getUrl(): string;
|
|
23
24
|
getTitle(): string;
|
|
@@ -31,6 +32,7 @@ export default class Product extends StockObject {
|
|
|
31
32
|
getLength(): number;
|
|
32
33
|
getHeight(): number;
|
|
33
34
|
getFileId(): number;
|
|
35
|
+
getJsonData(): any;
|
|
34
36
|
getDeleted(): boolean;
|
|
35
37
|
getFile(): Promise<FileI | null>;
|
|
36
38
|
getFiles(): Promise<FileI[] | null>;
|
|
@@ -64,6 +66,7 @@ export default class Product extends StockObject {
|
|
|
64
66
|
setLength(length: number): number;
|
|
65
67
|
setHeight(height: number): number;
|
|
66
68
|
setFileId(fileId: number): number;
|
|
69
|
+
setJsonData(jsonData: any): any;
|
|
67
70
|
setDeleted(deleted: boolean): boolean;
|
|
68
71
|
protected getMapper(): StockObjectMapper;
|
|
69
72
|
}
|
|
@@ -19,8 +19,9 @@ export default class Product extends StockObject {
|
|
|
19
19
|
deleted;
|
|
20
20
|
createdAt;
|
|
21
21
|
file;
|
|
22
|
+
jsonData;
|
|
22
23
|
files;
|
|
23
|
-
constructor(sku, url, title, description, netPrice, vat, color, quantity, width, length, height, fileId, deleted = false) {
|
|
24
|
+
constructor(sku, url, title, description, netPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
|
|
24
25
|
super();
|
|
25
26
|
this.sku = sku;
|
|
26
27
|
this.url = url;
|
|
@@ -34,6 +35,7 @@ export default class Product extends StockObject {
|
|
|
34
35
|
this.length = length;
|
|
35
36
|
this.height = height;
|
|
36
37
|
this.fileId = fileId;
|
|
38
|
+
this.jsonData = jsonData;
|
|
37
39
|
this.deleted = deleted;
|
|
38
40
|
this.createdAt = null;
|
|
39
41
|
this.file = null;
|
|
@@ -78,6 +80,9 @@ export default class Product extends StockObject {
|
|
|
78
80
|
getFileId() {
|
|
79
81
|
return this.fileId;
|
|
80
82
|
}
|
|
83
|
+
getJsonData() {
|
|
84
|
+
return this.jsonData;
|
|
85
|
+
}
|
|
81
86
|
getDeleted() {
|
|
82
87
|
return this.deleted;
|
|
83
88
|
}
|
|
@@ -154,6 +159,9 @@ export default class Product extends StockObject {
|
|
|
154
159
|
setFileId(fileId) {
|
|
155
160
|
return this.fileId = fileId;
|
|
156
161
|
}
|
|
162
|
+
setJsonData(jsonData) {
|
|
163
|
+
return this.jsonData = jsonData;
|
|
164
|
+
}
|
|
157
165
|
setDeleted(deleted) {
|
|
158
166
|
return this.deleted = deleted;
|
|
159
167
|
}
|
|
@@ -80,6 +80,7 @@ export default class ProductsTable extends Table {
|
|
|
80
80
|
query.bindParameter('length', productData.getLength());
|
|
81
81
|
query.bindParameter('height', productData.getHeight());
|
|
82
82
|
query.bindParameter('file_id', productData.getFileId());
|
|
83
|
+
query.bindParameter('json_data', productData.getJsonData());
|
|
83
84
|
}
|
|
84
85
|
async selectNextId() {
|
|
85
86
|
const query = this.createQuery(SQL.products.selectNextId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dascompany/product",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"vitest": "^3.0.6"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@dascompany/database": "^2.1.
|
|
23
|
+
"@dascompany/database": "^2.1.3",
|
|
24
24
|
"@types/pg": "^8.11.11",
|
|
25
25
|
"pg": "^8.13.3"
|
|
26
26
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ConnectionFactory } from '@dascompany/database';
|
|
2
|
-
import ProductServiceConnection from './ProductServiceConnection';
|
|
3
|
-
export default class ProductConnectionFactory extends ConnectionFactory {
|
|
4
|
-
private static subdomain;
|
|
5
|
-
static get(): ProductServiceConnection;
|
|
6
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ConnectionFactory } from '@dascompany/database';
|
|
2
|
-
import ProductsSchema from './ProductsSchema';
|
|
3
|
-
export default class ProductConnectionFactory extends ConnectionFactory {
|
|
4
|
-
static subdomain = 'defaultDatabaseName';
|
|
5
|
-
static get() {
|
|
6
|
-
const connection = super.get(this.subdomain);
|
|
7
|
-
if (!connection.productsSchema)
|
|
8
|
-
connection.productsSchema = new ProductsSchema(connection);
|
|
9
|
-
return connection;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Client } from 'pg';
|
|
2
|
-
import { Connection } from '@dascompany/database';
|
|
3
|
-
import ProductsSchema from './ProductsSchema';
|
|
4
|
-
export default class ProductServiceConnection extends Connection {
|
|
5
|
-
private tables;
|
|
6
|
-
constructor(pgClient: Client);
|
|
7
|
-
get productsSchema(): ProductsSchema;
|
|
8
|
-
set productsSchema(tables: ProductsSchema);
|
|
9
|
-
}
|