@dascompany/database 0.0.1
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/README.md +1 -0
- package/dist/Connection.d.ts +11 -0
- package/dist/Connection.js +22 -0
- package/dist/Database.d.ts +4 -0
- package/dist/Database.js +14 -0
- package/dist/DatabaseConfig.d.ts +7 -0
- package/dist/DatabaseConfig.js +1 -0
- package/dist/DatabaseConnection.d.ts +11 -0
- package/dist/DatabaseConnection.js +28 -0
- package/dist/SQL.json +123 -0
- package/dist/Table.d.ts +8 -0
- package/dist/Table.js +18 -0
- package/dist/TableConnection.d.ts +68 -0
- package/dist/TableConnection.js +132 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +42 -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/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/DeliveryStatusMapper.d.ts +9 -0
- package/dist/mappers/DeliveryStatusMapper.js +15 -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/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/StatusMapper.d.ts +9 -0
- package/dist/mappers/StatusMapper.js +15 -0
- package/dist/query/BindParams.d.ts +9 -0
- package/dist/query/BindParams.js +56 -0
- package/dist/query/Parameters.d.ts +11 -0
- package/dist/query/Parameters.js +54 -0
- package/dist/query/Query.d.ts +11 -0
- package/dist/query/Query.js +42 -0
- package/dist/query/QueryParamCreator.d.ts +10 -0
- package/dist/query/QueryParamCreator.js +67 -0
- package/dist/query/QueryParams.d.ts +20 -0
- package/dist/query/QueryParams.js +113 -0
- package/dist/query/Result.d.ts +11 -0
- package/dist/query/Result.js +43 -0
- package/dist/query/ResultsCorrector.d.ts +4 -0
- package/dist/query/ResultsCorrector.js +14 -0
- package/dist/reader/AddressesReader.d.ts +6 -0
- package/dist/reader/AddressesReader.js +24 -0
- package/dist/reader/ClientAccountReader.d.ts +7 -0
- package/dist/reader/ClientAccountReader.js +30 -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 +5 -0
- package/dist/reader/DeliveryMethodReader.js +13 -0
- package/dist/reader/DeliveryStatusReader.d.ts +5 -0
- package/dist/reader/DeliveryStatusReader.js +31 -0
- package/dist/reader/FilesReader.d.ts +7 -0
- package/dist/reader/FilesReader.js +26 -0
- package/dist/reader/InvoiceDetailsReader.d.ts +4 -0
- package/dist/reader/InvoiceDetailsReader.js +21 -0
- package/dist/reader/OrderProductsReader.d.ts +6 -0
- package/dist/reader/OrderProductsReader.js +50 -0
- package/dist/reader/OrderReader.d.ts +6 -0
- package/dist/reader/OrderReader.js +37 -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 +10 -0
- package/dist/reader/ProductReader.js +52 -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 +5 -0
- package/dist/reader/payment/PaymentMethodReader.js +13 -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/ClientAccountRepo.d.ts +5 -0
- package/dist/repo/ClientAccountRepo.js +14 -0
- package/dist/repo/CompanyDetailsRepo.d.ts +5 -0
- package/dist/repo/CompanyDetailsRepo.js +14 -0
- package/dist/repo/ContactDetailsRepo.d.ts +5 -0
- package/dist/repo/ContactDetailsRepo.js +14 -0
- package/dist/repo/DeliveryDetailsRepo.d.ts +5 -0
- package/dist/repo/DeliveryDetailsRepo.js +14 -0
- package/dist/repo/InvoiceDetailsRepo.d.ts +5 -0
- package/dist/repo/InvoiceDetailsRepo.js +14 -0
- package/dist/repo/OrderRepo.d.ts +5 -0
- package/dist/repo/OrderRepo.js +14 -0
- package/dist/repo/PaymentDetailsRepo.d.ts +5 -0
- package/dist/repo/PaymentDetailsRepo.js +14 -0
- package/dist/repo/PersonalDataRepo.d.ts +5 -0
- package/dist/repo/PersonalDataRepo.js +16 -0
- package/dist/repo/ProductRepo.d.ts +5 -0
- package/dist/repo/ProductRepo.js +15 -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/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 +15 -0
- package/dist/stockObjects/DeliveryDetails.js +34 -0
- package/dist/stockObjects/DeliveryStatus.d.ts +18 -0
- package/dist/stockObjects/DeliveryStatus.js +42 -0
- package/dist/stockObjects/InvoiceDetails.d.ts +12 -0
- package/dist/stockObjects/InvoiceDetails.js +26 -0
- package/dist/stockObjects/Order.d.ts +40 -0
- package/dist/stockObjects/Order.js +88 -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/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 +40 -0
- package/dist/stockObjects/Product.js +101 -0
- package/dist/stockObjects/Status.d.ts +15 -0
- package/dist/stockObjects/Status.js +34 -0
- package/dist/tables/AdminAccountsTable.d.ts +15 -0
- package/dist/tables/AdminAccountsTable.js +64 -0
- package/dist/tables/ClientAccountsTable.d.ts +14 -0
- package/dist/tables/ClientAccountsTable.js +62 -0
- package/dist/tables/DeliveryStatusTypesTable.d.ts +7 -0
- package/dist/tables/DeliveryStatusTypesTable.js +10 -0
- package/dist/tables/DeliveryStatusesTable.d.ts +9 -0
- package/dist/tables/DeliveryStatusesTable.js +31 -0
- package/dist/tables/ProductsTable.d.ts +9 -0
- package/dist/tables/ProductsTable.js +26 -0
- package/dist/tables/StatusTypesTable.d.ts +4 -0
- package/dist/tables/StatusTypesTable.js +9 -0
- package/dist/tables/files/FilesTable.d.ts +7 -0
- package/dist/tables/files/FilesTable.js +17 -0
- package/dist/tables/orders/OrdersProductsTable.d.ts +8 -0
- package/dist/tables/orders/OrdersProductsTable.js +25 -0
- package/dist/tables/orders/OrdersTable.d.ts +12 -0
- package/dist/tables/orders/OrdersTable.js +50 -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 +10 -0
- package/dist/tables/orders/StatusesTable.js +34 -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/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/store-settings/DeliveryMethodsTable.d.ts +6 -0
- package/dist/tables/store-settings/DeliveryMethodsTable.js +15 -0
- package/dist/tables/store-settings/PaymentMethodsTable.d.ts +6 -0
- package/dist/tables/store-settings/PaymentMethodsTable.js +15 -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/CompanyDetailsI.d.ts +5 -0
- package/dist/types/CompanyDetailsI.js +1 -0
- package/dist/types/ConnectorE.d.ts +5 -0
- package/dist/types/ConnectorE.js +6 -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/FileConnectionE.d.ts +4 -0
- package/dist/types/FileConnectionE.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 +9 -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/ParameterI.d.ts +6 -0
- package/dist/types/ParameterI.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 +21 -0
- package/dist/types/ProductI.js +1 -0
- package/dist/types/QueryOptionsI.d.ts +9 -0
- package/dist/types/QueryOptionsI.js +1 -0
- package/dist/types/ResultLimitationI.d.ts +4 -0
- package/dist/types/ResultLimitationI.js +1 -0
- package/dist/types/StockObject.d.ts +9 -0
- package/dist/types/StockObject.js +15 -0
- package/dist/types/StockObjectMapper.d.ts +4 -0
- package/dist/types/StockObjectMapper.js +1 -0
- package/dist/types/WhereOptionI.d.ts +6 -0
- package/dist/types/WhereOptionI.js +1 -0
- package/dist/types/parameters/ParameterFilter.d.ts +6 -0
- package/dist/types/parameters/ParameterFilter.js +1 -0
- package/dist/types/parameters/ParameterType.d.ts +13 -0
- package/dist/types/parameters/ParameterType.js +14 -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/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/DeliveryStatusRow.d.ts +7 -0
- package/dist/types/rows/DeliveryStatusRow.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 +12 -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/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 +7 -0
- package/dist/types/rows/StatusRow.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 +27 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nowe repo
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client } from 'pg';
|
|
2
|
+
import Query from './query/Query';
|
|
3
|
+
export default class Connection {
|
|
4
|
+
private pgClient;
|
|
5
|
+
constructor(pgClient: Client);
|
|
6
|
+
createQuery(queryString: string): Query;
|
|
7
|
+
beginTransaction(): Promise<void>;
|
|
8
|
+
commitTransaction(): Promise<void>;
|
|
9
|
+
rollBackTransaction(): Promise<void>;
|
|
10
|
+
end(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Query from './query/Query';
|
|
2
|
+
export default class Connection {
|
|
3
|
+
pgClient;
|
|
4
|
+
constructor(pgClient) {
|
|
5
|
+
this.pgClient = pgClient;
|
|
6
|
+
}
|
|
7
|
+
createQuery(queryString) {
|
|
8
|
+
return new Query(this.pgClient, queryString);
|
|
9
|
+
}
|
|
10
|
+
async beginTransaction() {
|
|
11
|
+
await this.pgClient.query('BEGIN');
|
|
12
|
+
}
|
|
13
|
+
async commitTransaction() {
|
|
14
|
+
await this.pgClient.query('COMMIT');
|
|
15
|
+
}
|
|
16
|
+
async rollBackTransaction() {
|
|
17
|
+
await this.pgClient.query('ROLLBACK');
|
|
18
|
+
}
|
|
19
|
+
async end() {
|
|
20
|
+
this.pgClient.end();
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/Database.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
export default class Database {
|
|
3
|
+
static async connect(connectionConfig) {
|
|
4
|
+
try {
|
|
5
|
+
const pgClient = new pg.Client(connectionConfig);
|
|
6
|
+
await pgClient.connect();
|
|
7
|
+
return pgClient;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
error.message = `Database connection failed!\n ${error.message}`;
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,123 @@
|
|
|
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
|
+
"selectNextId": "SELECT nextval('clients.accounts_id'::regclass)",
|
|
15
|
+
"getIdForEmail": "SELECT id FROM clients.accounts WHERE LOWER( email ) = LOWER($email::TEXT)",
|
|
16
|
+
"insert": "INSERT INTO clients.accounts( id, email, activated, contact_details_id) VALUES ($id::BIGINT, LOWER($email::TEXT), $activated::BOOL, $contact_details_id::BIGINT)",
|
|
17
|
+
"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",
|
|
18
|
+
"delete": "DELETE FROM clients.accounts WHERE id = $account_id::BIGINT"
|
|
19
|
+
},
|
|
20
|
+
"contactDetails": {
|
|
21
|
+
"select": "SELECT id, personal_data_id, address_id FROM personal_information.contact_details WHERE id = $id::BIGINT",
|
|
22
|
+
"insert": "INSERT INTO personal_information.contact_details(id, personal_data_id, address_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT)",
|
|
23
|
+
"update": "UPDATE personal_information.contact_details SET personal_data_id = $personal_data_id::BIGINT, address_id = $address_id::BIGINT WHERE id = $id::BIGINT",
|
|
24
|
+
"selectNextId": "SELECT nextval('personal_information.contact_details_id'::regclass)"
|
|
25
|
+
},
|
|
26
|
+
"deliveryDetails": {
|
|
27
|
+
"select": "SELECT id, personal_data_id, address_id, delivery_method_id FROM personal_information.delivery_details WHERE id = $id::BIGINT",
|
|
28
|
+
"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)",
|
|
29
|
+
"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",
|
|
30
|
+
"selectNextId": "SELECT nextval('personal_information.delivery_details_id'::regclass)"
|
|
31
|
+
},
|
|
32
|
+
"invoiceDetails": {
|
|
33
|
+
"select": "SELECT id, personal_data_id, address_id FROM personal_information.invoice_details WHERE id = $id::BIGINT",
|
|
34
|
+
"insert": "INSERT INTO personal_information.invoice_details(id, personal_data_id, address_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT)",
|
|
35
|
+
"update": "UPDATE personal_information.invoice_details SET personal_data_id = $personal_data_id::BIGINT, address_id = $address_id::BIGINT WHERE id = $id::BIGINT",
|
|
36
|
+
"selectNextId": "SELECT nextval('personal_information.invoice_details_id'::regclass)"
|
|
37
|
+
},
|
|
38
|
+
"addresses": {
|
|
39
|
+
"select": "SELECT id, country, city, postal_code, street, house_number, apartment_number FROM personal_information.addresses WHERE id = $id::BIGINT",
|
|
40
|
+
"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) ",
|
|
41
|
+
"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",
|
|
42
|
+
"selectNextId": "SELECT nextval('personal_information.addresses_id'::regclass)"
|
|
43
|
+
},
|
|
44
|
+
"personalData": {
|
|
45
|
+
"select": "SELECT id, first_name, last_name, email, phone_number, company_details_id FROM personal_information.personal_data WHERE id = $id::BIGINT",
|
|
46
|
+
"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)",
|
|
47
|
+
"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",
|
|
48
|
+
"selectNextId": "SELECT nextval('personal_information.personal_data_id'::regclass)"
|
|
49
|
+
},
|
|
50
|
+
"companyDetails": {
|
|
51
|
+
"select": "SELECT id, name, tax_number FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
52
|
+
"insert": "INSERT INTO personal_information.company_details( id, name, tax_number ) VALUES ($id::BIGINT, $name::TEXT, $tax_number::TEXT )",
|
|
53
|
+
"update": "UPDATE personal_information.company_details SET name = $name::TEXT, tax_number = $tax_number::TEXT WHERE id = $id::BIGINT",
|
|
54
|
+
"delete": "DELETE FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
55
|
+
"selectIfIs": "SELECT FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
56
|
+
"selectNextId": "SELECT nextval('personal_information.company_details_id'::regclass)"
|
|
57
|
+
},
|
|
58
|
+
"products": {
|
|
59
|
+
"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",
|
|
60
|
+
"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",
|
|
61
|
+
"selectForSku": "SELECT id as product_id FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
62
|
+
"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)",
|
|
63
|
+
"selectNextId": "SELECT nextval('product_id'::regclass)",
|
|
64
|
+
"count": "SELECT COUNT(*) AS total_rows FROM products WHERE deleted = false $PARAMS"
|
|
65
|
+
},
|
|
66
|
+
"orders": {
|
|
67
|
+
"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",
|
|
68
|
+
"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",
|
|
69
|
+
"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 )",
|
|
70
|
+
"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",
|
|
71
|
+
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)"
|
|
72
|
+
},
|
|
73
|
+
"ordersProducts": {
|
|
74
|
+
"selectForOrder": "SELECT id, order_id, product_id, net_price FROM orders.orders_products WHERE order_id = $order_id::BIGINT AND in_order = true",
|
|
75
|
+
"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 )",
|
|
76
|
+
"selectNextId": "SELECT nextval('orders.orders_products_id'::regclass)"
|
|
77
|
+
},
|
|
78
|
+
"statuses": {
|
|
79
|
+
"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",
|
|
80
|
+
"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",
|
|
81
|
+
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
|
82
|
+
"selectNextId": "SELECT nextval('orders.statuses_id'::regclass)"
|
|
83
|
+
},
|
|
84
|
+
"paymentDetails": {
|
|
85
|
+
"select": "SELECT id, payment_method_id, payment_order_id FROM orders.payment_details WHERE id = $id::BIGINT",
|
|
86
|
+
"insert": "INSERT INTO orders.payment_details(id, payment_method_id, payment_order_id) VALUES ($id::BIGINT, $payment_method_id::BIGINT, $payment_order_id::TEXT)",
|
|
87
|
+
"update": "UPDATE orders.payment_details SET payment_method_id = $payment_method_id::BIGINT, payment_order_id = $payment_order_id::TEXT WHERE id = $id::BIGINT",
|
|
88
|
+
"selectNextId": "SELECT nextval('orders.payment_details_id'::regclass)"
|
|
89
|
+
},
|
|
90
|
+
"files": {
|
|
91
|
+
"select": "SELECT id, name, orginal_name, catalog, size_kb, type, created_at FROM files.files WHERE id = $id::BIGINT",
|
|
92
|
+
"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"
|
|
93
|
+
},
|
|
94
|
+
"paymentMethods": {
|
|
95
|
+
"select": "SELECT * FROM settings.payment_methods WHERE id = $id::BIGINT",
|
|
96
|
+
"selectAll": "SELECT * FROM settings.payment_methods WHERE active = true ORDER BY id"
|
|
97
|
+
},
|
|
98
|
+
"deliveryMethods": {
|
|
99
|
+
"select": "SELECT * FROM settings.delivery_methods WHERE id = $id::BIGINT",
|
|
100
|
+
"selectAll": "SELECT * FROM settings.delivery_methods WHERE active = true ORDER BY id"
|
|
101
|
+
},
|
|
102
|
+
"paymentStatusTypes": {
|
|
103
|
+
"select": "SELECT * FROM orders.payment_status_types WHERE id = $id::BIGINT"
|
|
104
|
+
},
|
|
105
|
+
"deliveryStatusTypes": {
|
|
106
|
+
"select": "SELECT * FROM personal_information.delivery_status_types WHERE id = $id::BIGINT"
|
|
107
|
+
},
|
|
108
|
+
"deliveryStatuses": {
|
|
109
|
+
"select": "SELECT * FROM personal_information.delivery_statuses WHERE delivery_details_id = $delivery_details_id::BIGINT ORDER BY id DESC LIMIT 1",
|
|
110
|
+
"selectAll": "SELECT * FROM personal_information.delivery_statuses WHERE delivery_details_id = $delivery_details_id::BIGINT ORDER BY id DESC",
|
|
111
|
+
"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)",
|
|
112
|
+
"selectNextId": "SELECT nextval('personal_information.delivery_statuses_id'::regclass)"
|
|
113
|
+
},
|
|
114
|
+
"paymentStatuses": {
|
|
115
|
+
"select": "SELECT * FROM orders.payment_statuses WHERE payment_details_id = $payment_details_id::BIGINT ORDER BY id DESC LIMIT 1",
|
|
116
|
+
"selectAll": "SELECT * FROM orders.payment_statuses WHERE payment_details_id = $payment_details_id::BIGINT ORDER BY id DESC",
|
|
117
|
+
"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)",
|
|
118
|
+
"selectNextId": "SELECT nextval('orders.payment_statuses_id'::regclass)"
|
|
119
|
+
},
|
|
120
|
+
"statusTypes": {
|
|
121
|
+
"select": "SELECT * FROM orders.status_types"
|
|
122
|
+
}
|
|
123
|
+
}
|
package/dist/Table.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Connection from './Connection';
|
|
2
|
+
import Query from './query/Query';
|
|
3
|
+
import QueryOptionsI from './types/QueryOptionsI';
|
|
4
|
+
export default abstract class Table {
|
|
5
|
+
private connection;
|
|
6
|
+
constructor(connection: Connection);
|
|
7
|
+
protected createQuery(queryString: string, options?: QueryOptionsI): Query;
|
|
8
|
+
}
|
package/dist/Table.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import QueryParams from './query/QueryParams';
|
|
2
|
+
import BindParams from './query/BindParams';
|
|
3
|
+
export default class Table {
|
|
4
|
+
connection;
|
|
5
|
+
constructor(connection) {
|
|
6
|
+
this.connection = connection;
|
|
7
|
+
}
|
|
8
|
+
createQuery(queryString, options) {
|
|
9
|
+
if (!queryString)
|
|
10
|
+
throw new Error('Nie podano queryString');
|
|
11
|
+
if (options)
|
|
12
|
+
queryString = QueryParams.createParams(queryString, options);
|
|
13
|
+
const query = this.connection.createQuery(queryString);
|
|
14
|
+
if (options)
|
|
15
|
+
BindParams.bindParams(query, options);
|
|
16
|
+
return query;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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/ProductsTable';
|
|
7
|
+
import ClientAccountsTable from './tables/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/DeliveryStatusTypesTable';
|
|
12
|
+
import PaymentMethodsTable from './tables/store-settings/PaymentMethodsTable';
|
|
13
|
+
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
14
|
+
import DeliveryMethodsTable from './tables/store-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/DeliveryStatusesTable';
|
|
20
|
+
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
21
|
+
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
22
|
+
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
23
|
+
import StatusTypesTable from './tables/StatusTypesTable';
|
|
24
|
+
export default class TableConnection extends Connection {
|
|
25
|
+
private _AdminAccountsTable;
|
|
26
|
+
private _StatusTypesTable;
|
|
27
|
+
private _FilesTable;
|
|
28
|
+
private _OrdersTable;
|
|
29
|
+
private _ProductsTable;
|
|
30
|
+
private _StatusesTable;
|
|
31
|
+
private _AddressesTable;
|
|
32
|
+
private _PersonalDataTable;
|
|
33
|
+
private _CompanyDetailsTable;
|
|
34
|
+
private _ClientAccountsTable;
|
|
35
|
+
private _OrdersProductsTable;
|
|
36
|
+
private _ContactDetailsTable;
|
|
37
|
+
private _InvoiceDetailsTable;
|
|
38
|
+
private _PaymentMethodsTable;
|
|
39
|
+
private _DeliveryDetailsTable;
|
|
40
|
+
private _DeliveryMethodsTable;
|
|
41
|
+
private _PaymentStatusTypesTable;
|
|
42
|
+
private _DeliveryStatusTypesTable;
|
|
43
|
+
private _DeliveryStatusesTable;
|
|
44
|
+
private _PaymentDetailsTable;
|
|
45
|
+
private _PaymentStatusesTable;
|
|
46
|
+
constructor(pgClient: Client);
|
|
47
|
+
get adminAccounts(): AdminAccountsTable;
|
|
48
|
+
get statusTypes(): StatusTypesTable;
|
|
49
|
+
get files(): FilesTable;
|
|
50
|
+
get orders(): OrdersTable;
|
|
51
|
+
get products(): ProductsTable;
|
|
52
|
+
get statuses(): StatusesTable;
|
|
53
|
+
get addresses(): AddressesTable;
|
|
54
|
+
get accounts(): ClientAccountsTable;
|
|
55
|
+
get companyDetails(): CompanyDetailsTable;
|
|
56
|
+
get personalData(): PersonalDataTable;
|
|
57
|
+
get ordersProducts(): OrdersProductsTable;
|
|
58
|
+
get contactDetails(): ContactDetailsTable;
|
|
59
|
+
get deliveryDetails(): DeliveryDetailsTable;
|
|
60
|
+
get invoiceDetails(): InvoiceDetailsTable;
|
|
61
|
+
get deliveryMethods(): DeliveryMethodsTable;
|
|
62
|
+
get paymentMethods(): PaymentMethodsTable;
|
|
63
|
+
get paymentStatusTypes(): PaymentStatusTypesTable;
|
|
64
|
+
get deliveryStatusTypes(): DeliveryStatusTypesTable;
|
|
65
|
+
get deliveryStatuses(): DeliveryStatusesTable;
|
|
66
|
+
get paymentDetails(): PaymentDetailsTable;
|
|
67
|
+
get paymentStatuses(): PaymentStatusesTable;
|
|
68
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
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/ProductsTable';
|
|
6
|
+
import ClientAccountsTable from './tables/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/DeliveryStatusTypesTable';
|
|
11
|
+
import PaymentMethodsTable from './tables/store-settings/PaymentMethodsTable';
|
|
12
|
+
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
13
|
+
import DeliveryMethodsTable from './tables/store-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/DeliveryStatusesTable';
|
|
19
|
+
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
20
|
+
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
21
|
+
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
22
|
+
import StatusTypesTable from './tables/StatusTypesTable';
|
|
23
|
+
export default class TableConnection extends Connection {
|
|
24
|
+
_AdminAccountsTable;
|
|
25
|
+
_StatusTypesTable;
|
|
26
|
+
_FilesTable;
|
|
27
|
+
_OrdersTable;
|
|
28
|
+
_ProductsTable;
|
|
29
|
+
_StatusesTable;
|
|
30
|
+
_AddressesTable;
|
|
31
|
+
_PersonalDataTable;
|
|
32
|
+
_CompanyDetailsTable;
|
|
33
|
+
_ClientAccountsTable;
|
|
34
|
+
_OrdersProductsTable;
|
|
35
|
+
_ContactDetailsTable;
|
|
36
|
+
_InvoiceDetailsTable;
|
|
37
|
+
_PaymentMethodsTable;
|
|
38
|
+
_DeliveryDetailsTable;
|
|
39
|
+
_DeliveryMethodsTable;
|
|
40
|
+
_PaymentStatusTypesTable;
|
|
41
|
+
_DeliveryStatusTypesTable;
|
|
42
|
+
_DeliveryStatusesTable;
|
|
43
|
+
_PaymentDetailsTable;
|
|
44
|
+
_PaymentStatusesTable;
|
|
45
|
+
constructor(pgClient) {
|
|
46
|
+
super(pgClient);
|
|
47
|
+
this._AdminAccountsTable = new AdminAccountsTable(this);
|
|
48
|
+
this._StatusTypesTable = new StatusTypesTable(this);
|
|
49
|
+
this._FilesTable = new FilesTable(this);
|
|
50
|
+
this._OrdersTable = new OrdersTable(this);
|
|
51
|
+
this._StatusesTable = new StatusesTable(this);
|
|
52
|
+
this._ProductsTable = new ProductsTable(this);
|
|
53
|
+
this._AddressesTable = new AddressesTable(this);
|
|
54
|
+
this._PersonalDataTable = new PersonalDataTable(this);
|
|
55
|
+
this._CompanyDetailsTable = new CompanyDetailsTable(this);
|
|
56
|
+
this._OrdersProductsTable = new OrdersProductsTable(this);
|
|
57
|
+
this._ContactDetailsTable = new ContactDetailsTable(this);
|
|
58
|
+
this._InvoiceDetailsTable = new InvoiceDetailsTable(this);
|
|
59
|
+
this._ClientAccountsTable = new ClientAccountsTable(this);
|
|
60
|
+
this._PaymentMethodsTable = new PaymentMethodsTable(this);
|
|
61
|
+
this._DeliveryDetailsTable = new DeliveryDetailsTable(this);
|
|
62
|
+
this._DeliveryMethodsTable = new DeliveryMethodsTable(this);
|
|
63
|
+
this._PaymentStatusTypesTable = new PaymentStatusTypesTable(this);
|
|
64
|
+
this._DeliveryStatusTypesTable = new DeliveryStatusTypesTable(this);
|
|
65
|
+
this._DeliveryStatusesTable = new DeliveryStatusesTable(this);
|
|
66
|
+
this._PaymentDetailsTable = new PaymentDetailsTable(this);
|
|
67
|
+
this._PaymentStatusesTable = new PaymentStatusesTable(this);
|
|
68
|
+
}
|
|
69
|
+
get adminAccounts() {
|
|
70
|
+
return this._AdminAccountsTable;
|
|
71
|
+
}
|
|
72
|
+
get statusTypes() {
|
|
73
|
+
return this._StatusTypesTable;
|
|
74
|
+
}
|
|
75
|
+
get files() {
|
|
76
|
+
return this._FilesTable;
|
|
77
|
+
}
|
|
78
|
+
get orders() {
|
|
79
|
+
return this._OrdersTable;
|
|
80
|
+
}
|
|
81
|
+
get products() {
|
|
82
|
+
return this._ProductsTable;
|
|
83
|
+
}
|
|
84
|
+
get statuses() {
|
|
85
|
+
return this._StatusesTable;
|
|
86
|
+
}
|
|
87
|
+
get addresses() {
|
|
88
|
+
return this._AddressesTable;
|
|
89
|
+
}
|
|
90
|
+
get accounts() {
|
|
91
|
+
return this._ClientAccountsTable;
|
|
92
|
+
}
|
|
93
|
+
get companyDetails() {
|
|
94
|
+
return this._CompanyDetailsTable;
|
|
95
|
+
}
|
|
96
|
+
get personalData() {
|
|
97
|
+
return this._PersonalDataTable;
|
|
98
|
+
}
|
|
99
|
+
get ordersProducts() {
|
|
100
|
+
return this._OrdersProductsTable;
|
|
101
|
+
}
|
|
102
|
+
get contactDetails() {
|
|
103
|
+
return this._ContactDetailsTable;
|
|
104
|
+
}
|
|
105
|
+
get deliveryDetails() {
|
|
106
|
+
return this._DeliveryDetailsTable;
|
|
107
|
+
}
|
|
108
|
+
get invoiceDetails() {
|
|
109
|
+
return this._InvoiceDetailsTable;
|
|
110
|
+
}
|
|
111
|
+
get deliveryMethods() {
|
|
112
|
+
return this._DeliveryMethodsTable;
|
|
113
|
+
}
|
|
114
|
+
get paymentMethods() {
|
|
115
|
+
return this._PaymentMethodsTable;
|
|
116
|
+
}
|
|
117
|
+
get paymentStatusTypes() {
|
|
118
|
+
return this._PaymentStatusTypesTable;
|
|
119
|
+
}
|
|
120
|
+
get deliveryStatusTypes() {
|
|
121
|
+
return this._DeliveryStatusTypesTable;
|
|
122
|
+
}
|
|
123
|
+
get deliveryStatuses() {
|
|
124
|
+
return this._DeliveryStatusesTable;
|
|
125
|
+
}
|
|
126
|
+
get paymentDetails() {
|
|
127
|
+
return this._PaymentDetailsTable;
|
|
128
|
+
}
|
|
129
|
+
get paymentStatuses() {
|
|
130
|
+
return this._PaymentStatusesTable;
|
|
131
|
+
}
|
|
132
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import DatabaseConnection from "./DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./reader/AddressesReader";
|
|
3
|
+
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
4
|
+
import CompanyDetailsReader from "./reader/CompanyDetailsReader";
|
|
5
|
+
import ContactDetailsReader from "./reader/ContactDetailsReader";
|
|
6
|
+
import DeliveryDetailsReader from "./reader/DeliveryDetailsReader";
|
|
7
|
+
import DeliveryMethodReader from "./reader/DeliveryMethodReader";
|
|
8
|
+
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
9
|
+
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
10
|
+
import OrderReader from "./reader/OrderReader";
|
|
11
|
+
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
12
|
+
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
13
|
+
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
14
|
+
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
15
|
+
import PersonalDataReader from "./reader/PersonalDataReader";
|
|
16
|
+
import ProductReader from "./reader/ProductReader";
|
|
17
|
+
import AddressesRepo from "./repo/AddressesRepo";
|
|
18
|
+
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
19
|
+
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
20
|
+
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
21
|
+
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
22
|
+
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
23
|
+
import OrderRepo from "./repo/OrderRepo";
|
|
24
|
+
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
25
|
+
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
26
|
+
import ProductRepo from "./repo/ProductRepo";
|
|
27
|
+
import Address from "./stockObjects/Address";
|
|
28
|
+
import Admin from "./stockObjects/Admin";
|
|
29
|
+
import CompanyDetails from "./stockObjects/CompanyDetails";
|
|
30
|
+
import ContactDetails from "./stockObjects/ContactDetails";
|
|
31
|
+
import DeliveryDetails from "./stockObjects/DeliveryDetails";
|
|
32
|
+
import DeliveryStatus from "./stockObjects/DeliveryStatus";
|
|
33
|
+
import InvoiceDetails from "./stockObjects/InvoiceDetails";
|
|
34
|
+
import Order from "./stockObjects/Order";
|
|
35
|
+
import OrderProduct from "./stockObjects/OrderProduct";
|
|
36
|
+
import PaymentDetails from "./stockObjects/PaymentDetails";
|
|
37
|
+
import PaymentStatus from "./stockObjects/PaymentStatus";
|
|
38
|
+
import PersonalData from "./stockObjects/PersonalData";
|
|
39
|
+
import Product from "./stockObjects/Product";
|
|
40
|
+
import Status from "./stockObjects/Status";
|
|
41
|
+
import Client from "./stockObjects/Client";
|
|
42
|
+
export { DatabaseConnection, PaymentDetailsReader, PaymentMethodReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, ProductRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import DatabaseConnection from "./DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./reader/AddressesReader";
|
|
3
|
+
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
4
|
+
import CompanyDetailsReader from "./reader/CompanyDetailsReader";
|
|
5
|
+
import ContactDetailsReader from "./reader/ContactDetailsReader";
|
|
6
|
+
import DeliveryDetailsReader from "./reader/DeliveryDetailsReader";
|
|
7
|
+
import DeliveryMethodReader from "./reader/DeliveryMethodReader";
|
|
8
|
+
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
9
|
+
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
10
|
+
import OrderReader from "./reader/OrderReader";
|
|
11
|
+
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
12
|
+
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
13
|
+
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
14
|
+
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
15
|
+
import PersonalDataReader from "./reader/PersonalDataReader";
|
|
16
|
+
import ProductReader from "./reader/ProductReader";
|
|
17
|
+
import AddressesRepo from "./repo/AddressesRepo";
|
|
18
|
+
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
19
|
+
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
20
|
+
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
21
|
+
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
22
|
+
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
23
|
+
import OrderRepo from "./repo/OrderRepo";
|
|
24
|
+
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
25
|
+
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
26
|
+
import ProductRepo from "./repo/ProductRepo";
|
|
27
|
+
import Address from "./stockObjects/Address";
|
|
28
|
+
import Admin from "./stockObjects/Admin";
|
|
29
|
+
import CompanyDetails from "./stockObjects/CompanyDetails";
|
|
30
|
+
import ContactDetails from "./stockObjects/ContactDetails";
|
|
31
|
+
import DeliveryDetails from "./stockObjects/DeliveryDetails";
|
|
32
|
+
import DeliveryStatus from "./stockObjects/DeliveryStatus";
|
|
33
|
+
import InvoiceDetails from "./stockObjects/InvoiceDetails";
|
|
34
|
+
import Order from "./stockObjects/Order";
|
|
35
|
+
import OrderProduct from "./stockObjects/OrderProduct";
|
|
36
|
+
import PaymentDetails from "./stockObjects/PaymentDetails";
|
|
37
|
+
import PaymentStatus from "./stockObjects/PaymentStatus";
|
|
38
|
+
import PersonalData from "./stockObjects/PersonalData";
|
|
39
|
+
import Product from "./stockObjects/Product";
|
|
40
|
+
import Status from "./stockObjects/Status";
|
|
41
|
+
import Client from "./stockObjects/Client";
|
|
42
|
+
export { DatabaseConnection, PaymentDetailsReader, PaymentMethodReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, ProductRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
|
@@ -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
|
+
}
|