@dascompany/product 4.2.0 → 4.2.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.
package/dist/SQL.json CHANGED
@@ -18,10 +18,11 @@
18
18
  "selectNextId": "SELECT nextval('clients.accounts_id'::regclass)"
19
19
  },
20
20
  "accountCart": {
21
- "select": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT",
22
- "insert": "INSERT INTO clients.account_cart(account_id, product_id, installation) VALUES ($account_id::BIGINT, $product_id::BIGINT, $installation::BOOL)",
23
- "update": "UPDATE clients.account_cart SET installation = $installation WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT AND installation = $installation::Bool",
24
- "delete": "DELETE FROM clients.account_cart WHERE product_id = $product_id::BIGINT AND account_id = $account_id::BIGINT AND installation = $installation::BOOL"
21
+ "selectAll": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT",
22
+ "select": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT",
23
+ "insert": "INSERT INTO clients.account_cart(account_id, product_id, installation, quantity) VALUES ($account_id::BIGINT, $product_id::BIGINT, $installation::BOOL, $quantity::INT)",
24
+ "update": "UPDATE clients.account_cart SET installation = $installation::BOOL, quantity = $quantity::INT WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT AND (installation != $installation::BOOL OR quantity != $quantity::INT)",
25
+ "delete": "DELETE FROM clients.account_cart WHERE product_id = $product_id::BIGINT AND account_id = $account_id::BIGINT"
25
26
  },
26
27
  "accountDeliveryDetails": {
27
28
  "select": "SELECT * FROM clients.account_delivery_details WHERE account_id = $account_id::BIGINT",
@@ -98,7 +99,7 @@
98
99
  "files": {
99
100
  "select": "SELECT * FROM files.files",
100
101
  "selectId": "SELECT id FROM files.files ",
101
- "selectForConnection": "SELECT id, name, catalog, type, sequence FROM files.files JOIN files.file_connections ON file_id = id",
102
+ "selectForConnection": "SELECT id, name, catalog, type, sequence, alt, title FROM files.files JOIN files.file_connections ON file_id = id",
102
103
  "insert": "INSERT INTO files.files( id, name, orginal_name, catalog, size_kb, type, alt, title, created_at ) VALUES ( $id::BIGINT, $name::TEXT, $orginal_name::TEXT, $catalog::TEXT, $size_kb::BIGINT, $type::TEXT, $alt::TEXT, $title::TEXT, now() )",
103
104
  "update": "UPDATE files.files SET name = $name::TEXT, orginal_name = $orginal_name::TEXT, catalog = $catalog::TEXT, size_kb = $size_kb::BIGINT, type = $type::TEXT, alt = $alt::TEXT, title = $title::TEXT WHERE id = $id::BIGINT ",
104
105
  "count": "SELECT COUNT(*) AS total_rows FROM files.files",
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import Client from "./stockObjects/Client";
2
2
  import ClientAccountRepo from "./repo/ClientAccountRepo";
3
3
  import ClientAccountReader from "./reader/ClientAccountReader";
4
- import AccountCartReader from "./reader/AccountCartReader";
5
4
  import AccountDeliveryDetailsReader from "./reader/AccountDeliveryDetailsReader";
6
5
  import AccountCompanyDetailsReader from "./reader/AccountCompanyDetailsReader";
6
+ import AccountCart from "./utils/AccountCart";
7
+ import AccountCartReader from "./reader/AccountCartReader";
7
8
  import Admin from "./stockObjects/Admin";
8
9
  import AdminRepo from "./repo/AdminRepo";
9
10
  import AdminReader from "./reader/AdminReader";
@@ -73,4 +74,4 @@ import CompanyDataReader from "./reader/CompanyDataReader";
73
74
  import CompanyDataI from "./types/CompanyDataI";
74
75
  import PriceConverter from "./utils/PriceConverter";
75
76
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
76
- export { Client, ClientAccountRepo, ClientAccountReader, AccountCartReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusReader, StatusI, OrderStatusTypeE, StatusTypesReader, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, PriceConverter, createQueryOptionsForId };
77
+ export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, AccountCart, AccountCartReader, Admin, AdminRepo, AdminReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusReader, StatusI, OrderStatusTypeE, StatusTypesReader, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, PriceConverter, createQueryOptionsForId };
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import Client from "./stockObjects/Client";
2
2
  import ClientAccountRepo from "./repo/ClientAccountRepo";
3
3
  import ClientAccountReader from "./reader/ClientAccountReader";
4
- import AccountCartReader from "./reader/AccountCartReader";
5
4
  import AccountDeliveryDetailsReader from "./reader/AccountDeliveryDetailsReader";
6
5
  import AccountCompanyDetailsReader from "./reader/AccountCompanyDetailsReader";
6
+ import AccountCart from "./utils/AccountCart";
7
+ import AccountCartReader from "./reader/AccountCartReader";
7
8
  import Admin from "./stockObjects/Admin";
8
9
  import AdminRepo from "./repo/AdminRepo";
9
10
  import AdminReader from "./reader/AdminReader";
@@ -61,4 +62,4 @@ import CompanyDataRepo from "./repo/CompanyDataRepo";
61
62
  import CompanyDataReader from "./reader/CompanyDataReader";
62
63
  import PriceConverter from "./utils/PriceConverter";
63
64
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
64
- export { Client, ClientAccountRepo, ClientAccountReader, AccountCartReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusReader, OrderStatusTypeE, StatusTypesReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, PriceConverter, createQueryOptionsForId };
65
+ export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, AccountCart, AccountCartReader, Admin, AdminRepo, AdminReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusReader, OrderStatusTypeE, StatusTypesReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, PriceConverter, createQueryOptionsForId };
@@ -1,5 +1,4 @@
1
- import ProductI from "../types/ProductI";
2
1
  export default class AccountCartReader {
3
- static getAll(accountId: string): Promise<ProductI[]>;
2
+ static getAll(accountId: string): Promise<any[]>;
4
3
  private static correctAccountCart;
5
4
  }
@@ -1,6 +1,4 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
- import createQueryOptionsForId from "../utils/createQueryOptionsForId";
3
- import ProductReader from "./ProductReader";
4
2
  export default class AccountCartReader {
5
3
  static async getAll(accountId) {
6
4
  const accountCart = await DatabaseConnection.getInstance().accountCart.selectAll(accountId);
@@ -9,8 +7,11 @@ export default class AccountCartReader {
9
7
  static async correctAccountCart(accountCart) {
10
8
  const correctAccountCart = [];
11
9
  for (let i = 0; i < accountCart.length; i++) {
12
- const product = await ProductReader.get(createQueryOptionsForId(accountCart[i].product_id));
13
- correctAccountCart.push(product);
10
+ correctAccountCart.push({
11
+ id: accountCart[i].product_id,
12
+ installation: accountCart[i].installation,
13
+ quantity: accountCart[i].quantity
14
+ });
14
15
  }
15
16
  return correctAccountCart;
16
17
  }
@@ -0,0 +1,21 @@
1
+ export default class AccountCartItem {
2
+ private accountId;
3
+ private productId;
4
+ private installation;
5
+ private quantity;
6
+ constructor(accountId: string, productId: string, installation: boolean, quantity: number);
7
+ getData(): {
8
+ accountId: string;
9
+ productId: string;
10
+ installation: boolean;
11
+ quantity: number;
12
+ };
13
+ getAccountId(): string;
14
+ getProductId(): string;
15
+ getInstallation(): boolean;
16
+ getQuantity(): number;
17
+ setAccountId(accountId: string): void;
18
+ setProductId(productId: string): void;
19
+ setInstallation(installation: boolean): void;
20
+ setQuantity(quantity: number): void;
21
+ }
@@ -0,0 +1,44 @@
1
+ export default class AccountCartItem {
2
+ accountId;
3
+ productId;
4
+ installation;
5
+ quantity;
6
+ constructor(accountId, productId, installation, quantity) {
7
+ this.accountId = accountId;
8
+ this.productId = productId;
9
+ this.installation = installation;
10
+ this.quantity = quantity;
11
+ }
12
+ getData() {
13
+ return {
14
+ accountId: this.accountId,
15
+ productId: this.productId,
16
+ installation: this.installation,
17
+ quantity: this.quantity,
18
+ };
19
+ }
20
+ getAccountId() {
21
+ return this.accountId;
22
+ }
23
+ getProductId() {
24
+ return this.productId;
25
+ }
26
+ getInstallation() {
27
+ return this.installation;
28
+ }
29
+ getQuantity() {
30
+ return this.quantity;
31
+ }
32
+ setAccountId(accountId) {
33
+ this.accountId = accountId;
34
+ }
35
+ setProductId(productId) {
36
+ this.productId = productId;
37
+ }
38
+ setInstallation(installation) {
39
+ this.installation = installation;
40
+ }
41
+ setQuantity(quantity) {
42
+ this.quantity = quantity;
43
+ }
44
+ }
@@ -54,7 +54,7 @@ export default class Product extends StockObject {
54
54
  return this.url;
55
55
  }
56
56
  getArticleNumber() {
57
- return this.url;
57
+ return this.articleNumber;
58
58
  }
59
59
  getTitle() {
60
60
  return this.title;
@@ -1,9 +1,12 @@
1
1
  import { Table } from '@dascompany/database';
2
2
  import AccountCartRow from '../../types/rows/AccountCartRow';
3
+ import AccountCartItem from '../../stockObjects/AccountCartItem.ts';
3
4
  export default class AccountCartTable extends Table {
4
5
  selectAll(accountId: string): Promise<AccountCartRow[]>;
5
- delete(accountId: string, productId: string, installation: boolean): Promise<void>;
6
- insert(accountId: string, productId: string, installation: boolean): Promise<void>;
7
- update(accountId: string, productId: string, oldInstallation: boolean, newInstallation: boolean): Promise<void>;
6
+ select(accountId: string, productId: string): Promise<AccountCartRow[]>;
7
+ delete(accountId: string, productId: string): Promise<void>;
8
+ insert(accountCartItem: AccountCartItem): Promise<void>;
9
+ update(accountCartItem: AccountCartItem): Promise<void>;
8
10
  private bindParams;
11
+ private bindSideParams;
9
12
  }
@@ -2,29 +2,43 @@ import { Table } from '@dascompany/database';
2
2
  import * as SQL from '../../SQL.json';
3
3
  export default class AccountCartTable extends Table {
4
4
  async selectAll(accountId) {
5
- const query = this.createQuery(SQL.accountCart.select);
5
+ const query = this.createQuery(SQL.accountCart.selectAll);
6
6
  query.bindParameter('account_id', accountId);
7
7
  const result = await query.execute();
8
8
  return result.getRows();
9
9
  }
10
- async delete(accountId, productId, installation) {
10
+ async select(accountId, productId) {
11
+ const query = this.createQuery(SQL.accountCart.select);
12
+ query.bindParameter('account_id', accountId);
13
+ query.bindParameter('product_id', productId);
14
+ const result = await query.execute();
15
+ return result.getRow();
16
+ }
17
+ async delete(accountId, productId) {
11
18
  const query = this.createQuery(SQL.accountCart.delete);
12
- this.bindParams(query, accountId, productId, installation);
19
+ this.bindParams(query, accountId, productId);
13
20
  await query.execute();
14
21
  }
15
- async insert(accountId, productId, installation) {
22
+ async insert(accountCartItem) {
16
23
  const query = this.createQuery(SQL.accountCart.insert);
17
- this.bindParams(query, accountId, productId, installation);
24
+ this.bindParams(query, accountCartItem.getAccountId(), accountCartItem.getProductId());
25
+ this.bindSideParams(query, accountCartItem);
18
26
  await query.execute();
19
27
  }
20
- async update(accountId, productId, oldInstallation, newInstallation) {
28
+ async update(accountCartItem) {
21
29
  const query = this.createQuery(SQL.accountCart.update);
22
- this.bindParams(query, accountId, productId, newInstallation);
30
+ query.bindParameter('account_id', accountCartItem.getAccountId());
31
+ query.bindParameter('product_id', accountCartItem.getProductId());
32
+ query.bindParameter('installation', accountCartItem.getInstallation());
33
+ query.bindParameter('quantity', accountCartItem.getQuantity());
23
34
  await query.execute();
24
35
  }
25
- bindParams(query, accountId, productId, installation) {
36
+ bindParams(query, accountId, productId) {
26
37
  query.bindParameter('account_id', accountId);
27
38
  query.bindParameter('product_id', productId);
28
- query.bindParameter('installation', installation);
39
+ }
40
+ bindSideParams(query, accountCartItem) {
41
+ query.bindParameter('installation', accountCartItem.getInstallation());
42
+ query.bindParameter('quantity', accountCartItem.getQuantity());
29
43
  }
30
44
  }
@@ -1,4 +1,6 @@
1
1
  export default interface AccountCartRow {
2
2
  account_id: string;
3
3
  product_id: string;
4
+ installation: boolean;
5
+ quantity: boolean;
4
6
  }
@@ -1,5 +1,5 @@
1
1
  export default class AccountCart {
2
- static delete(accountId: string, productId: string, installation: boolean): Promise<boolean>;
3
- static insert(accountId: string, productId: string, installation: boolean): Promise<boolean>;
4
- static update(accountId: string, productId: string, oldInstallation: boolean, installation: boolean): Promise<boolean>;
2
+ static delete(accountId: string, productId: string): Promise<boolean>;
3
+ static insert(accountId: string, productId: string, installation: boolean, quantity: number): Promise<boolean>;
4
+ static update(accountId: string, productId: string, installation: boolean, quantity: number): Promise<boolean>;
5
5
  }
@@ -1,15 +1,18 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
+ import AccountCartItem from "../stockObjects/AccountCartItem.ts";
2
3
  export default class AccountCart {
3
- static async delete(accountId, productId, installation) {
4
- await DatabaseConnection.getInstance().accountCart.delete(accountId, productId, installation);
4
+ static async delete(accountId, productId) {
5
+ await DatabaseConnection.getInstance().accountCart.delete(accountId, productId);
5
6
  return true;
6
7
  }
7
- static async insert(accountId, productId, installation) {
8
- await DatabaseConnection.getInstance().accountCart.insert(accountId, productId, installation);
8
+ static async insert(accountId, productId, installation, quantity) {
9
+ const item = new AccountCartItem(accountId, productId, installation, quantity);
10
+ await DatabaseConnection.getInstance().accountCart.insert(item);
9
11
  return true;
10
12
  }
11
- static async update(accountId, productId, oldInstallation, installation) {
12
- await DatabaseConnection.getInstance().accountCart.update(accountId, productId, oldInstallation, installation);
13
+ static async update(accountId, productId, installation, quantity) {
14
+ const item = new AccountCartItem(accountId, productId, installation, quantity);
15
+ await DatabaseConnection.getInstance().accountCart.update(item);
13
16
  return true;
14
17
  }
15
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",