@dascompany/database 3.0.0 → 3.0.2
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 +11 -0
- package/dist/DatabaseConnection.js +28 -0
- package/dist/SQL.json +169 -0
- package/dist/TableConnection.d.ts +74 -0
- package/dist/TableConnection.js +144 -0
- package/dist/mappers/AddressMapper.d.ts +9 -0
- package/dist/mappers/AddressMapper.js +17 -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 +22 -0
- package/dist/mappers/ContactDetailsMapper.d.ts +9 -0
- package/dist/mappers/ContactDetailsMapper.js +18 -0
- package/dist/mappers/DeliveryDetailsMapper.d.ts +9 -0
- package/dist/mappers/DeliveryDetailsMapper.js +17 -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 +17 -0
- package/dist/mappers/FileMapper.d.ts +9 -0
- package/dist/mappers/FileMapper.js +17 -0
- package/dist/mappers/InvoiceDetailsMapper.d.ts +9 -0
- package/dist/mappers/InvoiceDetailsMapper.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 +15 -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 +17 -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/query/QueryParamCreator.js +2 -0
- package/dist/query/QueryParams.js +5 -3
- package/dist/reader/AddressesReader.d.ts +6 -0
- package/dist/reader/AddressesReader.js +24 -0
- package/dist/reader/ClientAccountReader.d.ts +13 -0
- package/dist/reader/ClientAccountReader.js +47 -0
- package/dist/reader/CompanyDataReader.d.ts +4 -0
- package/dist/reader/CompanyDataReader.js +27 -0
- package/dist/reader/CompanyDetailsReader.d.ts +4 -0
- package/dist/reader/CompanyDetailsReader.js +15 -0
- package/dist/reader/ContactDetailsReader.d.ts +4 -0
- package/dist/reader/ContactDetailsReader.js +16 -0
- package/dist/reader/DeliveryDetailsReader.d.ts +4 -0
- package/dist/reader/DeliveryDetailsReader.js +31 -0
- package/dist/reader/DeliveryMethodReader.d.ts +6 -0
- package/dist/reader/DeliveryMethodReader.js +18 -0
- package/dist/reader/DeliveryStatusReader.d.ts +5 -0
- package/dist/reader/DeliveryStatusReader.js +31 -0
- package/dist/reader/FileConnectionsReader.d.ts +6 -0
- package/dist/reader/FileConnectionsReader.js +25 -0
- package/dist/reader/FilesReader.d.ts +12 -0
- package/dist/reader/FilesReader.js +45 -0
- package/dist/reader/InvoiceDetailsReader.d.ts +4 -0
- package/dist/reader/InvoiceDetailsReader.js +21 -0
- package/dist/reader/OrderProductsReader.d.ts +10 -0
- package/dist/reader/OrderProductsReader.js +92 -0
- package/dist/reader/OrderReader.d.ts +12 -0
- package/dist/reader/OrderReader.js +51 -0
- package/dist/reader/OrderStatusReader.d.ts +6 -0
- package/dist/reader/OrderStatusReader.js +28 -0
- package/dist/reader/PersonalDataReader.d.ts +5 -0
- package/dist/reader/PersonalDataReader.js +27 -0
- package/dist/reader/ProductReader.d.ts +13 -0
- package/dist/reader/ProductReader.js +81 -0
- package/dist/reader/StatusTypesReader.d.ts +3 -0
- package/dist/reader/StatusTypesReader.js +8 -0
- package/dist/reader/payment/PaymentDetailsReader.d.ts +5 -0
- package/dist/reader/payment/PaymentDetailsReader.js +27 -0
- package/dist/reader/payment/PaymentMethodReader.d.ts +6 -0
- package/dist/reader/payment/PaymentMethodReader.js +18 -0
- package/dist/reader/payment/PaymentStatusesReader.d.ts +5 -0
- package/dist/reader/payment/PaymentStatusesReader.js +30 -0
- package/dist/repo/AddressesRepo.d.ts +5 -0
- package/dist/repo/AddressesRepo.js +14 -0
- package/dist/repo/AdminRepo.d.ts +12 -0
- package/dist/repo/AdminRepo.js +32 -0
- package/dist/repo/ClientAccountRepo.d.ts +7 -0
- package/dist/repo/ClientAccountRepo.js +24 -0
- package/dist/repo/CompanyDataRepo.d.ts +4 -0
- package/dist/repo/CompanyDataRepo.js +11 -0
- package/dist/repo/CompanyDetailsRepo.d.ts +5 -0
- package/dist/repo/CompanyDetailsRepo.js +14 -0
- package/dist/repo/ContactDetailsRepo.d.ts +6 -0
- package/dist/repo/ContactDetailsRepo.js +19 -0
- package/dist/repo/DeliveryDetailsRepo.d.ts +5 -0
- package/dist/repo/DeliveryDetailsRepo.js +14 -0
- package/dist/repo/DeliveryMethodRepo.d.ts +4 -0
- package/dist/repo/DeliveryMethodRepo.js +11 -0
- package/dist/repo/FileConnectionsRepo.d.ts +7 -0
- package/dist/repo/FileConnectionsRepo.js +25 -0
- package/dist/repo/FilesRepo.d.ts +7 -0
- package/dist/repo/FilesRepo.js +26 -0
- package/dist/repo/InvoiceDetailsRepo.d.ts +5 -0
- package/dist/repo/InvoiceDetailsRepo.js +14 -0
- package/dist/repo/OrderProductsRepo.d.ts +7 -0
- package/dist/repo/OrderProductsRepo.js +37 -0
- package/dist/repo/OrderRepo.d.ts +5 -0
- package/dist/repo/OrderRepo.js +14 -0
- package/dist/repo/OrderStatusRepo.d.ts +7 -0
- package/dist/repo/OrderStatusRepo.js +27 -0
- package/dist/repo/PaymentDetailsRepo.d.ts +5 -0
- package/dist/repo/PaymentDetailsRepo.js +14 -0
- package/dist/repo/PaymentMethodRepo.d.ts +4 -0
- package/dist/repo/PaymentMethodRepo.js +11 -0
- package/dist/repo/PersonalDataRepo.d.ts +5 -0
- package/dist/repo/PersonalDataRepo.js +16 -0
- package/dist/repo/ProductRepo.d.ts +6 -0
- package/dist/repo/ProductRepo.js +21 -0
- package/dist/stockObjects/Address.d.ts +33 -0
- package/dist/stockObjects/Address.js +69 -0
- package/dist/stockObjects/Admin.d.ts +25 -0
- package/dist/stockObjects/Admin.js +57 -0
- package/dist/stockObjects/Client.d.ts +24 -0
- package/dist/stockObjects/Client.js +57 -0
- package/dist/stockObjects/CompanyData.d.ts +21 -0
- package/dist/stockObjects/CompanyData.js +51 -0
- package/dist/stockObjects/CompanyDetails.d.ts +17 -0
- package/dist/stockObjects/CompanyDetails.js +34 -0
- package/dist/stockObjects/ContactDetails.d.ts +12 -0
- package/dist/stockObjects/ContactDetails.js +26 -0
- package/dist/stockObjects/DeliveryDetails.d.ts +16 -0
- package/dist/stockObjects/DeliveryDetails.js +37 -0
- package/dist/stockObjects/DeliveryMethods.d.ts +12 -0
- package/dist/stockObjects/DeliveryMethods.js +26 -0
- package/dist/stockObjects/DeliveryStatus.d.ts +18 -0
- package/dist/stockObjects/DeliveryStatus.js +42 -0
- package/dist/stockObjects/File.d.ts +21 -0
- package/dist/stockObjects/File.js +50 -0
- package/dist/stockObjects/FileConnection.d.ts +18 -0
- package/dist/stockObjects/FileConnection.js +42 -0
- package/dist/stockObjects/InvoiceDetails.d.ts +12 -0
- package/dist/stockObjects/InvoiceDetails.js +26 -0
- package/dist/stockObjects/Order.d.ts +41 -0
- package/dist/stockObjects/Order.js +97 -0
- package/dist/stockObjects/OrderProduct.d.ts +15 -0
- package/dist/stockObjects/OrderProduct.js +33 -0
- package/dist/stockObjects/PaymentDetails.d.ts +12 -0
- package/dist/stockObjects/PaymentDetails.js +26 -0
- package/dist/stockObjects/PaymentMethods.d.ts +12 -0
- package/dist/stockObjects/PaymentMethods.js +26 -0
- package/dist/stockObjects/PaymentStatus.d.ts +13 -0
- package/dist/stockObjects/PaymentStatus.js +26 -0
- package/dist/stockObjects/PersonalData.d.ts +42 -0
- package/dist/stockObjects/PersonalData.js +81 -0
- package/dist/stockObjects/Product.d.ts +70 -0
- package/dist/stockObjects/Product.js +163 -0
- package/dist/stockObjects/Status.d.ts +23 -0
- package/dist/stockObjects/Status.js +50 -0
- package/dist/tables/clients/ClientAccountsTable.d.ts +17 -0
- package/dist/tables/clients/ClientAccountsTable.js +74 -0
- package/dist/tables/files/FileConnectionsTable.d.ts +12 -0
- package/dist/tables/files/FileConnectionsTable.js +41 -0
- package/dist/tables/files/FilesTable.d.ts +17 -0
- package/dist/tables/files/FilesTable.js +65 -0
- package/dist/tables/orders/OrdersProductsTable.d.ts +14 -0
- package/dist/tables/orders/OrdersProductsTable.js +54 -0
- package/dist/tables/orders/OrdersTable.d.ts +15 -0
- package/dist/tables/orders/OrdersTable.js +60 -0
- package/dist/tables/orders/PaymentDetailsTable.d.ts +10 -0
- package/dist/tables/orders/PaymentDetailsTable.js +34 -0
- package/dist/tables/orders/PaymentStatusTypesTable.d.ts +7 -0
- package/dist/tables/orders/PaymentStatusTypesTable.js +10 -0
- package/dist/tables/orders/PaymentStatusesTable.d.ts +9 -0
- package/dist/tables/orders/PaymentStatusesTable.js +30 -0
- package/dist/tables/orders/StatusTypesTable.d.ts +4 -0
- package/dist/tables/orders/StatusTypesTable.js +9 -0
- package/dist/tables/orders/StatusesTable.d.ts +11 -0
- package/dist/tables/orders/StatusesTable.js +40 -0
- package/dist/tables/personalInformation/AddressesTable.d.ts +10 -0
- package/dist/tables/personalInformation/AddressesTable.js +37 -0
- package/dist/tables/personalInformation/CompanyDetailsTable.d.ts +11 -0
- package/dist/tables/personalInformation/CompanyDetailsTable.js +38 -0
- package/dist/tables/personalInformation/ContactDetailsTable.d.ts +10 -0
- package/dist/tables/personalInformation/ContactDetailsTable.js +34 -0
- package/dist/tables/personalInformation/DeliveryDetailsTable.d.ts +10 -0
- package/dist/tables/personalInformation/DeliveryDetailsTable.js +35 -0
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.d.ts +7 -0
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.js +10 -0
- package/dist/tables/personalInformation/DeliveryStatusesTable.d.ts +9 -0
- package/dist/tables/personalInformation/DeliveryStatusesTable.js +31 -0
- package/dist/tables/personalInformation/InvoiceDetailsTable.d.ts +10 -0
- package/dist/tables/personalInformation/InvoiceDetailsTable.js +34 -0
- package/dist/tables/personalInformation/PersonalDataTable.d.ts +10 -0
- package/dist/tables/personalInformation/PersonalDataTable.js +37 -0
- package/dist/tables/public/AdminAccountsTable.d.ts +15 -0
- package/dist/tables/public/AdminAccountsTable.js +64 -0
- package/dist/tables/public/ProductsTable.d.ts +19 -0
- package/dist/tables/public/ProductsTable.js +98 -0
- package/dist/tables/settings/CompanyDataTable.d.ts +10 -0
- package/dist/tables/settings/CompanyDataTable.js +37 -0
- package/dist/tables/settings/DeliveryMethodsTable.d.ts +12 -0
- package/dist/tables/settings/DeliveryMethodsTable.js +43 -0
- package/dist/tables/settings/PaymentMethodsTable.d.ts +12 -0
- package/dist/tables/settings/PaymentMethodsTable.js +43 -0
- package/dist/types/AddressI.d.ts +9 -0
- package/dist/types/AddressI.js +1 -0
- package/dist/types/ClaimI.d.ts +4 -0
- package/dist/types/ClaimI.js +1 -0
- package/dist/types/ClientAccountI.d.ts +10 -0
- package/dist/types/ClientAccountI.js +1 -0
- package/dist/types/CompanyDataI.d.ts +8 -0
- package/dist/types/CompanyDataI.js +1 -0
- package/dist/types/CompanyDetailsI.d.ts +5 -0
- package/dist/types/CompanyDetailsI.js +1 -0
- package/dist/types/ContactDetailsI.d.ts +7 -0
- package/dist/types/ContactDetailsI.js +1 -0
- package/dist/types/DeliveryDetailsI.d.ts +8 -0
- package/dist/types/DeliveryDetailsI.js +1 -0
- package/dist/types/DeliveryMethodI.d.ts +5 -0
- package/dist/types/DeliveryMethodI.js +1 -0
- package/dist/types/FileConnectionI.d.ts +6 -0
- package/dist/types/FileConnectionI.js +1 -0
- package/dist/types/FileConnectionTypeE.d.ts +4 -0
- package/dist/types/FileConnectionTypeE.js +5 -0
- package/dist/types/FileI.d.ts +6 -0
- package/dist/types/FileI.js +1 -0
- package/dist/types/InvoiceDetailsI.d.ts +7 -0
- package/dist/types/InvoiceDetailsI.js +1 -0
- package/dist/types/OrderI.d.ts +12 -0
- package/dist/types/OrderI.js +1 -0
- package/dist/types/OrderProductI.d.ts +15 -0
- package/dist/types/OrderProductI.js +1 -0
- package/dist/types/OrderStatusI.d.ts +7 -0
- package/dist/types/OrderStatusI.js +1 -0
- package/dist/types/PaymentDetailsI.d.ts +6 -0
- package/dist/types/PaymentDetailsI.js +1 -0
- package/dist/types/PaymentMethodE.d.ts +5 -0
- package/dist/types/PaymentMethodE.js +6 -0
- package/dist/types/PaymentMethodI.d.ts +5 -0
- package/dist/types/PaymentMethodI.js +1 -0
- package/dist/types/PaymentStatusE.d.ts +6 -0
- package/dist/types/PaymentStatusE.js +7 -0
- package/dist/types/PersonalDataI.d.ts +10 -0
- package/dist/types/PersonalDataI.js +1 -0
- package/dist/types/ProductI.d.ts +22 -0
- package/dist/types/ProductI.js +1 -0
- package/dist/types/StatusI.d.ts +5 -0
- package/dist/types/StatusI.js +1 -0
- package/dist/types/rows/AddressRow.d.ts +9 -0
- package/dist/types/rows/AddressRow.js +1 -0
- package/dist/types/rows/AdminRow.d.ts +9 -0
- package/dist/types/rows/AdminRow.js +1 -0
- package/dist/types/rows/ClientAccountRow.d.ts +10 -0
- package/dist/types/rows/ClientAccountRow.js +1 -0
- package/dist/types/rows/CompanyDataRow.d.ts +8 -0
- package/dist/types/rows/CompanyDataRow.js +1 -0
- package/dist/types/rows/CompanyDetailsRow.d.ts +5 -0
- package/dist/types/rows/CompanyDetailsRow.js +1 -0
- package/dist/types/rows/ContactDetailsRow.d.ts +5 -0
- package/dist/types/rows/ContactDetailsRow.js +1 -0
- package/dist/types/rows/DeliveryDetailsRow.d.ts +6 -0
- package/dist/types/rows/DeliveryDetailsRow.js +1 -0
- package/dist/types/rows/DeliveryMethodRow.d.ts +5 -0
- package/dist/types/rows/DeliveryMethodRow.js +1 -0
- package/dist/types/rows/DeliveryStatusRow.d.ts +7 -0
- package/dist/types/rows/DeliveryStatusRow.js +1 -0
- package/dist/types/rows/FileConnectionRow.d.ts +6 -0
- package/dist/types/rows/FileConnectionRow.js +1 -0
- package/dist/types/rows/FileRow.d.ts +9 -0
- package/dist/types/rows/FileRow.js +1 -0
- package/dist/types/rows/InvoiceDetailsRow.d.ts +5 -0
- package/dist/types/rows/InvoiceDetailsRow.js +1 -0
- package/dist/types/rows/OrderProductRow.d.ts +6 -0
- package/dist/types/rows/OrderProductRow.js +1 -0
- package/dist/types/rows/OrderRow.d.ts +15 -0
- package/dist/types/rows/OrderRow.js +1 -0
- package/dist/types/rows/PaymentDetailsRow.d.ts +6 -0
- package/dist/types/rows/PaymentDetailsRow.js +1 -0
- package/dist/types/rows/PaymentMethodRow.d.ts +5 -0
- package/dist/types/rows/PaymentMethodRow.js +1 -0
- package/dist/types/rows/PaymentStatusRow.d.ts +6 -0
- package/dist/types/rows/PaymentStatusRow.js +1 -0
- package/dist/types/rows/PersonalDataRow.d.ts +8 -0
- package/dist/types/rows/PersonalDataRow.js +1 -0
- package/dist/types/rows/ProductRow.d.ts +17 -0
- package/dist/types/rows/ProductRow.js +1 -0
- package/dist/types/rows/StatusRow.d.ts +8 -0
- package/dist/types/rows/StatusRow.js +1 -0
- package/dist/utils/OrderByI.d.ts +4 -0
- package/dist/utils/OrderByI.js +1 -0
- package/dist/utils/calculateNetToGrossPrice.d.ts +1 -0
- package/dist/utils/calculateNetToGrossPrice.js +7 -0
- package/dist/utils/correctPhoneNumber.d.ts +1 -0
- package/dist/utils/correctPhoneNumber.js +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DatabaseConfig from "./DatabaseConfig";
|
|
2
|
+
import TableConnection from "./TableConnection";
|
|
3
|
+
export default class DatabaseConnection {
|
|
4
|
+
private static connection;
|
|
5
|
+
private static configName;
|
|
6
|
+
private static configField;
|
|
7
|
+
private static configPath;
|
|
8
|
+
static get(): TableConnection;
|
|
9
|
+
static create(): Promise<TableConnection>;
|
|
10
|
+
static getDatabaseConfig(): Promise<DatabaseConfig>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Database from "./Database";
|
|
2
|
+
import TableConnection from "./TableConnection";
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
export default class DatabaseConnection {
|
|
5
|
+
static connection;
|
|
6
|
+
static configName = 'config.json';
|
|
7
|
+
static configField = 'database';
|
|
8
|
+
static configPath = './server/';
|
|
9
|
+
static get() {
|
|
10
|
+
if (!this.connection)
|
|
11
|
+
throw Error('Connection not created!');
|
|
12
|
+
return this.connection;
|
|
13
|
+
}
|
|
14
|
+
static async create() {
|
|
15
|
+
if (!this.connection) {
|
|
16
|
+
const databaseConfig = await this.getDatabaseConfig();
|
|
17
|
+
const pgClient = await Database.connect(databaseConfig);
|
|
18
|
+
this.connection = new TableConnection(pgClient);
|
|
19
|
+
}
|
|
20
|
+
return this.connection;
|
|
21
|
+
}
|
|
22
|
+
static async getDatabaseConfig() {
|
|
23
|
+
let config = JSON.parse(await readFile(`${this.configPath}${this.configName}`, "utf8"));
|
|
24
|
+
if (this.configField)
|
|
25
|
+
config = config[this.configField];
|
|
26
|
+
return config;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/SQL.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"adminAccounts": {
|
|
3
|
+
"select": "SELECT id, first_name, last_name, email, created_at, activated, deleted FROM admin_accounts WHERE id = $id::BIGINT",
|
|
4
|
+
"selectAll": "SELECT id, first_name, last_name, email, created_at, activated, deleted FROM admin_accounts $WHERE $ORDERBY $LIMIT ",
|
|
5
|
+
"selectNextId": "SELECT nextval('admin_account_id'::regclass)",
|
|
6
|
+
"selectForEmail": "SELECT id FROM admin_accounts WHERE LOWER( email ) = LOWER($email::TEXT)",
|
|
7
|
+
"insert": "INSERT INTO admin_accounts( id, first_name, last_name, email, activated) VALUES ($id::BIGINT, $first_name::TEXT, $last_name::TEXT, LOWER($email::TEXT), $activated::BOOL)",
|
|
8
|
+
"update": "UPDATE admin_accounts SET first_name = $first_name::TEXT, last_name = $last_name::TEXT , email = LOWER($email::TEXT), activated = $activated::BOOL, deleted = $deleted::BOOL WHERE id = $id::BIGINT",
|
|
9
|
+
"delete": "UPDATE admin_accounts SET deleted = true, activated = false WHERE id = $id::BIGINT",
|
|
10
|
+
"count": "SELECT COUNT(*) AS total_rows FROM admin_accounts $WHERE "
|
|
11
|
+
},
|
|
12
|
+
"accounts": {
|
|
13
|
+
"select": "SELECT id, email, created_at, activated, deleted, contact_details_id, delivery_details_id, invoice_details_id FROM clients.accounts WHERE id = $account_id::BIGINT",
|
|
14
|
+
"selectAll": "SELECT id, email, created_at, activated, deleted FROM clients.accounts $WHERE $ORDERBY $LIMIT",
|
|
15
|
+
"selectNextId": "SELECT nextval('clients.accounts_id'::regclass)",
|
|
16
|
+
"getIdForEmail": "SELECT id FROM clients.accounts WHERE LOWER( email ) = LOWER($email::TEXT)",
|
|
17
|
+
"insert": "INSERT INTO clients.accounts( id, email, activated, contact_details_id) VALUES ($id::BIGINT, LOWER($email::TEXT), $activated::BOOL, $contact_details_id::BIGINT)",
|
|
18
|
+
"update": "UPDATE clients.accounts SET activated = $activated::BOOL, deleted = $deleted::BOOL, contact_details_id = $contact_details_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, invoice_details_id = $invoice_details_id::BIGINT WHERE id = $id::BIGINT",
|
|
19
|
+
"delete": "DELETE FROM clients.accounts WHERE id = $account_id::BIGINT",
|
|
20
|
+
"count": "SELECT COUNT(*) AS total_rows FROM clients.accounts $WHERE ",
|
|
21
|
+
"selectEmail": "SELECT email FROM clients.accounts WHERE id = $id:BIGINT"
|
|
22
|
+
},
|
|
23
|
+
"contactDetails": {
|
|
24
|
+
"select": "SELECT id, personal_data_id, address_id FROM personal_information.contact_details WHERE id = $id::BIGINT",
|
|
25
|
+
"insert": "INSERT INTO personal_information.contact_details(id, personal_data_id, address_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT)",
|
|
26
|
+
"update": "UPDATE personal_information.contact_details SET personal_data_id = $personal_data_id::BIGINT, address_id = $address_id::BIGINT WHERE id = $id::BIGINT",
|
|
27
|
+
"selectNextId": "SELECT nextval('personal_information.contact_details_id'::regclass)"
|
|
28
|
+
},
|
|
29
|
+
"deliveryDetails": {
|
|
30
|
+
"select": "SELECT id, personal_data_id, address_id, delivery_method_id FROM personal_information.delivery_details WHERE id = $id::BIGINT",
|
|
31
|
+
"insert": "INSERT INTO personal_information.delivery_details(id, personal_data_id, address_id, delivery_method_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT, $delivery_method_id::BIGINT)",
|
|
32
|
+
"update": "UPDATE personal_information.delivery_details SET personal_data_id = $personal_data_id::BIGINT, address_id = $address_id::BIGINT, delivery_method_id = $delivery_method_id::BIGINT WHERE id = $id::BIGINT",
|
|
33
|
+
"selectNextId": "SELECT nextval('personal_information.delivery_details_id'::regclass)"
|
|
34
|
+
},
|
|
35
|
+
"invoiceDetails": {
|
|
36
|
+
"select": "SELECT id, personal_data_id, address_id FROM personal_information.invoice_details WHERE id = $id::BIGINT",
|
|
37
|
+
"insert": "INSERT INTO personal_information.invoice_details(id, personal_data_id, address_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT)",
|
|
38
|
+
"update": "UPDATE personal_information.invoice_details SET personal_data_id = $personal_data_id::BIGINT, address_id = $address_id::BIGINT WHERE id = $id::BIGINT",
|
|
39
|
+
"selectNextId": "SELECT nextval('personal_information.invoice_details_id'::regclass)"
|
|
40
|
+
},
|
|
41
|
+
"addresses": {
|
|
42
|
+
"select": "SELECT id, country, city, postal_code, street, house_number, apartment_number FROM personal_information.addresses WHERE id = $id::BIGINT",
|
|
43
|
+
"selectTypes": "SELECT type FROM personal_information.addresses WHERE account_id = $account_id::BIGINT",
|
|
44
|
+
"selectId": "SELECT id FROM personal_information.addresses WHERE account_id = $account_id::BIGINT AND type = $type::SMALLINT",
|
|
45
|
+
"insert": "INSERT INTO personal_information.addresses( id, country, city, postal_code, street, house_number, apartment_number) VALUES( $id::BIGINT, $country::TEXT, $city::TEXT, $postal_code::TEXT, $street::TEXT, $house_number::TEXT, $apartment_number::TEXT) ",
|
|
46
|
+
"update": "UPDATE personal_information.addresses SET country = $country::TEXT, city = $city::TEXT, postal_code = $postal_code::TEXT , street = $street::TEXT , house_number = $house_number::TEXT , apartment_number = $apartment_number::TEXT WHERE id = $id::BIGINT",
|
|
47
|
+
"selectNextId": "SELECT nextval('personal_information.addresses_id'::regclass)"
|
|
48
|
+
},
|
|
49
|
+
"personalData": {
|
|
50
|
+
"select": "SELECT id, first_name, last_name, email, phone_number, company_details_id FROM personal_information.personal_data WHERE id = $id::BIGINT",
|
|
51
|
+
"insert": "INSERT INTO personal_information.personal_data (id, first_name, last_name, email, phone_number, company_details_id) VALUES ($id::BIGINT, $first_name::TEXT, $last_name::TEXT, $email::TEXT, $phone_number::TEXT, $company_details_id::BIGINT)",
|
|
52
|
+
"update": "UPDATE personal_information.personal_data SET email = $email::TEXT, first_name = $first_name::TEXT, last_name= $last_name::TEXT, phone_number = $phone_number::TEXT, company_details_id = $company_details_id::BIGINT WHERE id = $id::BIGINT",
|
|
53
|
+
"selectNextId": "SELECT nextval('personal_information.personal_data_id'::regclass)"
|
|
54
|
+
},
|
|
55
|
+
"companyDetails": {
|
|
56
|
+
"select": "SELECT id, name, tax_number FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
57
|
+
"insert": "INSERT INTO personal_information.company_details( id, name, tax_number ) VALUES ($id::BIGINT, $name::TEXT, $tax_number::TEXT )",
|
|
58
|
+
"update": "UPDATE personal_information.company_details SET name = $name::TEXT, tax_number = $tax_number::TEXT WHERE id = $id::BIGINT",
|
|
59
|
+
"delete": "DELETE FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
60
|
+
"selectIfIs": "SELECT FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
61
|
+
"selectNextId": "SELECT nextval('personal_information.company_details_id'::regclass)"
|
|
62
|
+
},
|
|
63
|
+
"products": {
|
|
64
|
+
"select": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE id = $id::BIGINT",
|
|
65
|
+
"selectAll": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE deleted = false $PARAMS $ORDERBY LIMIT $limit::BIGINT OFFSET $offset::BIGINT",
|
|
66
|
+
"selectListForOrder": "SELECT id, title, sku, file_id, net_price FROM products WHERE deleted = false",
|
|
67
|
+
"selectIdForSku": "SELECT id FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT) AND deleted = false",
|
|
68
|
+
"insert": "INSERT INTO products( id, sku, url, title, description, net_price, vat, color, quantity, width, length, height, file_id, deleted) VALUES ($id::BIGINT, $sku::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $vat::INT, $color::TEXT, $quantity::INT, $width::INT, $length::INT, $height::DOUBLE PRECISION,$file_id::BIGINT ,false::BOOL)",
|
|
69
|
+
"update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT , description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, vat = $vat::INT, color = $color::TEXT, quantity = $quantity::INT, width = $width::INT, length = $length::INT, height = $height::DOUBLE PRECISION, file_id = $file_id::BIGINT WHERE id = $id::BIGINT",
|
|
70
|
+
"delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
|
|
71
|
+
"restore": "UPDATE products SET deleted = false WHERE id = $id::BIGINT",
|
|
72
|
+
"selectForSku": "SELECT * FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
73
|
+
"selectForUrl": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE LOWER( url ) = LOWER($url::TEXT)",
|
|
74
|
+
"selectNextId": "SELECT nextval('product_id'::regclass)",
|
|
75
|
+
"count": "SELECT COUNT(*) AS total_rows FROM products WHERE deleted = false $PARAMS"
|
|
76
|
+
},
|
|
77
|
+
"orders": {
|
|
78
|
+
"selectAll": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id, zsi_id FROM orders.orders",
|
|
79
|
+
"select": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id, zsi_id FROM orders.orders WHERE id = $id::BIGINT",
|
|
80
|
+
"selectForClient": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id FROM orders.orders WHERE client_id = $client_id::BIGINT ORDER BY id DESC",
|
|
81
|
+
"insert": "INSERT INTO orders.orders( id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id ) VALUES ($order_id::BIGINT, $email::TEXT, $price::DOUBLE PRECISION, $client_id::BIGINT, $contact_details_id::BIGINT, $delivery_details_id::BIGINT , $invoice_details_id::BIGINT, $payment_details_id::BIGINT )",
|
|
82
|
+
"update": "UPDATE orders.orders SET price = $price::DOUBLE PRECISION, contact_details_id = $contact_details_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, invoice_details_id = $invoice_details_id::BIGINT, payment_details_id = $payment_details_id::BIGINT, zsi_id = $zsi_id::BIGINT WHERE id = $id::BIGINT",
|
|
83
|
+
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)",
|
|
84
|
+
"count": "SELECT COUNT (*) AS TOTAL_ROWS FROM orders.orders as o JOIN orders.statuses as os ON o.id = os.order_id JOIN (SELECT order_id, MAX(id) as max_id FROM orders.statuses GROUP BY order_id) as latest ON os.order_id = latest.order_id AND os.id = latest.max_id $WHERE"
|
|
85
|
+
},
|
|
86
|
+
"ordersProducts": {
|
|
87
|
+
"selectProducts": "SELECT op.id, order_id, product_id, title, sku, p.file_id, op.net_price FROM orders.orders_products as op JOIN products as p ON op.product_id = p.id WHERE order_id = $order_id::BIGINT AND in_order = true",
|
|
88
|
+
"select": "SELECT id, order_id, product_id, in_order FROM orders.orders_products WHERE order_id = $order_id::BIGINT AND in_order = true",
|
|
89
|
+
"selectAll": "SELECT * FROM orders.orders_products $WHERE",
|
|
90
|
+
"getAllActiveForOrderId": "SELECT * FROM orders.orders_products WHERE order_id = $order_id::BIGINT and in_order = true",
|
|
91
|
+
"insert": "INSERT INTO orders.orders_products( id, order_id, product_id, net_price ) VALUES ( $id::BIGINT , $order_id::BIGINT, $product_id::BIGINT, $net_price::DOUBLE PRECISION )",
|
|
92
|
+
"selectNextId": "SELECT nextval('orders.orders_products_id'::regclass)",
|
|
93
|
+
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
94
|
+
},
|
|
95
|
+
"statuses": {
|
|
96
|
+
"selectLatest": "SELECT s.id, s.order_id, created_at, user_id, s.type as type_id, st.key as type_name FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE s.order_id = $order_id::BIGINT ORDER BY s.id DESC LIMIT 1",
|
|
97
|
+
"selectForOrder": "SELECT s.id, order_id, created_at, user_id, st.key as type FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE order_id = $order_id::BIGINT ORDER BY s.id DESC LIMIT 1",
|
|
98
|
+
"selectAllForOrder": "SELECT s.id, order_id, created_at, user_id, st.key as type FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE order_id = $order_id::BIGINT ORDER BY s.id DESC",
|
|
99
|
+
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
|
100
|
+
"selectNextId": "SELECT nextval('orders.statuses_id'::regclass)"
|
|
101
|
+
},
|
|
102
|
+
"paymentDetails": {
|
|
103
|
+
"select": "SELECT id, payment_method_id, payment_order_id FROM orders.payment_details WHERE id = $id::BIGINT",
|
|
104
|
+
"insert": "INSERT INTO orders.payment_details(id, payment_method_id, payment_order_id) VALUES ($id::BIGINT, $payment_method_id::BIGINT, $payment_order_id::TEXT)",
|
|
105
|
+
"update": "UPDATE orders.payment_details SET payment_method_id = $payment_method_id::BIGINT, payment_order_id = $payment_order_id::TEXT WHERE id = $id::BIGINT",
|
|
106
|
+
"selectNextId": "SELECT nextval('orders.payment_details_id'::regclass)"
|
|
107
|
+
},
|
|
108
|
+
"files": {
|
|
109
|
+
"selectId": "SELECT id FROM files.files $WHERE",
|
|
110
|
+
"selectAll": "SELECT f.id, f.name, f.orginal_name, f.catalog, f.size_kb, f.type, f.created_at FROM files.files as f $WHERE $ORDERBY",
|
|
111
|
+
"select": "SELECT id, name, orginal_name, catalog, size_kb, type, created_at FROM files.files WHERE id = $id::BIGINT",
|
|
112
|
+
"selectForConnection": "SELECT id, name, catalog, type FROM files.files JOIN files.file_connections ON file_id = id WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT ORDER BY sequence",
|
|
113
|
+
"selectNextId": "SELECT nextval('files.files_id'::regclass)",
|
|
114
|
+
"insert": "INSERT INTO files.files( id, name, orginal_name, catalog, size_kb, type, created_at ) VALUES ( $id::BIGINT, $name::TEXT, $orginal_name::TEXT, $catalog::TEXT, $size_kb::BIGINT, $type::TEXT, now() )",
|
|
115
|
+
"update": "UPDATE files.files SET name = $name::TEXT, orginal_name = $orginal_name::TEXT, catalog = $catalog::TEXT, size_kb = $size_kb::BIGINT, type = $type::TEXT WHERE id = $id::BIGINT ",
|
|
116
|
+
"count": "SELECT COUNT(*) AS total_rows FROM files.files as f $WHERE ",
|
|
117
|
+
"delete": "DELETE FROM files.files WHERE id = $id::BIGINT "
|
|
118
|
+
},
|
|
119
|
+
"fileConnections": {
|
|
120
|
+
"select": "SELECT file_id, sequence FROM files.file_connections WHERE connection_type = $connection_type::BIGINT and connection_id = $connection_id::BIGINT",
|
|
121
|
+
"selectForFileId": "SELECT * FROM files.file_connections WHERE file_id = $file_id::BIGINT",
|
|
122
|
+
"insert": "INSERT INTO files.file_connections( file_id, connection_type, connection_id, sequence) VALUES ($file_id::BIGINT, $connection_type::TEXT, $connection_id::BIGINT, $sequence::BIGINT)",
|
|
123
|
+
"delete": "DELETE FROM files.file_connections WHERE file_id = $file_id::BIGINT",
|
|
124
|
+
"deleteForConnection": "DELETE FROM files.file_connections WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT"
|
|
125
|
+
},
|
|
126
|
+
"paymentMethods": {
|
|
127
|
+
"select": "SELECT * FROM settings.payment_methods WHERE id = $id::BIGINT",
|
|
128
|
+
"selectAll": "SELECT * FROM settings.payment_methods ORDER BY id",
|
|
129
|
+
"selectAllActive": "SELECT * FROM settings.payment_methods WHERE active=true ORDER BY id",
|
|
130
|
+
"insert": "INSERT INTO settings.payment_methods(id, key, active) VALUES ( $id::BIGINT, $key::TEXT, $active::BOOL)",
|
|
131
|
+
"update": "UPDATE settings.payment_methods SET id = $id::BIGINT, key = $key::TEXT, active = $active::BOOL WHERE id = $id::BIGINT",
|
|
132
|
+
"selectNextId": "SELECT nextval('settings.payment_methods_id'::regclass)"
|
|
133
|
+
},
|
|
134
|
+
"deliveryMethods": {
|
|
135
|
+
"select": "SELECT * FROM settings.delivery_methods WHERE id = $id::BIGINT",
|
|
136
|
+
"selectAll": "SELECT * FROM settings.delivery_methods ORDER BY id",
|
|
137
|
+
"selectAllActive": "SELECT * FROM settings.delivery_methods WHERE active=true ORDER BY id",
|
|
138
|
+
"insert": "INSERT INTO settings.delivery_methods(id, key, active) VALUES ( $id::BIGINT, $key::TEXT, $active::BOOL)",
|
|
139
|
+
"update": "UPDATE settings.delivery_methods SET id = $id::BIGINT, key = $key::TEXT, active = $active::BOOL WHERE id = $id::BIGINT",
|
|
140
|
+
"selectNextId": "SELECT nextval('settings.delivery_methods_id'::regclass)"
|
|
141
|
+
},
|
|
142
|
+
"paymentStatusTypes": {
|
|
143
|
+
"select": "SELECT * FROM orders.payment_status_types WHERE id = $id::BIGINT"
|
|
144
|
+
},
|
|
145
|
+
"deliveryStatusTypes": {
|
|
146
|
+
"select": "SELECT * FROM personal_information.delivery_status_types WHERE id = $id::BIGINT"
|
|
147
|
+
},
|
|
148
|
+
"deliveryStatuses": {
|
|
149
|
+
"select": "SELECT * FROM personal_information.delivery_statuses WHERE delivery_details_id = $delivery_details_id::BIGINT ORDER BY id DESC LIMIT 1",
|
|
150
|
+
"selectAll": "SELECT * FROM personal_information.delivery_statuses WHERE delivery_details_id = $delivery_details_id::BIGINT ORDER BY id DESC",
|
|
151
|
+
"insert": "INSERT INTO personal_information.delivery_statuses( id, delivery_details_id, delivery_status_type_id, user_id ) VALUES ($id::BIGINT, $delivery_details_id::BIGINT, $delivery_status_type_id::BIGINT, $user_id::BIGINT)",
|
|
152
|
+
"selectNextId": "SELECT nextval('personal_information.delivery_statuses_id'::regclass)"
|
|
153
|
+
},
|
|
154
|
+
"paymentStatuses": {
|
|
155
|
+
"select": "SELECT * FROM orders.payment_statuses WHERE payment_details_id = $payment_details_id::BIGINT ORDER BY id DESC LIMIT 1",
|
|
156
|
+
"selectAll": "SELECT * FROM orders.payment_statuses WHERE payment_details_id = $payment_details_id::BIGINT ORDER BY id DESC",
|
|
157
|
+
"insert": "INSERT INTO orders.payment_statuses( id, payment_details_id, payment_status_type_id ) VALUES ($id::BIGINT, $payment_details_id::BIGINT, $payment_status_type_id::BIGINT)",
|
|
158
|
+
"selectNextId": "SELECT nextval('orders.payment_statuses_id'::regclass)"
|
|
159
|
+
},
|
|
160
|
+
"statusTypes": {
|
|
161
|
+
"select": "SELECT * FROM orders.status_types"
|
|
162
|
+
},
|
|
163
|
+
"companyData": {
|
|
164
|
+
"select": "SELECT * FROM settings.company_data ORDER BY id DESC LIMIT 1",
|
|
165
|
+
"insert": "INSERT INTO settings.company_data(id, name, tax_number, email, phone_number, address_id) VALUES ( $id::BIGINT, $name::TEXT, $tax_number::TEXT, $email::TEXT, $phone_number::TEXT, $address_id::BIGINT )",
|
|
166
|
+
"update": "UPDATE settings.company_data SET id = $id::BIGINT, name = $name::TEXT , email = LOWER($email::TEXT), phone_number = $phone_number::TEXT, tax_number = $tax_number::TEXT WHERE id = $id::BIGINT",
|
|
167
|
+
"selectNextId": "SELECT nextval('settings.company_data_id'::regclass)"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Client } from 'pg';
|
|
2
|
+
import Connection from './Connection';
|
|
3
|
+
import OrdersTable from './tables/orders/OrdersTable';
|
|
4
|
+
import FilesTable from './tables/files/FilesTable';
|
|
5
|
+
import StatusesTable from './tables/orders/StatusesTable';
|
|
6
|
+
import ProductsTable from './tables/public/ProductsTable';
|
|
7
|
+
import ClientAccountsTable from './tables/clients/ClientAccountsTable';
|
|
8
|
+
import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
9
|
+
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
10
|
+
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
11
|
+
import DeliveryStatusTypesTable from './tables/personalInformation/DeliveryStatusTypesTable';
|
|
12
|
+
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
13
|
+
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
14
|
+
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
15
|
+
import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
|
|
16
|
+
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
17
|
+
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
18
|
+
import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
|
|
19
|
+
import DeliveryStatusesTable from './tables/personalInformation/DeliveryStatusesTable';
|
|
20
|
+
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
21
|
+
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
22
|
+
import AdminAccountsTable from './tables/public/AdminAccountsTable';
|
|
23
|
+
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
24
|
+
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
25
|
+
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
26
|
+
export default class TableConnection extends Connection {
|
|
27
|
+
private _AdminAccountsTable;
|
|
28
|
+
private _StatusTypesTable;
|
|
29
|
+
private _FilesTable;
|
|
30
|
+
private _OrdersTable;
|
|
31
|
+
private _ProductsTable;
|
|
32
|
+
private _StatusesTable;
|
|
33
|
+
private _AddressesTable;
|
|
34
|
+
private _PersonalDataTable;
|
|
35
|
+
private _CompanyDetailsTable;
|
|
36
|
+
private _ClientAccountsTable;
|
|
37
|
+
private _OrdersProductsTable;
|
|
38
|
+
private _ContactDetailsTable;
|
|
39
|
+
private _InvoiceDetailsTable;
|
|
40
|
+
private _PaymentMethodsTable;
|
|
41
|
+
private _DeliveryDetailsTable;
|
|
42
|
+
private _DeliveryMethodsTable;
|
|
43
|
+
private _PaymentStatusTypesTable;
|
|
44
|
+
private _DeliveryStatusTypesTable;
|
|
45
|
+
private _DeliveryStatusesTable;
|
|
46
|
+
private _PaymentDetailsTable;
|
|
47
|
+
private _PaymentStatusesTable;
|
|
48
|
+
private _CompanyDataTable;
|
|
49
|
+
private _FileConnectionsTable;
|
|
50
|
+
constructor(pgClient: Client);
|
|
51
|
+
get adminAccounts(): AdminAccountsTable;
|
|
52
|
+
get statusTypes(): StatusTypesTable;
|
|
53
|
+
get files(): FilesTable;
|
|
54
|
+
get orders(): OrdersTable;
|
|
55
|
+
get products(): ProductsTable;
|
|
56
|
+
get statuses(): StatusesTable;
|
|
57
|
+
get addresses(): AddressesTable;
|
|
58
|
+
get accounts(): ClientAccountsTable;
|
|
59
|
+
get companyDetails(): CompanyDetailsTable;
|
|
60
|
+
get personalData(): PersonalDataTable;
|
|
61
|
+
get ordersProducts(): OrdersProductsTable;
|
|
62
|
+
get contactDetails(): ContactDetailsTable;
|
|
63
|
+
get deliveryDetails(): DeliveryDetailsTable;
|
|
64
|
+
get invoiceDetails(): InvoiceDetailsTable;
|
|
65
|
+
get deliveryMethods(): DeliveryMethodsTable;
|
|
66
|
+
get paymentMethods(): PaymentMethodsTable;
|
|
67
|
+
get paymentStatusTypes(): PaymentStatusTypesTable;
|
|
68
|
+
get deliveryStatusTypes(): DeliveryStatusTypesTable;
|
|
69
|
+
get deliveryStatuses(): DeliveryStatusesTable;
|
|
70
|
+
get paymentDetails(): PaymentDetailsTable;
|
|
71
|
+
get paymentStatuses(): PaymentStatusesTable;
|
|
72
|
+
get companyData(): CompanyDataTable;
|
|
73
|
+
get fileConnections(): FileConnectionsTable;
|
|
74
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import Connection from './Connection';
|
|
2
|
+
import OrdersTable from './tables/orders/OrdersTable';
|
|
3
|
+
import FilesTable from './tables/files/FilesTable';
|
|
4
|
+
import StatusesTable from './tables/orders/StatusesTable';
|
|
5
|
+
import ProductsTable from './tables/public/ProductsTable';
|
|
6
|
+
import ClientAccountsTable from './tables/clients/ClientAccountsTable';
|
|
7
|
+
import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
8
|
+
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
9
|
+
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
10
|
+
import DeliveryStatusTypesTable from './tables/personalInformation/DeliveryStatusTypesTable';
|
|
11
|
+
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
12
|
+
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
13
|
+
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
14
|
+
import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
|
|
15
|
+
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
16
|
+
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
17
|
+
import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
|
|
18
|
+
import DeliveryStatusesTable from './tables/personalInformation/DeliveryStatusesTable';
|
|
19
|
+
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
20
|
+
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
21
|
+
import AdminAccountsTable from './tables/public/AdminAccountsTable';
|
|
22
|
+
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
23
|
+
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
24
|
+
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
25
|
+
export default class TableConnection extends Connection {
|
|
26
|
+
_AdminAccountsTable;
|
|
27
|
+
_StatusTypesTable;
|
|
28
|
+
_FilesTable;
|
|
29
|
+
_OrdersTable;
|
|
30
|
+
_ProductsTable;
|
|
31
|
+
_StatusesTable;
|
|
32
|
+
_AddressesTable;
|
|
33
|
+
_PersonalDataTable;
|
|
34
|
+
_CompanyDetailsTable;
|
|
35
|
+
_ClientAccountsTable;
|
|
36
|
+
_OrdersProductsTable;
|
|
37
|
+
_ContactDetailsTable;
|
|
38
|
+
_InvoiceDetailsTable;
|
|
39
|
+
_PaymentMethodsTable;
|
|
40
|
+
_DeliveryDetailsTable;
|
|
41
|
+
_DeliveryMethodsTable;
|
|
42
|
+
_PaymentStatusTypesTable;
|
|
43
|
+
_DeliveryStatusTypesTable;
|
|
44
|
+
_DeliveryStatusesTable;
|
|
45
|
+
_PaymentDetailsTable;
|
|
46
|
+
_PaymentStatusesTable;
|
|
47
|
+
_CompanyDataTable;
|
|
48
|
+
_FileConnectionsTable;
|
|
49
|
+
constructor(pgClient) {
|
|
50
|
+
super(pgClient);
|
|
51
|
+
this._AdminAccountsTable = new AdminAccountsTable(this);
|
|
52
|
+
this._StatusTypesTable = new StatusTypesTable(this);
|
|
53
|
+
this._FilesTable = new FilesTable(this);
|
|
54
|
+
this._OrdersTable = new OrdersTable(this);
|
|
55
|
+
this._StatusesTable = new StatusesTable(this);
|
|
56
|
+
this._ProductsTable = new ProductsTable(this);
|
|
57
|
+
this._AddressesTable = new AddressesTable(this);
|
|
58
|
+
this._PersonalDataTable = new PersonalDataTable(this);
|
|
59
|
+
this._CompanyDetailsTable = new CompanyDetailsTable(this);
|
|
60
|
+
this._OrdersProductsTable = new OrdersProductsTable(this);
|
|
61
|
+
this._ContactDetailsTable = new ContactDetailsTable(this);
|
|
62
|
+
this._InvoiceDetailsTable = new InvoiceDetailsTable(this);
|
|
63
|
+
this._ClientAccountsTable = new ClientAccountsTable(this);
|
|
64
|
+
this._PaymentMethodsTable = new PaymentMethodsTable(this);
|
|
65
|
+
this._DeliveryDetailsTable = new DeliveryDetailsTable(this);
|
|
66
|
+
this._DeliveryMethodsTable = new DeliveryMethodsTable(this);
|
|
67
|
+
this._PaymentStatusTypesTable = new PaymentStatusTypesTable(this);
|
|
68
|
+
this._DeliveryStatusTypesTable = new DeliveryStatusTypesTable(this);
|
|
69
|
+
this._DeliveryStatusesTable = new DeliveryStatusesTable(this);
|
|
70
|
+
this._PaymentDetailsTable = new PaymentDetailsTable(this);
|
|
71
|
+
this._PaymentStatusesTable = new PaymentStatusesTable(this);
|
|
72
|
+
this._CompanyDataTable = new CompanyDataTable(this);
|
|
73
|
+
this._FileConnectionsTable = new FileConnectionsTable(this);
|
|
74
|
+
}
|
|
75
|
+
get adminAccounts() {
|
|
76
|
+
return this._AdminAccountsTable;
|
|
77
|
+
}
|
|
78
|
+
get statusTypes() {
|
|
79
|
+
return this._StatusTypesTable;
|
|
80
|
+
}
|
|
81
|
+
get files() {
|
|
82
|
+
return this._FilesTable;
|
|
83
|
+
}
|
|
84
|
+
get orders() {
|
|
85
|
+
return this._OrdersTable;
|
|
86
|
+
}
|
|
87
|
+
get products() {
|
|
88
|
+
return this._ProductsTable;
|
|
89
|
+
}
|
|
90
|
+
get statuses() {
|
|
91
|
+
return this._StatusesTable;
|
|
92
|
+
}
|
|
93
|
+
get addresses() {
|
|
94
|
+
return this._AddressesTable;
|
|
95
|
+
}
|
|
96
|
+
get accounts() {
|
|
97
|
+
return this._ClientAccountsTable;
|
|
98
|
+
}
|
|
99
|
+
get companyDetails() {
|
|
100
|
+
return this._CompanyDetailsTable;
|
|
101
|
+
}
|
|
102
|
+
get personalData() {
|
|
103
|
+
return this._PersonalDataTable;
|
|
104
|
+
}
|
|
105
|
+
get ordersProducts() {
|
|
106
|
+
return this._OrdersProductsTable;
|
|
107
|
+
}
|
|
108
|
+
get contactDetails() {
|
|
109
|
+
return this._ContactDetailsTable;
|
|
110
|
+
}
|
|
111
|
+
get deliveryDetails() {
|
|
112
|
+
return this._DeliveryDetailsTable;
|
|
113
|
+
}
|
|
114
|
+
get invoiceDetails() {
|
|
115
|
+
return this._InvoiceDetailsTable;
|
|
116
|
+
}
|
|
117
|
+
get deliveryMethods() {
|
|
118
|
+
return this._DeliveryMethodsTable;
|
|
119
|
+
}
|
|
120
|
+
get paymentMethods() {
|
|
121
|
+
return this._PaymentMethodsTable;
|
|
122
|
+
}
|
|
123
|
+
get paymentStatusTypes() {
|
|
124
|
+
return this._PaymentStatusTypesTable;
|
|
125
|
+
}
|
|
126
|
+
get deliveryStatusTypes() {
|
|
127
|
+
return this._DeliveryStatusTypesTable;
|
|
128
|
+
}
|
|
129
|
+
get deliveryStatuses() {
|
|
130
|
+
return this._DeliveryStatusesTable;
|
|
131
|
+
}
|
|
132
|
+
get paymentDetails() {
|
|
133
|
+
return this._PaymentDetailsTable;
|
|
134
|
+
}
|
|
135
|
+
get paymentStatuses() {
|
|
136
|
+
return this._PaymentStatusesTable;
|
|
137
|
+
}
|
|
138
|
+
get companyData() {
|
|
139
|
+
return this._CompanyDataTable;
|
|
140
|
+
}
|
|
141
|
+
get fileConnections() {
|
|
142
|
+
return this._FileConnectionsTable;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Address from "../stockObjects/Address";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class AddressMapper implements StockObjectMapper {
|
|
4
|
+
private address;
|
|
5
|
+
private addressesTable;
|
|
6
|
+
constructor(address: Address);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class AddressMapper {
|
|
3
|
+
address;
|
|
4
|
+
addressesTable;
|
|
5
|
+
constructor(address) {
|
|
6
|
+
this.addressesTable = DatabaseConnection.get().addresses;
|
|
7
|
+
this.address = address;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.address.getId())
|
|
11
|
+
await this.addressesTable.update(this.address);
|
|
12
|
+
else
|
|
13
|
+
await this.addressesTable.insert(this.address);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Admin from "../stockObjects/Admin";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class AdminMapper implements StockObjectMapper {
|
|
4
|
+
private admin;
|
|
5
|
+
private adminAccountsTable;
|
|
6
|
+
constructor(admin: Admin);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class AdminMapper {
|
|
3
|
+
admin;
|
|
4
|
+
adminAccountsTable;
|
|
5
|
+
constructor(admin) {
|
|
6
|
+
this.adminAccountsTable = DatabaseConnection.get().adminAccounts;
|
|
7
|
+
this.admin = admin;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (!this.admin.getDeleted()) {
|
|
11
|
+
if (this.admin.getId())
|
|
12
|
+
await this.adminAccountsTable.update(this.admin);
|
|
13
|
+
else
|
|
14
|
+
await this.adminAccountsTable.insert(this.admin);
|
|
15
|
+
}
|
|
16
|
+
else
|
|
17
|
+
throw new Error(`Admin account ${this.admin.getId()} is deleted. Restore before updating.`);
|
|
18
|
+
}
|
|
19
|
+
async delete() {
|
|
20
|
+
const id = this.admin.getId();
|
|
21
|
+
if (id)
|
|
22
|
+
await this.adminAccountsTable.delete(id);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
2
|
+
import Client from "../stockObjects/Client";
|
|
3
|
+
export default class ClientMapper implements StockObjectMapper {
|
|
4
|
+
private client;
|
|
5
|
+
private clientAccountsTable;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class ClientMapper {
|
|
3
|
+
client;
|
|
4
|
+
clientAccountsTable;
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.clientAccountsTable = DatabaseConnection.get().accounts;
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (!this.client.getDeleted()) {
|
|
11
|
+
if (this.client.getId())
|
|
12
|
+
await this.clientAccountsTable.update(this.client);
|
|
13
|
+
else
|
|
14
|
+
await this.clientAccountsTable.insert(this.client);
|
|
15
|
+
}
|
|
16
|
+
else
|
|
17
|
+
throw new Error(`Client account ${this.client.getId()} is deleted. Restore before updating.`);
|
|
18
|
+
}
|
|
19
|
+
async delete() {
|
|
20
|
+
const id = this.client.getId();
|
|
21
|
+
if (id)
|
|
22
|
+
await this.clientAccountsTable.delete(id);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import CompanyData from "../stockObjects/CompanyData";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class CompanyDataMapper implements StockObjectMapper {
|
|
4
|
+
private companyData;
|
|
5
|
+
private companyDataTable;
|
|
6
|
+
constructor(companyData: CompanyData);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class CompanyDataMapper {
|
|
3
|
+
companyData;
|
|
4
|
+
companyDataTable;
|
|
5
|
+
constructor(companyData) {
|
|
6
|
+
this.companyDataTable = DatabaseConnection.get().companyData;
|
|
7
|
+
this.companyData = companyData;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.companyData.getId())
|
|
11
|
+
await this.companyDataTable.update(this.companyData);
|
|
12
|
+
else
|
|
13
|
+
await this.companyDataTable.insert(this.companyData);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import CompanyDetails from "../stockObjects/CompanyDetails";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class CompanyDetailsMapper implements StockObjectMapper {
|
|
4
|
+
private companyDetails;
|
|
5
|
+
private companyDetailsTable;
|
|
6
|
+
constructor(companyDetails: CompanyDetails);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class CompanyDetailsMapper {
|
|
3
|
+
companyDetails;
|
|
4
|
+
companyDetailsTable;
|
|
5
|
+
constructor(companyDetails) {
|
|
6
|
+
this.companyDetailsTable = DatabaseConnection.get().companyDetails;
|
|
7
|
+
this.companyDetails = companyDetails;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.companyDetails.getId())
|
|
11
|
+
await this.companyDetailsTable.update(this.companyDetails);
|
|
12
|
+
else
|
|
13
|
+
await this.companyDetailsTable.insert(this.companyDetails);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
const id = this.companyDetails.getId();
|
|
17
|
+
if (id)
|
|
18
|
+
await this.companyDetailsTable.delete(id);
|
|
19
|
+
else
|
|
20
|
+
throw Error('Uncreated companyDetails cannot be deleted');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ContactDetails from "../stockObjects/ContactDetails";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class ContactDetailsMapper implements StockObjectMapper {
|
|
4
|
+
private contactDetails;
|
|
5
|
+
private contactDetailsTable;
|
|
6
|
+
constructor(contactDetails: ContactDetails);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class ContactDetailsMapper {
|
|
3
|
+
contactDetails;
|
|
4
|
+
contactDetailsTable;
|
|
5
|
+
constructor(contactDetails) {
|
|
6
|
+
this.contactDetailsTable = DatabaseConnection.get().contactDetails;
|
|
7
|
+
this.contactDetails = contactDetails;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.contactDetails.getId())
|
|
11
|
+
await this.contactDetailsTable.update(this.contactDetails);
|
|
12
|
+
else
|
|
13
|
+
await this.contactDetailsTable.insert(this.contactDetails);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
throw Error('Method not impemented');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import DeliveryDetails from "../stockObjects/DeliveryDetails";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class DeliveryDetailsMapper implements StockObjectMapper {
|
|
4
|
+
private deliveryDetails;
|
|
5
|
+
private deliveryDetailsTable;
|
|
6
|
+
constructor(deliveryDetails: DeliveryDetails);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|