@dascompany/database 1.0.0 → 1.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/dist/TableConnection.d.ts +0 -3
- package/dist/TableConnection.js +0 -6
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/package.json +1 -1
- package/dist/mappers/AdminMapper.d.ts +0 -9
- package/dist/mappers/AdminMapper.js +0 -24
- package/dist/repo/AdminRepo.d.ts +0 -12
- package/dist/repo/AdminRepo.js +0 -32
- package/dist/stockObjects/Admin.d.ts +0 -25
- package/dist/stockObjects/Admin.js +0 -57
- package/dist/tables/public/AdminAccountsTable.d.ts +0 -15
- package/dist/tables/public/AdminAccountsTable.js +0 -64
- package/dist/types/rows/AdminRow.d.ts +0 -9
- package/dist/types/rows/AdminRow.js +0 -1
|
@@ -19,12 +19,10 @@ import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTa
|
|
|
19
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/public/AdminAccountsTable';
|
|
23
22
|
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
24
23
|
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
25
24
|
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
26
25
|
export default class TableConnection extends Connection {
|
|
27
|
-
private _AdminAccountsTable;
|
|
28
26
|
private _StatusTypesTable;
|
|
29
27
|
private _FilesTable;
|
|
30
28
|
private _OrdersTable;
|
|
@@ -48,7 +46,6 @@ export default class TableConnection extends Connection {
|
|
|
48
46
|
private _CompanyDataTable;
|
|
49
47
|
private _FileConnectionsTable;
|
|
50
48
|
constructor(pgClient: Client);
|
|
51
|
-
get adminAccounts(): AdminAccountsTable;
|
|
52
49
|
get statusTypes(): StatusTypesTable;
|
|
53
50
|
get files(): FilesTable;
|
|
54
51
|
get orders(): OrdersTable;
|
package/dist/TableConnection.js
CHANGED
|
@@ -18,12 +18,10 @@ import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTa
|
|
|
18
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/public/AdminAccountsTable';
|
|
22
21
|
import StatusTypesTable from './tables/orders/StatusTypesTable';
|
|
23
22
|
import CompanyDataTable from './tables/settings/CompanyDataTable';
|
|
24
23
|
import FileConnectionsTable from './tables/files/FileConnectionsTable';
|
|
25
24
|
export default class TableConnection extends Connection {
|
|
26
|
-
_AdminAccountsTable;
|
|
27
25
|
_StatusTypesTable;
|
|
28
26
|
_FilesTable;
|
|
29
27
|
_OrdersTable;
|
|
@@ -48,7 +46,6 @@ export default class TableConnection extends Connection {
|
|
|
48
46
|
_FileConnectionsTable;
|
|
49
47
|
constructor(pgClient) {
|
|
50
48
|
super(pgClient);
|
|
51
|
-
this._AdminAccountsTable = new AdminAccountsTable(this);
|
|
52
49
|
this._StatusTypesTable = new StatusTypesTable(this);
|
|
53
50
|
this._FilesTable = new FilesTable(this);
|
|
54
51
|
this._OrdersTable = new OrdersTable(this);
|
|
@@ -72,9 +69,6 @@ export default class TableConnection extends Connection {
|
|
|
72
69
|
this._CompanyDataTable = new CompanyDataTable(this);
|
|
73
70
|
this._FileConnectionsTable = new FileConnectionsTable(this);
|
|
74
71
|
}
|
|
75
|
-
get adminAccounts() {
|
|
76
|
-
return this._AdminAccountsTable;
|
|
77
|
-
}
|
|
78
72
|
get statusTypes() {
|
|
79
73
|
return this._StatusTypesTable;
|
|
80
74
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,6 @@ import QueryOptions from './query/QueryOptions';
|
|
|
16
16
|
import Client from "./stockObjects/Client";
|
|
17
17
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
18
18
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
19
|
-
import Admin from "./stockObjects/Admin";
|
|
20
|
-
import AdminRepo from './repo/AdminRepo';
|
|
21
19
|
import Address from "./stockObjects/Address";
|
|
22
20
|
import AddressI from "./types/AddressI";
|
|
23
21
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
@@ -88,4 +86,4 @@ import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
|
88
86
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
89
87
|
import CompanyDataI from "./types/CompanyDataI";
|
|
90
88
|
import StatusTypesReader from './reader/StatusTypesReader';
|
|
91
|
-
export { DatabaseConnection, StockObject, StockObjectMapper, Table, Query, TableConnection, ParameterType, ParameterFilter, ConnectorE, ParameterI, QueryOptionsI, ResultLimitationI, Parameters, OrderByI, QueryOptions, Client, ClientAccountRepo, ClientAccountReader,
|
|
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, };
|
package/dist/index.js
CHANGED
|
@@ -10,8 +10,6 @@ import QueryOptions from './query/QueryOptions';
|
|
|
10
10
|
import Client from "./stockObjects/Client";
|
|
11
11
|
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
12
12
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
13
|
-
import Admin from "./stockObjects/Admin";
|
|
14
|
-
import AdminRepo from './repo/AdminRepo';
|
|
15
13
|
import Address from "./stockObjects/Address";
|
|
16
14
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
17
15
|
import AddressesReader from "./reader/AddressesReader";
|
|
@@ -68,4 +66,4 @@ import CompanyData from "./stockObjects/CompanyData";
|
|
|
68
66
|
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
69
67
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
70
68
|
import StatusTypesReader from './reader/StatusTypesReader';
|
|
71
|
-
export { DatabaseConnection, StockObject, Table, Query, TableConnection, ParameterType, ConnectorE, Parameters, QueryOptions, Client, ClientAccountRepo, ClientAccountReader,
|
|
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, };
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/repo/AdminRepo.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Admin from "../stockObjects/Admin";
|
|
2
|
-
import QueryOptionsI from "../types/QueryOptionsI";
|
|
3
|
-
export default class AdminRepo {
|
|
4
|
-
static get(accountId: number): Promise<Admin>;
|
|
5
|
-
static getIdForEmail(email: string): Promise<number>;
|
|
6
|
-
static getAll(queryOptions: QueryOptionsI): Promise<{
|
|
7
|
-
adminAccounts: Admin[];
|
|
8
|
-
quantity: number;
|
|
9
|
-
}>;
|
|
10
|
-
private static createAdminsFromRows;
|
|
11
|
-
private static createAdminFromRow;
|
|
12
|
-
}
|
package/dist/repo/AdminRepo.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import Admin from "../stockObjects/Admin";
|
|
3
|
-
export default class AdminRepo {
|
|
4
|
-
static async get(accountId) {
|
|
5
|
-
const connection = DatabaseConnection.get();
|
|
6
|
-
const account = await connection.adminAccounts.select(accountId);
|
|
7
|
-
return this.createAdminFromRow(account);
|
|
8
|
-
}
|
|
9
|
-
static async getIdForEmail(email) {
|
|
10
|
-
const connection = DatabaseConnection.get();
|
|
11
|
-
return await connection.adminAccounts.selectForEmail(email);
|
|
12
|
-
}
|
|
13
|
-
static async getAll(queryOptions) {
|
|
14
|
-
const connection = DatabaseConnection.get();
|
|
15
|
-
const adminAccounts = await connection.adminAccounts.selectAll(queryOptions);
|
|
16
|
-
const quantity = await connection.adminAccounts.count(queryOptions);
|
|
17
|
-
return { adminAccounts: this.createAdminsFromRows(adminAccounts), quantity };
|
|
18
|
-
}
|
|
19
|
-
static createAdminsFromRows(dataRows) {
|
|
20
|
-
const admins = [];
|
|
21
|
-
for (const dataRow of dataRows) {
|
|
22
|
-
const admin = this.createAdminFromRow(dataRow);
|
|
23
|
-
admins.push(admin);
|
|
24
|
-
}
|
|
25
|
-
return admins;
|
|
26
|
-
}
|
|
27
|
-
static createAdminFromRow(dataRow) {
|
|
28
|
-
const admin = new Admin(dataRow.email, dataRow.first_name, dataRow.last_name, dataRow.activated, dataRow.deleted, dataRow.created_at);
|
|
29
|
-
admin.setId(dataRow.id);
|
|
30
|
-
return admin;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import ClaimI from "../types/ClaimI";
|
|
2
|
-
import StockObject from "../types/StockObject";
|
|
3
|
-
import StockObjectMapper from "../types/StockObjectMapper";
|
|
4
|
-
export default class Admin extends StockObject {
|
|
5
|
-
private email;
|
|
6
|
-
private activated;
|
|
7
|
-
private deleted;
|
|
8
|
-
private firstName;
|
|
9
|
-
private lastName;
|
|
10
|
-
private createdAt;
|
|
11
|
-
private claims;
|
|
12
|
-
constructor(email: string, firstName: string, lastName: string, activated: boolean, deleted?: boolean, createdAt?: string | null);
|
|
13
|
-
getEmail(): string;
|
|
14
|
-
getActivated(): boolean;
|
|
15
|
-
getDeleted(): boolean;
|
|
16
|
-
getCreatedAt(): string | null;
|
|
17
|
-
getFirstName(): string;
|
|
18
|
-
getLastName(): string;
|
|
19
|
-
setActivated(activated: boolean): void;
|
|
20
|
-
setDeleted(deleted: boolean): void;
|
|
21
|
-
setFirstName(firstName: string): void;
|
|
22
|
-
setLastName(lastName: string): void;
|
|
23
|
-
setClaims(claims: ClaimI[]): void;
|
|
24
|
-
protected getMapper(): StockObjectMapper;
|
|
25
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import AdminMapper from "../mappers/AdminMapper";
|
|
2
|
-
import StockObject from "../types/StockObject";
|
|
3
|
-
export default class Admin extends StockObject {
|
|
4
|
-
email;
|
|
5
|
-
activated;
|
|
6
|
-
deleted;
|
|
7
|
-
firstName;
|
|
8
|
-
lastName;
|
|
9
|
-
createdAt;
|
|
10
|
-
claims;
|
|
11
|
-
constructor(email, firstName, lastName, activated, deleted = false, createdAt = null) {
|
|
12
|
-
super();
|
|
13
|
-
this.email = email;
|
|
14
|
-
this.activated = activated;
|
|
15
|
-
this.deleted = deleted;
|
|
16
|
-
this.firstName = firstName;
|
|
17
|
-
this.lastName = lastName;
|
|
18
|
-
this.createdAt = createdAt;
|
|
19
|
-
this.claims = null;
|
|
20
|
-
}
|
|
21
|
-
getEmail() {
|
|
22
|
-
return this.email;
|
|
23
|
-
}
|
|
24
|
-
getActivated() {
|
|
25
|
-
return this.activated;
|
|
26
|
-
}
|
|
27
|
-
getDeleted() {
|
|
28
|
-
return this.deleted;
|
|
29
|
-
}
|
|
30
|
-
getCreatedAt() {
|
|
31
|
-
return this.createdAt;
|
|
32
|
-
}
|
|
33
|
-
getFirstName() {
|
|
34
|
-
return this.firstName;
|
|
35
|
-
}
|
|
36
|
-
getLastName() {
|
|
37
|
-
return this.lastName;
|
|
38
|
-
}
|
|
39
|
-
setActivated(activated) {
|
|
40
|
-
this.activated = activated;
|
|
41
|
-
}
|
|
42
|
-
setDeleted(deleted) {
|
|
43
|
-
this.deleted = deleted;
|
|
44
|
-
}
|
|
45
|
-
setFirstName(firstName) {
|
|
46
|
-
this.firstName = firstName;
|
|
47
|
-
}
|
|
48
|
-
setLastName(lastName) {
|
|
49
|
-
this.lastName = lastName;
|
|
50
|
-
}
|
|
51
|
-
setClaims(claims) {
|
|
52
|
-
this.claims = claims;
|
|
53
|
-
}
|
|
54
|
-
getMapper() {
|
|
55
|
-
return new AdminMapper(this);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import QueryOptionsI from "../../types/QueryOptionsI";
|
|
2
|
-
import Table from "../../Table";
|
|
3
|
-
import AdminRow from "../../types/rows/AdminRow";
|
|
4
|
-
import Admin from "../../stockObjects/Admin";
|
|
5
|
-
export default class AdminAccountsTable extends Table {
|
|
6
|
-
select(accountId: number): Promise<AdminRow>;
|
|
7
|
-
selectAll(queryOptions: QueryOptionsI): Promise<AdminRow[]>;
|
|
8
|
-
selectForEmail(email: string): Promise<number>;
|
|
9
|
-
count(queryOptions: QueryOptionsI): Promise<number>;
|
|
10
|
-
insert(admin: Admin): Promise<number>;
|
|
11
|
-
update(admin: Admin): Promise<boolean>;
|
|
12
|
-
delete(accountId: number): Promise<number>;
|
|
13
|
-
private bindParameters;
|
|
14
|
-
private selectNextId;
|
|
15
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|