@dascompany/product 2.0.0 → 2.1.0

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.
@@ -3,10 +3,8 @@ import AdminI from "../types/AdminI";
3
3
  export default class AdminReader {
4
4
  static get(queryOptions: QueryOptions): Promise<AdminI>;
5
5
  static getId(queryOptions: QueryOptions): Promise<number>;
6
- static getAll(queryOptions: QueryOptions): Promise<{
7
- adminAccounts: AdminI[];
8
- quantity: number;
9
- }>;
6
+ static getAll(queryOptions: QueryOptions): Promise<AdminI[]>;
7
+ static getQuantity(queryOptions: QueryOptions): Promise<number>;
10
8
  private static correctAdmins;
11
9
  private static correctAdmin;
12
10
  }
@@ -9,11 +9,11 @@ export default class AdminReader {
9
9
  }
10
10
  static async getAll(queryOptions) {
11
11
  const adminAccounts = await DatabaseConnection.getInstance().adminAccounts.selectAll(queryOptions);
12
+ return this.correctAdmins(adminAccounts);
13
+ }
14
+ static async getQuantity(queryOptions) {
12
15
  const quantity = await DatabaseConnection.getInstance().adminAccounts.count(queryOptions);
13
- return {
14
- adminAccounts: this.correctAdmins(adminAccounts),
15
- quantity
16
- };
16
+ return quantity;
17
17
  }
18
18
  static correctAdmins(admins) {
19
19
  const correctAdmins = [];
@@ -2,10 +2,8 @@ import { QueryOptions } from "@dascompany/database";
2
2
  import ClientAccountI from "../types/ClientAccountI";
3
3
  export default class ClientAccountReader {
4
4
  static get(queryOptions: QueryOptions): Promise<ClientAccountI>;
5
- static getAll(queryOptions: QueryOptions): Promise<{
6
- clientAccounts: ClientAccountI[];
7
- quantity: number;
8
- }>;
5
+ static getAll(queryOptions: QueryOptions): Promise<ClientAccountI[]>;
6
+ static getQuantity(queryOptions: QueryOptions): Promise<number>;
9
7
  static getId(queryOptions: QueryOptions): Promise<number | null>;
10
8
  private static correctClientsFromRows;
11
9
  private static correctData;
@@ -6,11 +6,11 @@ export default class ClientAccountReader {
6
6
  }
7
7
  static async getAll(queryOptions) {
8
8
  const clientAccounts = await DatabaseConnection.getInstance().clientAccounts.selectAll(queryOptions);
9
+ return this.correctClientsFromRows(clientAccounts);
10
+ }
11
+ static async getQuantity(queryOptions) {
9
12
  const quantity = await DatabaseConnection.getInstance().clientAccounts.count(queryOptions);
10
- return {
11
- clientAccounts: this.correctClientsFromRows(clientAccounts),
12
- quantity
13
- };
13
+ return quantity;
14
14
  }
15
15
  static async getId(queryOptions) {
16
16
  const accountId = await DatabaseConnection.getInstance().clientAccounts.selectId(queryOptions);
@@ -3,10 +3,8 @@ import OrderI from "../types/OrderI";
3
3
  export default class OrderReader {
4
4
  static get(queryOptions: QueryOptions): Promise<OrderI>;
5
5
  static getAll(queryOptions: QueryOptions): Promise<OrderI[]>;
6
- static getAllForClient(queryOptions: QueryOptions): Promise<{
7
- orders: OrderI[];
8
- quantity: number;
9
- }>;
6
+ static getAllForClient(queryOptions: QueryOptions): Promise<OrderI[]>;
7
+ static getQuantity(queryOptions: QueryOptions): Promise<number>;
10
8
  private static correctOrders;
11
9
  private static correctOrder;
12
10
  }
@@ -18,9 +18,12 @@ export default class OrderReader {
18
18
  }
19
19
  static async getAllForClient(queryOptions) {
20
20
  const orderRows = await DatabaseConnection.getInstance().orders.selectAll(queryOptions);
21
- const quantity = await DatabaseConnection.getInstance().orders.count(queryOptions);
22
21
  const orders = await this.correctOrders(orderRows);
23
- return { orders, quantity };
22
+ return orders;
23
+ }
24
+ static async getQuantity(queryOptions) {
25
+ const quantity = await DatabaseConnection.getInstance().orders.count(queryOptions);
26
+ return quantity;
24
27
  }
25
28
  static async correctOrders(orderRows) {
26
29
  const orders = [];
@@ -3,10 +3,8 @@ import Admin from "../stockObjects/Admin";
3
3
  export default class AdminRepo {
4
4
  static get(queryOptions: QueryOptions): Promise<Admin>;
5
5
  static getId(queryOptions: QueryOptions): Promise<number>;
6
- static getAll(queryOptions: QueryOptions): Promise<{
7
- adminAccounts: Admin[];
8
- quantity: number;
9
- }>;
6
+ static getAll(queryOptions: QueryOptions): Promise<Admin[]>;
7
+ static getQuantity(queryOptions: QueryOptions): Promise<number>;
10
8
  private static createAdminsFromRows;
11
9
  private static createAdminFromRow;
12
10
  }
@@ -10,8 +10,11 @@ export default class AdminRepo {
10
10
  }
11
11
  static async getAll(queryOptions) {
12
12
  const adminAccounts = await DatabaseConnection.getInstance().adminAccounts.selectAll(queryOptions);
13
+ return this.createAdminsFromRows(adminAccounts);
14
+ }
15
+ static async getQuantity(queryOptions) {
13
16
  const quantity = await DatabaseConnection.getInstance().adminAccounts.count(queryOptions);
14
- return { adminAccounts: this.createAdminsFromRows(adminAccounts), quantity };
17
+ return quantity;
15
18
  }
16
19
  static createAdminsFromRows(dataRows) {
17
20
  const admins = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",
@@ -20,7 +20,7 @@
20
20
  "vitest": "^3.0.6"
21
21
  },
22
22
  "peerDependencies": {
23
- "@dascompany/database": "^3.0.0",
23
+ "@dascompany/database": "^3.0.1",
24
24
  "@types/pg": "^8.11.11",
25
25
  "pg": "^8.13.3"
26
26
  }