@dascompany/database 0.0.3 → 0.0.5
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/SQL.json +26 -2
- package/dist/TableConnection.d.ts +14 -8
- package/dist/TableConnection.js +20 -8
- package/dist/index.d.ts +11 -1
- package/dist/index.js +10 -1
- package/dist/mappers/CompanyDataMapper.d.ts +9 -0
- package/dist/mappers/CompanyDataMapper.js +17 -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/PaymentMethodsMapper.d.ts +9 -0
- package/dist/mappers/PaymentMethodsMapper.js +17 -0
- package/dist/mappers/ProductMapper.d.ts +9 -0
- package/dist/mappers/ProductMapper.js +18 -0
- package/dist/reader/CompanyDataReader.d.ts +4 -0
- package/dist/reader/CompanyDataReader.js +27 -0
- package/dist/reader/FileConnectionsReader.d.ts +6 -0
- package/dist/reader/FileConnectionsReader.js +25 -0
- package/dist/reader/FilesReader.d.ts +5 -0
- package/dist/reader/FilesReader.js +24 -5
- package/dist/reader/ProductReader.d.ts +2 -0
- package/dist/reader/ProductReader.js +21 -0
- package/dist/reader/StatusTypesReader.d.ts +3 -0
- package/dist/reader/StatusTypesReader.js +8 -0
- package/dist/reader/payment/PaymentMethodReader.d.ts +1 -0
- package/dist/reader/payment/PaymentMethodReader.js +5 -0
- package/dist/repo/CompanyDataRepo.d.ts +4 -0
- package/dist/repo/CompanyDataRepo.js +11 -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/PaymentMethodRepo.d.ts +4 -0
- package/dist/repo/PaymentMethodRepo.js +11 -0
- package/dist/stockObjects/CompanyData.d.ts +21 -0
- package/dist/stockObjects/CompanyData.js +51 -0
- package/dist/stockObjects/DeliveryDetails.d.ts +1 -0
- package/dist/stockObjects/DeliveryDetails.js +3 -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/PaymentDetails.d.ts +1 -1
- package/dist/stockObjects/PaymentDetails.js +1 -1
- package/dist/stockObjects/PaymentMethods.d.ts +12 -0
- package/dist/stockObjects/PaymentMethods.js +26 -0
- package/dist/stockObjects/Product.d.ts +30 -0
- package/dist/stockObjects/Product.js +60 -1
- package/dist/tables/{ClientAccountsTable.d.ts → clients/ClientAccountsTable.d.ts} +4 -4
- package/dist/tables/{ClientAccountsTable.js → clients/ClientAccountsTable.js} +2 -2
- package/dist/tables/files/FileConnectionsTable.d.ts +12 -0
- package/dist/tables/files/FileConnectionsTable.js +41 -0
- package/dist/tables/files/FilesTable.d.ts +10 -0
- package/dist/tables/files/FilesTable.js +48 -0
- package/dist/tables/{DeliveryStatusTypesTable.d.ts → personalInformation/DeliveryStatusTypesTable.d.ts} +1 -1
- package/dist/tables/{DeliveryStatusTypesTable.js → personalInformation/DeliveryStatusTypesTable.js} +2 -2
- package/dist/tables/{DeliveryStatusesTable.d.ts → personalInformation/DeliveryStatusesTable.d.ts} +3 -3
- package/dist/tables/{DeliveryStatusesTable.js → personalInformation/DeliveryStatusesTable.js} +2 -2
- package/dist/tables/{AdminAccountsTable.d.ts → public/AdminAccountsTable.d.ts} +4 -4
- package/dist/tables/{AdminAccountsTable.js → public/AdminAccountsTable.js} +2 -2
- package/dist/tables/{ProductsTable.d.ts → public/ProductsTable.d.ts} +4 -4
- package/dist/tables/{ProductsTable.js → public/ProductsTable.js} +2 -2
- package/dist/tables/settings/CompanyDataTable.d.ts +10 -0
- package/dist/tables/settings/CompanyDataTable.js +37 -0
- package/dist/tables/settings/PaymentMethodsTable.d.ts +12 -0
- package/dist/tables/settings/PaymentMethodsTable.js +43 -0
- package/dist/types/CompanyDataI.d.ts +8 -0
- package/dist/types/CompanyDataI.js +1 -0
- package/dist/types/FileConnectionI.d.ts +6 -0
- package/dist/types/FileConnectionI.js +1 -0
- package/dist/types/PersonalDataI.d.ts +1 -1
- package/dist/types/QueryOptionsI.d.ts +2 -1
- package/dist/types/rows/CompanyDataRow.d.ts +8 -0
- package/dist/types/rows/CompanyDataRow.js +1 -0
- package/dist/types/rows/FileConnectionRow.d.ts +6 -0
- package/dist/types/rows/FileConnectionRow.js +1 -0
- package/dist/types/rows/PaymentMethodRow.d.ts +5 -0
- package/dist/types/rows/PaymentMethodRow.js +1 -0
- package/package.json +1 -1
- package/dist/tables/StatusTypesTable.d.ts +0 -4
- package/dist/tables/StatusTypesTable.js +0 -9
- package/dist/tables/store-settings/PaymentMethodsTable.d.ts +0 -6
- package/dist/tables/store-settings/PaymentMethodsTable.js +0 -15
- /package/dist/tables/{store-settings → settings}/DeliveryMethodsTable.d.ts +0 -0
- /package/dist/tables/{store-settings → settings}/DeliveryMethodsTable.js +0 -0
package/dist/SQL.json
CHANGED
|
@@ -99,12 +99,30 @@
|
|
|
99
99
|
"selectNextId": "SELECT nextval('orders.payment_details_id'::regclass)"
|
|
100
100
|
},
|
|
101
101
|
"files": {
|
|
102
|
+
"selectId": "SELECT id FROM files.files $WHERE",
|
|
103
|
+
"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",
|
|
102
104
|
"select": "SELECT id, name, orginal_name, catalog, size_kb, type, created_at FROM files.files WHERE id = $id::BIGINT",
|
|
103
|
-
"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"
|
|
105
|
+
"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",
|
|
106
|
+
"selectNextId": "SELECT nextval('files.files_id'::regclass)",
|
|
107
|
+
"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() )",
|
|
108
|
+
"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 ",
|
|
109
|
+
"count": "SELECT COUNT(*) AS total_rows FROM files.files as f $WHERE ",
|
|
110
|
+
"delete": "DELETE FROM files.files WHERE id = $id::BIGINT "
|
|
111
|
+
},
|
|
112
|
+
"fileConnections": {
|
|
113
|
+
"select": "SELECT file_id, sequence FROM files.file_connections WHERE connection_type = $connection_type::BIGINT and connection_id = $connection_id::BIGINT",
|
|
114
|
+
"selectForFileId": "SELECT * FROM files.file_connections WHERE file_id = $file_id::BIGINT",
|
|
115
|
+
"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)",
|
|
116
|
+
"delete": "DELETE FROM files.file_connections WHERE file_id = $file_id::BIGINT",
|
|
117
|
+
"deleteForConnection": "DELETE FROM files.file_connections WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT"
|
|
104
118
|
},
|
|
105
119
|
"paymentMethods": {
|
|
106
120
|
"select": "SELECT * FROM settings.payment_methods WHERE id = $id::BIGINT",
|
|
107
|
-
"selectAll": "SELECT * FROM settings.payment_methods
|
|
121
|
+
"selectAll": "SELECT * FROM settings.payment_methods ORDER BY id",
|
|
122
|
+
"selectAllActive": "SELECT * FROM settings.payment_methods WHERE active=true ORDER BY id",
|
|
123
|
+
"insert": "INSERT INTO settings.payment_methods(id, key, active) VALUES ( $id::BIGINT, $key::TEXT, $active::BOOL)",
|
|
124
|
+
"update": "UPDATE settings.payment_methods SET id = $id::BIGINT, key = $key::TEXT, active = $active::BOOL WHERE id = $id::BIGINT",
|
|
125
|
+
"selectNextId": "SELECT nextval('settings.payment_methods_id'::regclass)"
|
|
108
126
|
},
|
|
109
127
|
"deliveryMethods": {
|
|
110
128
|
"select": "SELECT * FROM settings.delivery_methods WHERE id = $id::BIGINT",
|
|
@@ -134,5 +152,11 @@
|
|
|
134
152
|
},
|
|
135
153
|
"statusTypes": {
|
|
136
154
|
"select": "SELECT * FROM orders.status_types"
|
|
155
|
+
},
|
|
156
|
+
"companyData": {
|
|
157
|
+
"select": "SELECT * FROM settings.company_data ORDER BY id DESC LIMIT 1",
|
|
158
|
+
"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 )",
|
|
159
|
+
"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",
|
|
160
|
+
"selectNextId": "SELECT nextval('settings.company_data_id'::regclass)"
|
|
137
161
|
}
|
|
138
162
|
}
|
|
@@ -3,24 +3,26 @@ import Connection from './Connection';
|
|
|
3
3
|
import OrdersTable from './tables/orders/OrdersTable';
|
|
4
4
|
import FilesTable from './tables/files/FilesTable';
|
|
5
5
|
import StatusesTable from './tables/orders/StatusesTable';
|
|
6
|
-
import ProductsTable from './tables/ProductsTable';
|
|
7
|
-
import ClientAccountsTable from './tables/ClientAccountsTable';
|
|
6
|
+
import ProductsTable from './tables/public/ProductsTable';
|
|
7
|
+
import ClientAccountsTable from './tables/clients/ClientAccountsTable';
|
|
8
8
|
import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
9
9
|
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
10
10
|
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
11
|
-
import DeliveryStatusTypesTable from './tables/DeliveryStatusTypesTable';
|
|
12
|
-
import PaymentMethodsTable from './tables/
|
|
11
|
+
import DeliveryStatusTypesTable from './tables/personalInformation/DeliveryStatusTypesTable';
|
|
12
|
+
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
13
13
|
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
14
|
-
import DeliveryMethodsTable from './tables/
|
|
14
|
+
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
15
15
|
import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
|
|
16
16
|
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
17
17
|
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
18
18
|
import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
|
|
19
|
-
import DeliveryStatusesTable from './tables/DeliveryStatusesTable';
|
|
19
|
+
import DeliveryStatusesTable from './tables/personalInformation/DeliveryStatusesTable';
|
|
20
20
|
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
21
21
|
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
22
|
-
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
23
|
-
import StatusTypesTable from './tables/StatusTypesTable';
|
|
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';
|
|
24
26
|
export default class TableConnection extends Connection {
|
|
25
27
|
private _AdminAccountsTable;
|
|
26
28
|
private _StatusTypesTable;
|
|
@@ -43,6 +45,8 @@ export default class TableConnection extends Connection {
|
|
|
43
45
|
private _DeliveryStatusesTable;
|
|
44
46
|
private _PaymentDetailsTable;
|
|
45
47
|
private _PaymentStatusesTable;
|
|
48
|
+
private _CompanyDataTable;
|
|
49
|
+
private _FileConnectionsTable;
|
|
46
50
|
constructor(pgClient: Client);
|
|
47
51
|
get adminAccounts(): AdminAccountsTable;
|
|
48
52
|
get statusTypes(): StatusTypesTable;
|
|
@@ -65,4 +69,6 @@ export default class TableConnection extends Connection {
|
|
|
65
69
|
get deliveryStatuses(): DeliveryStatusesTable;
|
|
66
70
|
get paymentDetails(): PaymentDetailsTable;
|
|
67
71
|
get paymentStatuses(): PaymentStatusesTable;
|
|
72
|
+
get companyData(): CompanyDataTable;
|
|
73
|
+
get fileConnections(): FileConnectionsTable;
|
|
68
74
|
}
|
package/dist/TableConnection.js
CHANGED
|
@@ -2,24 +2,26 @@ import Connection from './Connection';
|
|
|
2
2
|
import OrdersTable from './tables/orders/OrdersTable';
|
|
3
3
|
import FilesTable from './tables/files/FilesTable';
|
|
4
4
|
import StatusesTable from './tables/orders/StatusesTable';
|
|
5
|
-
import ProductsTable from './tables/ProductsTable';
|
|
6
|
-
import ClientAccountsTable from './tables/ClientAccountsTable';
|
|
5
|
+
import ProductsTable from './tables/public/ProductsTable';
|
|
6
|
+
import ClientAccountsTable from './tables/clients/ClientAccountsTable';
|
|
7
7
|
import OrdersProductsTable from './tables/orders/OrdersProductsTable';
|
|
8
8
|
import PaymentStatusTypesTable from './tables/orders/PaymentStatusTypesTable';
|
|
9
9
|
import AddressesTable from './tables/personalInformation/AddressesTable';
|
|
10
|
-
import DeliveryStatusTypesTable from './tables/DeliveryStatusTypesTable';
|
|
11
|
-
import PaymentMethodsTable from './tables/
|
|
10
|
+
import DeliveryStatusTypesTable from './tables/personalInformation/DeliveryStatusTypesTable';
|
|
11
|
+
import PaymentMethodsTable from './tables/settings/PaymentMethodsTable';
|
|
12
12
|
import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
|
|
13
|
-
import DeliveryMethodsTable from './tables/
|
|
13
|
+
import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
|
|
14
14
|
import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
|
|
15
15
|
import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
|
|
16
16
|
import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
|
|
17
17
|
import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
|
|
18
|
-
import DeliveryStatusesTable from './tables/DeliveryStatusesTable';
|
|
18
|
+
import DeliveryStatusesTable from './tables/personalInformation/DeliveryStatusesTable';
|
|
19
19
|
import PaymentDetailsTable from './tables/orders/PaymentDetailsTable';
|
|
20
20
|
import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
21
|
-
import AdminAccountsTable from './tables/AdminAccountsTable';
|
|
22
|
-
import StatusTypesTable from './tables/StatusTypesTable';
|
|
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';
|
|
23
25
|
export default class TableConnection extends Connection {
|
|
24
26
|
_AdminAccountsTable;
|
|
25
27
|
_StatusTypesTable;
|
|
@@ -42,6 +44,8 @@ export default class TableConnection extends Connection {
|
|
|
42
44
|
_DeliveryStatusesTable;
|
|
43
45
|
_PaymentDetailsTable;
|
|
44
46
|
_PaymentStatusesTable;
|
|
47
|
+
_CompanyDataTable;
|
|
48
|
+
_FileConnectionsTable;
|
|
45
49
|
constructor(pgClient) {
|
|
46
50
|
super(pgClient);
|
|
47
51
|
this._AdminAccountsTable = new AdminAccountsTable(this);
|
|
@@ -65,6 +69,8 @@ export default class TableConnection extends Connection {
|
|
|
65
69
|
this._DeliveryStatusesTable = new DeliveryStatusesTable(this);
|
|
66
70
|
this._PaymentDetailsTable = new PaymentDetailsTable(this);
|
|
67
71
|
this._PaymentStatusesTable = new PaymentStatusesTable(this);
|
|
72
|
+
this._CompanyDataTable = new CompanyDataTable(this);
|
|
73
|
+
this._FileConnectionsTable = new FileConnectionsTable(this);
|
|
68
74
|
}
|
|
69
75
|
get adminAccounts() {
|
|
70
76
|
return this._AdminAccountsTable;
|
|
@@ -129,4 +135,10 @@ export default class TableConnection extends Connection {
|
|
|
129
135
|
get paymentStatuses() {
|
|
130
136
|
return this._PaymentStatusesTable;
|
|
131
137
|
}
|
|
138
|
+
get companyData() {
|
|
139
|
+
return this._CompanyDataTable;
|
|
140
|
+
}
|
|
141
|
+
get fileConnections() {
|
|
142
|
+
return this._FileConnectionsTable;
|
|
143
|
+
}
|
|
132
144
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,12 +18,14 @@ import ProductReader from "./reader/ProductReader";
|
|
|
18
18
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
19
19
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
20
20
|
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
21
|
+
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
21
22
|
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
22
23
|
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
23
24
|
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
24
25
|
import OrderRepo from "./repo/OrderRepo";
|
|
25
26
|
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
26
27
|
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
28
|
+
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
27
29
|
import ProductRepo from "./repo/ProductRepo";
|
|
28
30
|
import Address from "./stockObjects/Address";
|
|
29
31
|
import Admin from "./stockObjects/Admin";
|
|
@@ -52,4 +54,12 @@ import ResultLimitationI from './types/ResultLimitationI';
|
|
|
52
54
|
import ParameterFilter from './types/parameters/ParameterFilter';
|
|
53
55
|
import PaymentStatusE from './types/PaymentStatusE';
|
|
54
56
|
import OrderProductI from './types/OrderProductI';
|
|
55
|
-
|
|
57
|
+
import Parameters from './utils/Parameters';
|
|
58
|
+
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
59
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
60
|
+
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
61
|
+
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
62
|
+
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
63
|
+
import OrderByI from "./utils/OrderByI";
|
|
64
|
+
import FilesRepo from './repo/FilesRepo';
|
|
65
|
+
export { TableConnection, DatabaseConnection, OrderByI, ParameterType, ConnectorE, FileConnectionE, PaymentStatusE, Parameters, ParameterI, QueryOptionsI, ResultLimitationI, OrderProductI, ParameterFilter, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, CompanyDataReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, FilesRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
package/dist/index.js
CHANGED
|
@@ -18,12 +18,14 @@ import ProductReader from "./reader/ProductReader";
|
|
|
18
18
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
19
19
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
20
20
|
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
21
|
+
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
21
22
|
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
22
23
|
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
23
24
|
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
24
25
|
import OrderRepo from "./repo/OrderRepo";
|
|
25
26
|
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
26
27
|
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
28
|
+
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
27
29
|
import ProductRepo from "./repo/ProductRepo";
|
|
28
30
|
import Address from "./stockObjects/Address";
|
|
29
31
|
import Admin from "./stockObjects/Admin";
|
|
@@ -47,4 +49,11 @@ import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
|
47
49
|
import FileConnectionE from './types/FileConnectionE';
|
|
48
50
|
import ConnectorE from './types/ConnectorE';
|
|
49
51
|
import PaymentStatusE from './types/PaymentStatusE';
|
|
50
|
-
|
|
52
|
+
import Parameters from './utils/Parameters';
|
|
53
|
+
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
54
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
55
|
+
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
56
|
+
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
57
|
+
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
58
|
+
import FilesRepo from './repo/FilesRepo';
|
|
59
|
+
export { TableConnection, DatabaseConnection, ParameterType, ConnectorE, FileConnectionE, PaymentStatusE, Parameters, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, CompanyDataReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, FilesRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
|
@@ -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 FileConnection from '../stockObjects/FileConnection';
|
|
2
|
+
import StockObjectMapper from '../types/StockObjectMapper';
|
|
3
|
+
export default class FileConnectionMapper implements StockObjectMapper {
|
|
4
|
+
private fileConnection;
|
|
5
|
+
private fileConnectionsTable;
|
|
6
|
+
constructor(fileConnection: FileConnection);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from '../DatabaseConnection';
|
|
2
|
+
export default class FileConnectionMapper {
|
|
3
|
+
fileConnection;
|
|
4
|
+
fileConnectionsTable;
|
|
5
|
+
constructor(fileConnection) {
|
|
6
|
+
this.fileConnectionsTable = DatabaseConnection.get().fileConnections;
|
|
7
|
+
this.fileConnection = fileConnection;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
const id = this.fileConnection.getId();
|
|
11
|
+
if (id)
|
|
12
|
+
await this.fileConnectionsTable.delete(id);
|
|
13
|
+
await this.fileConnectionsTable.insert(this.fileConnection);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import File from "../stockObjects/File";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class FileMapper implements StockObjectMapper {
|
|
4
|
+
private file;
|
|
5
|
+
private filesTable;
|
|
6
|
+
constructor(file: File);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class FileMapper {
|
|
3
|
+
file;
|
|
4
|
+
filesTable;
|
|
5
|
+
constructor(file) {
|
|
6
|
+
this.filesTable = DatabaseConnection.get().files;
|
|
7
|
+
this.file = file;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.file.getId())
|
|
11
|
+
await this.filesTable.update(this.file);
|
|
12
|
+
else
|
|
13
|
+
await this.filesTable.insert(this.file);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import PaymentMethods from "../stockObjects/PaymentMethods";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class PaymentMethodsMapper implements StockObjectMapper {
|
|
4
|
+
private paymentMethods;
|
|
5
|
+
private paymentMethodsTable;
|
|
6
|
+
constructor(paymentMethods: PaymentMethods);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class PaymentMethodsMapper {
|
|
3
|
+
paymentMethods;
|
|
4
|
+
paymentMethodsTable;
|
|
5
|
+
constructor(paymentMethods) {
|
|
6
|
+
this.paymentMethodsTable = DatabaseConnection.get().paymentMethods;
|
|
7
|
+
this.paymentMethods = paymentMethods;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.paymentMethods.getId())
|
|
11
|
+
await this.paymentMethodsTable.update(this.paymentMethods);
|
|
12
|
+
else
|
|
13
|
+
await this.paymentMethodsTable.insert(this.paymentMethods);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Product from "../stockObjects/Product";
|
|
2
|
+
import StockObjectMapper from "../types/StockObjectMapper";
|
|
3
|
+
export default class ProductMapper implements StockObjectMapper {
|
|
4
|
+
private product;
|
|
5
|
+
private productTable;
|
|
6
|
+
constructor(product: Product);
|
|
7
|
+
save(): Promise<void>;
|
|
8
|
+
delete(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class ProductMapper {
|
|
3
|
+
product;
|
|
4
|
+
productTable;
|
|
5
|
+
constructor(product) {
|
|
6
|
+
this.productTable = DatabaseConnection.get().products;
|
|
7
|
+
this.product = product;
|
|
8
|
+
}
|
|
9
|
+
async save() {
|
|
10
|
+
if (this.product.getId() && !this.product.getDeleted())
|
|
11
|
+
await this.productTable.update(this.product);
|
|
12
|
+
else
|
|
13
|
+
await this.productTable.insert(this.product);
|
|
14
|
+
}
|
|
15
|
+
async delete() {
|
|
16
|
+
await this.productTable.delete(this.product.getId());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./AddressesReader";
|
|
3
|
+
export default class CompanyDataReader {
|
|
4
|
+
static async get() {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const companyData = await connection.companyData.select();
|
|
7
|
+
if (companyData) {
|
|
8
|
+
const address = companyData?.address_id ? await AddressesReader.get(companyData.address_id) : null;
|
|
9
|
+
return {
|
|
10
|
+
id: companyData.id,
|
|
11
|
+
name: companyData.name,
|
|
12
|
+
taxNumber: companyData.tax_number,
|
|
13
|
+
phoneNumber: companyData.phone_number,
|
|
14
|
+
address: address
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return {
|
|
19
|
+
id: 0,
|
|
20
|
+
name: '',
|
|
21
|
+
taxNumber: '',
|
|
22
|
+
phoneNumber: '',
|
|
23
|
+
address: {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
export default class FileConnectionsReader {
|
|
3
|
+
static async getAllForFileId(fileId) {
|
|
4
|
+
const connection = DatabaseConnection.get();
|
|
5
|
+
const fileConnections = await connection.fileConnections.selectForFileId(fileId);
|
|
6
|
+
return this.correctFileConnections(fileConnections);
|
|
7
|
+
}
|
|
8
|
+
static correctFileConnections(fileConnectionsRows) {
|
|
9
|
+
const fileConnections = [];
|
|
10
|
+
for (let i = 0; i < fileConnectionsRows.length; i++) {
|
|
11
|
+
const fileConnection = this.correctFileConnection(fileConnectionsRows[i]);
|
|
12
|
+
fileConnections.push(fileConnection);
|
|
13
|
+
}
|
|
14
|
+
return fileConnections;
|
|
15
|
+
}
|
|
16
|
+
static correctFileConnection(fileConnections) {
|
|
17
|
+
const correctFileConnection = {
|
|
18
|
+
fileId: fileConnections.file_id,
|
|
19
|
+
connectionType: fileConnections.connection_type,
|
|
20
|
+
connectionId: fileConnections.connection_id,
|
|
21
|
+
sequence: fileConnections.sequence
|
|
22
|
+
};
|
|
23
|
+
return correctFileConnection;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import FileConnectionE from "../types/FileConnectionE";
|
|
2
2
|
import FileI from "../types/FileI";
|
|
3
|
+
import QueryOptionsI from "../types/QueryOptionsI";
|
|
3
4
|
export default class FilesReader {
|
|
4
5
|
static get(fileId: number): Promise<FileI>;
|
|
6
|
+
static getAll(queryOptions: QueryOptionsI): Promise<FileI[]>;
|
|
7
|
+
static isExist(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
|
+
static getQuantity(queryOptions: any): Promise<number>;
|
|
5
9
|
static getForConnection(connectionType: FileConnectionE, connectionId: number): Promise<FileI[]>;
|
|
10
|
+
private static correctFiles;
|
|
6
11
|
private static correctFile;
|
|
7
12
|
}
|
|
@@ -5,14 +5,33 @@ export default class FilesReader {
|
|
|
5
5
|
const file = await connection.files.select(fileId);
|
|
6
6
|
return this.correctFile(file);
|
|
7
7
|
}
|
|
8
|
+
static async getAll(queryOptions) {
|
|
9
|
+
const connection = DatabaseConnection.get();
|
|
10
|
+
const file = await connection.files.selectAll(queryOptions);
|
|
11
|
+
return this.correctFiles(file);
|
|
12
|
+
}
|
|
13
|
+
static async isExist(queryOptions) {
|
|
14
|
+
const connection = DatabaseConnection.get();
|
|
15
|
+
const fileId = await connection.files.selectId(queryOptions);
|
|
16
|
+
return fileId;
|
|
17
|
+
}
|
|
18
|
+
static async getQuantity(queryOptions) {
|
|
19
|
+
const connection = DatabaseConnection.get();
|
|
20
|
+
const quantity = await connection.files.count(queryOptions);
|
|
21
|
+
return quantity;
|
|
22
|
+
}
|
|
8
23
|
static async getForConnection(connectionType, connectionId) {
|
|
9
24
|
const connection = DatabaseConnection.get();
|
|
10
25
|
const files = await connection.files.selectForConnection(connectionType, connectionId);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
return this.correctFiles(files);
|
|
27
|
+
}
|
|
28
|
+
static correctFiles(fileRows) {
|
|
29
|
+
const fileConnections = [];
|
|
30
|
+
for (let i = 0; i < fileRows.length; i++) {
|
|
31
|
+
const fileConnection = this.correctFile(fileRows[i]);
|
|
32
|
+
fileConnections.push(fileConnection);
|
|
33
|
+
}
|
|
34
|
+
return fileConnections;
|
|
16
35
|
}
|
|
17
36
|
static correctFile(file) {
|
|
18
37
|
const correctFile = {
|
|
@@ -3,8 +3,10 @@ import QueryOptionsI from "../types/QueryOptionsI";
|
|
|
3
3
|
export default class ProductReader {
|
|
4
4
|
static get(productId: number): Promise<ProductI>;
|
|
5
5
|
static getForUrl(productUrl: string): Promise<ProductI>;
|
|
6
|
+
static getListForOrder(): Promise<any>;
|
|
6
7
|
static getAll(queryOptions: QueryOptionsI): Promise<ProductI[]>;
|
|
7
8
|
static getQuantity(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
9
|
private static correctProducts;
|
|
9
10
|
private static correctProduct;
|
|
11
|
+
private static correctProductForOrderList;
|
|
10
12
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
|
+
import FilesReader from "./FilesReader";
|
|
3
4
|
export default class ProductReader {
|
|
4
5
|
static async get(productId) {
|
|
5
6
|
const connection = DatabaseConnection.get();
|
|
@@ -11,6 +12,17 @@ export default class ProductReader {
|
|
|
11
12
|
const product = await connection.products.selectForUrl(productUrl);
|
|
12
13
|
return this.correctProduct(product);
|
|
13
14
|
}
|
|
15
|
+
static async getListForOrder() {
|
|
16
|
+
const connection = DatabaseConnection.get();
|
|
17
|
+
let correctProducts = [];
|
|
18
|
+
const products = await connection.products.selectListForOrder();
|
|
19
|
+
for (const product of products) {
|
|
20
|
+
const file = await FilesReader.get(product.file_id);
|
|
21
|
+
product.file = file;
|
|
22
|
+
correctProducts.push(this.correctProductForOrderList(product));
|
|
23
|
+
}
|
|
24
|
+
return correctProducts;
|
|
25
|
+
}
|
|
14
26
|
static async getAll(queryOptions) {
|
|
15
27
|
const connection = DatabaseConnection.get();
|
|
16
28
|
const products = await connection.products.selectAll(queryOptions);
|
|
@@ -49,4 +61,13 @@ export default class ProductReader {
|
|
|
49
61
|
grossPrice: calculateNetToGrossPrice(product.net_price, product.vat)
|
|
50
62
|
};
|
|
51
63
|
}
|
|
64
|
+
static correctProductForOrderList(product) {
|
|
65
|
+
return {
|
|
66
|
+
id: product.id,
|
|
67
|
+
title: product.title,
|
|
68
|
+
sku: product.sku,
|
|
69
|
+
file: product.file,
|
|
70
|
+
netPrice: product.net_price
|
|
71
|
+
};
|
|
72
|
+
}
|
|
52
73
|
}
|
|
@@ -10,4 +10,9 @@ export default class PaymentMethodReader {
|
|
|
10
10
|
const paymentMethods = await connection.paymentMethods.selectAll();
|
|
11
11
|
return paymentMethods;
|
|
12
12
|
}
|
|
13
|
+
static async getAllActive() {
|
|
14
|
+
const connection = DatabaseConnection.get();
|
|
15
|
+
const paymentMethods = await connection.paymentMethods.selectAllActive();
|
|
16
|
+
return paymentMethods;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import CompanyData from "../stockObjects/CompanyData";
|
|
3
|
+
export default class CompanyDataRepo {
|
|
4
|
+
static async get() {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const companyDataRow = await connection.companyData.select();
|
|
7
|
+
const companyData = new CompanyData(companyDataRow.name, companyDataRow.tax_number, companyDataRow.phone_number, companyDataRow.email, companyDataRow.address_id);
|
|
8
|
+
companyData.setId(companyDataRow.id);
|
|
9
|
+
return companyData;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import DeliveryMethods from "../stockObjects/DeliveryMethods";
|
|
3
|
+
export default class DeliveryMethodRepo {
|
|
4
|
+
static async get(id) {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const deliveryMethodsRow = await connection.deliveryMethods.select(id);
|
|
7
|
+
const deliveryMethods = new DeliveryMethods(deliveryMethodsRow.key, deliveryMethodsRow.active);
|
|
8
|
+
deliveryMethods.setId(deliveryMethodsRow.id);
|
|
9
|
+
return deliveryMethods;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import FileConnection from "../stockObjects/FileConnection";
|
|
2
|
+
export default class FileConnectionsRepo {
|
|
3
|
+
static getAllForFileId(fileId: number): Promise<FileConnection[]>;
|
|
4
|
+
static deleteAllForConnection(connectionType: string, connectionId: number): Promise<boolean>;
|
|
5
|
+
private static correctFileConnections;
|
|
6
|
+
private static correctFileConnection;
|
|
7
|
+
}
|