@dascompany/database 1.0.1 → 1.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.
|
@@ -22,7 +22,9 @@ import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
|
22
22
|
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
23
23
|
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
24
24
|
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
25
|
+
import AdminAccountsTable from './tables/public/AdminAccountsTable';
|
|
25
26
|
export default class TableConnection extends Connection {
|
|
27
|
+
private _AdminAccountsTable;
|
|
26
28
|
private _StatusTypesTable;
|
|
27
29
|
private _FilesTable;
|
|
28
30
|
private _OrdersTable;
|
|
@@ -46,6 +48,7 @@ export default class TableConnection extends Connection {
|
|
|
46
48
|
private _CompanyDataTable;
|
|
47
49
|
private _FileConnectionsTable;
|
|
48
50
|
constructor(pgClient: Client);
|
|
51
|
+
get adminAccounts(): AdminAccountsTable;
|
|
49
52
|
get statusTypes(): StatusTypesTable;
|
|
50
53
|
get files(): FilesTable;
|
|
51
54
|
get orders(): OrdersTable;
|
package/dist/TableConnection.js
CHANGED
|
@@ -21,7 +21,9 @@ import PaymentStatusesTable from './tables/orders/PaymentStatusesTable';
|
|
|
21
21
|
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
22
22
|
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
23
23
|
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
24
|
+
import AdminAccountsTable from './tables/public/AdminAccountsTable';
|
|
24
25
|
export default class TableConnection extends Connection {
|
|
26
|
+
_AdminAccountsTable;
|
|
25
27
|
_StatusTypesTable;
|
|
26
28
|
_FilesTable;
|
|
27
29
|
_OrdersTable;
|
|
@@ -46,6 +48,7 @@ export default class TableConnection extends Connection {
|
|
|
46
48
|
_FileConnectionsTable;
|
|
47
49
|
constructor(pgClient) {
|
|
48
50
|
super(pgClient);
|
|
51
|
+
this._AdminAccountsTable = new AdminAccountsTable(this);
|
|
49
52
|
this._StatusTypesTable = new StatusTypesTable(this);
|
|
50
53
|
this._FilesTable = new FilesTable(this);
|
|
51
54
|
this._OrdersTable = new OrdersTable(this);
|
|
@@ -69,6 +72,9 @@ export default class TableConnection extends Connection {
|
|
|
69
72
|
this._CompanyDataTable = new CompanyDataTable(this);
|
|
70
73
|
this._FileConnectionsTable = new FileConnectionsTable(this);
|
|
71
74
|
}
|
|
75
|
+
get adminAccounts() {
|
|
76
|
+
return this._AdminAccountsTable;
|
|
77
|
+
}
|
|
72
78
|
get statusTypes() {
|
|
73
79
|
return this._StatusTypesTable;
|
|
74
80
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import ResultLimitationI from './types/ResultLimitationI';
|
|
|
13
13
|
import Parameters from './utils/Parameters';
|
|
14
14
|
import OrderByI from "./utils/OrderByI";
|
|
15
15
|
import QueryOptions from './query/QueryOptions';
|
|
16
|
+
import AdminAccountsTable from "./tables/public/AdminAccountsTable";
|
|
16
17
|
import Client from "./stockObjects/Client";
|
|
17
18
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
18
19
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
@@ -69,6 +70,7 @@ import Status from "./stockObjects/Status";
|
|
|
69
70
|
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
70
71
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
71
72
|
import StatusI from "./types/StatusI";
|
|
73
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
72
74
|
import ProductI from './types/ProductI';
|
|
73
75
|
import Product from "./stockObjects/Product";
|
|
74
76
|
import ProductRepo from "./repo/ProductRepo";
|
|
@@ -85,5 +87,4 @@ import CompanyData from "./stockObjects/CompanyData";
|
|
|
85
87
|
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
86
88
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
87
89
|
import CompanyDataI from "./types/CompanyDataI";
|
|
88
|
-
|
|
89
|
-
export { DatabaseConnection, StockObject, StockObjectMapper, Table, Query, TableConnection, ParameterType, ParameterFilter, ConnectorE, ParameterI, QueryOptionsI, ResultLimitationI, Parameters, OrderByI, QueryOptions, Client, ClientAccountRepo, ClientAccountReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, ContactDetails, ContactDetailsRepo, ContactDetailsReader, ContactDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryStatus, DeliveryStatusReader, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, InvoiceDetailsI, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusRepo, OrderStatusReader, StatusI, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, StatusTypesReader, };
|
|
90
|
+
export { DatabaseConnection, StockObject, StockObjectMapper, Table, Query, TableConnection, ParameterType, ParameterFilter, ConnectorE, ParameterI, QueryOptionsI, ResultLimitationI, Parameters, OrderByI, QueryOptions, AdminAccountsTable, Client, ClientAccountRepo, ClientAccountReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, ContactDetails, ContactDetailsRepo, ContactDetailsReader, ContactDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryStatus, DeliveryStatusReader, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, InvoiceDetailsI, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusRepo, OrderStatusReader, StatusI, StatusTypesReader, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import ParameterType from './types/parameters/ParameterType';
|
|
|
7
7
|
import ConnectorE from './types/ConnectorE';
|
|
8
8
|
import Parameters from './utils/Parameters';
|
|
9
9
|
import QueryOptions from './query/QueryOptions';
|
|
10
|
+
import AdminAccountsTable from "./tables/public/AdminAccountsTable";
|
|
10
11
|
import Client from "./stockObjects/Client";
|
|
11
12
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
12
13
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
@@ -52,6 +53,7 @@ import OrderProductsReader from "./reader/OrderProductsReader";
|
|
|
52
53
|
import Status from "./stockObjects/Status";
|
|
53
54
|
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
54
55
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
56
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
55
57
|
import Product from "./stockObjects/Product";
|
|
56
58
|
import ProductRepo from "./repo/ProductRepo";
|
|
57
59
|
import ProductReader from "./reader/ProductReader";
|
|
@@ -65,5 +67,4 @@ import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
|
65
67
|
import CompanyData from "./stockObjects/CompanyData";
|
|
66
68
|
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
67
69
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
68
|
-
|
|
69
|
-
export { DatabaseConnection, StockObject, Table, Query, TableConnection, ParameterType, ConnectorE, Parameters, QueryOptions, Client, ClientAccountRepo, ClientAccountReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, ContactDetails, ContactDetailsRepo, ContactDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryStatus, DeliveryStatusReader, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusRepo, OrderStatusReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, StatusTypesReader, };
|
|
70
|
+
export { DatabaseConnection, StockObject, Table, Query, TableConnection, ParameterType, ConnectorE, Parameters, QueryOptions, AdminAccountsTable, Client, ClientAccountRepo, ClientAccountReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, ContactDetails, ContactDetailsRepo, ContactDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryStatus, DeliveryStatusReader, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusRepo, OrderStatusReader, StatusTypesReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import QueryOptionsI from "../../types/QueryOptionsI";
|
|
2
|
+
import Table from "../../Table";
|
|
3
|
+
export default class AdminAccountsTable extends Table {
|
|
4
|
+
select(accountId: number): Promise<any>;
|
|
5
|
+
selectAll(queryOptions: QueryOptionsI): Promise<any[]>;
|
|
6
|
+
selectForEmail(email: string): Promise<number>;
|
|
7
|
+
count(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
|
+
insert(admin: any): Promise<number>;
|
|
9
|
+
update(admin: any): Promise<boolean>;
|
|
10
|
+
delete(accountId: number): Promise<number>;
|
|
11
|
+
private bindParameters;
|
|
12
|
+
private selectNextId;
|
|
13
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Table from "../../Table";
|
|
2
|
+
import * as SQL from '../../SQL.json';
|
|
3
|
+
export default class AdminAccountsTable extends Table {
|
|
4
|
+
async select(accountId) {
|
|
5
|
+
const query = this.createQuery(SQL.adminAccounts.select);
|
|
6
|
+
query.bindParameter('id', accountId);
|
|
7
|
+
const result = await query.execute();
|
|
8
|
+
return result.getRow();
|
|
9
|
+
}
|
|
10
|
+
async selectAll(queryOptions) {
|
|
11
|
+
const query = this.createQuery(SQL.adminAccounts.selectAll, queryOptions);
|
|
12
|
+
const result = await query.execute();
|
|
13
|
+
return result.getRows();
|
|
14
|
+
}
|
|
15
|
+
async selectForEmail(email) {
|
|
16
|
+
const query = this.createQuery(SQL.adminAccounts.selectForEmail);
|
|
17
|
+
query.bindParameter('email', String(email).toUpperCase());
|
|
18
|
+
const result = await query.execute();
|
|
19
|
+
return result.getValue();
|
|
20
|
+
}
|
|
21
|
+
async count(queryOptions) {
|
|
22
|
+
const query = this.createQuery(SQL.adminAccounts.count, queryOptions);
|
|
23
|
+
const result = await query.execute();
|
|
24
|
+
return result.getValue();
|
|
25
|
+
}
|
|
26
|
+
async insert(admin) {
|
|
27
|
+
let accountId = await this.selectForEmail(admin.getEmail());
|
|
28
|
+
if (accountId)
|
|
29
|
+
throw new Error(`Admin account with email: ${admin.getEmail()} already exist!`);
|
|
30
|
+
else
|
|
31
|
+
accountId = await this.selectNextId();
|
|
32
|
+
const query = this.createQuery(SQL.adminAccounts.insert);
|
|
33
|
+
query.bindParameter('id', accountId);
|
|
34
|
+
this.bindParameters(query, admin);
|
|
35
|
+
await query.execute();
|
|
36
|
+
admin.setId(accountId);
|
|
37
|
+
return accountId;
|
|
38
|
+
}
|
|
39
|
+
async update(admin) {
|
|
40
|
+
const query = this.createQuery(SQL.adminAccounts.update);
|
|
41
|
+
query.bindParameter('id', admin.getId());
|
|
42
|
+
this.bindParameters(query, admin);
|
|
43
|
+
await query.execute();
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
async delete(accountId) {
|
|
47
|
+
const query = this.createQuery(SQL.adminAccounts.delete);
|
|
48
|
+
query.bindParameter('id', accountId);
|
|
49
|
+
const result = await query.execute();
|
|
50
|
+
return result.getRowCount();
|
|
51
|
+
}
|
|
52
|
+
bindParameters(query, admin) {
|
|
53
|
+
query.bindParameter('email', admin.getEmail());
|
|
54
|
+
query.bindParameter('first_name', admin.getFirstName());
|
|
55
|
+
query.bindParameter('last_name', admin.getLastName());
|
|
56
|
+
query.bindParameter('activated', admin.getActivated());
|
|
57
|
+
query.bindParameter('deleted', admin.getDeleted());
|
|
58
|
+
}
|
|
59
|
+
async selectNextId() {
|
|
60
|
+
const query = this.createQuery(SQL.adminAccounts.selectNextId);
|
|
61
|
+
const result = await query.execute();
|
|
62
|
+
return result.getValue();
|
|
63
|
+
}
|
|
64
|
+
}
|