@dascompany/product 4.2.3 → 4.2.4

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,6 +22,7 @@ import AdminAccountsTable from './tables/public/AdminAccountsTable';
22
22
  import AccountCompanyDetailsTable from './tables/clients/AccountCompanyDetailsTable';
23
23
  import AccountDeliveryDetailsTable from './tables/clients/AccountDeliveryDetailsTable';
24
24
  import AccountCartTable from './tables/clients/AccountCartTable';
25
+ import MarketPlacesTable from './tables/settings/MarketPlacesTable';
25
26
  export default class DatabaseConnection {
26
27
  static instance: DatabaseConnection;
27
28
  private tables;
@@ -51,5 +52,6 @@ export default class DatabaseConnection {
51
52
  get paymentDetails(): PaymentDetailsTable;
52
53
  get paymentStatuses(): PaymentStatusesTable;
53
54
  get companyData(): CompanyDataTable;
55
+ get marketPlaces(): MarketPlacesTable;
54
56
  get fileConnections(): FileConnectionsTable;
55
57
  }
@@ -24,6 +24,7 @@ import AdminAccountsTable from './tables/public/AdminAccountsTable';
24
24
  import AccountCompanyDetailsTable from './tables/clients/AccountCompanyDetailsTable';
25
25
  import AccountDeliveryDetailsTable from './tables/clients/AccountDeliveryDetailsTable';
26
26
  import AccountCartTable from './tables/clients/AccountCartTable';
27
+ import MarketPlacesTable from './tables/settings/MarketPlacesTable';
27
28
  export default class DatabaseConnection {
28
29
  static instance;
29
30
  tables = new Map();
@@ -151,6 +152,11 @@ export default class DatabaseConnection {
151
152
  this.tables.set(TableNames.companyData, new CompanyDataTable(this.connection));
152
153
  return this.tables.get(TableNames.companyData);
153
154
  }
155
+ get marketPlaces() {
156
+ if (!this.tables.get(TableNames.marketPlaces))
157
+ this.tables.set(TableNames.marketPlaces, new MarketPlacesTable(this.connection));
158
+ return this.tables.get(TableNames.marketPlaces);
159
+ }
154
160
  get fileConnections() {
155
161
  if (!this.tables.get(TableNames.fileConnections))
156
162
  this.tables.set(TableNames.fileConnections, new FileConnectionsTable(this.connection));
package/dist/SQL.json CHANGED
@@ -146,5 +146,8 @@
146
146
  "insert": "INSERT INTO settings.company_data(id, name, email, phone_number, registration_number, tax_number, swift_number, regon_number, bank_account_number, bank_name, address_id) VALUES ( $id::BIGINT, $name::TEXT, $email::TEXT, $phone_number::TEXT, $registartion_number::TEXT, $tax_number::TEXT, $swift_number::TEXT, $regon_number::TEXT, $bank_account_number::TEXT, $bank_name::TEXT, $address_id::BIGINT )",
147
147
  "update": "UPDATE settings.company_data SET id = $id::BIGINT, name = $name::TEXT , email = LOWER($email::TEXT), phone_number = $phone_number::TEXT, registration_number = $registration_number::TEXT,tax_number = $tax_number::TEXT, regon_number = $regon_number::TEXT, bank_account_number = $bank_account_number::TEXT, bank_name = $bank_name::TEXT WHERE id = $id::BIGINT",
148
148
  "selectNextId": "SELECT nextval('settings.company_data_id'::regclass)"
149
+ },
150
+ "marketPlaces": {
151
+ "select": "SELECT * FROM settings.market_places"
149
152
  }
150
153
  }
@@ -0,0 +1,14 @@
1
+ import { QueryOptions } from "@dascompany/database";
2
+ type MarketData = {
3
+ id: string;
4
+ country: string;
5
+ language: string;
6
+ vatRate: string;
7
+ };
8
+ export default class MarketPlacesReader {
9
+ static get(queryOptions: QueryOptions): Promise<MarketData>;
10
+ static getAll(queryOptions: QueryOptions): Promise<MarketData[]>;
11
+ private static correctMarkets;
12
+ private static correctMarket;
13
+ }
14
+ export {};
@@ -0,0 +1,29 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ export default class MarketPlacesReader {
3
+ static async get(queryOptions) {
4
+ if (!queryOptions.getLimit())
5
+ queryOptions.setLimit(1, 0);
6
+ const marketPlace = await DatabaseConnection.getInstance().marketPlaces.select(queryOptions);
7
+ return this.correctMarket(marketPlace[0]);
8
+ }
9
+ static async getAll(queryOptions) {
10
+ const marketPlace = await DatabaseConnection.getInstance().marketPlaces.select(queryOptions);
11
+ return this.correctMarkets(marketPlace);
12
+ }
13
+ static correctMarkets(marketRows) {
14
+ const markets = [];
15
+ marketRows.forEach((market) => {
16
+ markets.push(this.correctMarket(market));
17
+ });
18
+ return markets;
19
+ }
20
+ static correctMarket(marketRow) {
21
+ const correctMarket = {
22
+ id: marketRow.id,
23
+ country: marketRow.country,
24
+ language: marketRow.language,
25
+ vatRate: marketRow.vat_rate,
26
+ };
27
+ return correctMarket;
28
+ }
29
+ }
@@ -22,6 +22,7 @@ declare enum TableNames {
22
22
  products = "productsTable",
23
23
  companyData = "companyDataTable",
24
24
  deliveryMethods = "deliveryMethodsTable",
25
- paymentMethods = "paymentMethodsTable"
25
+ paymentMethods = "paymentMethodsTable",
26
+ marketPlaces = "marketPlacesTable"
26
27
  }
27
28
  export default TableNames;
@@ -24,5 +24,6 @@ var TableNames;
24
24
  TableNames["companyData"] = "companyDataTable";
25
25
  TableNames["deliveryMethods"] = "deliveryMethodsTable";
26
26
  TableNames["paymentMethods"] = "paymentMethodsTable";
27
+ TableNames["marketPlaces"] = "marketPlacesTable";
27
28
  })(TableNames || (TableNames = {}));
28
29
  export default TableNames;
@@ -0,0 +1,5 @@
1
+ import { QueryOptions, Table } from '@dascompany/database';
2
+ import MarketPlaceRow from '../../types/rows/MarketPlaceRow';
3
+ export default class MarketPlacesTable extends Table {
4
+ select(queryOptions: QueryOptions): Promise<MarketPlaceRow[]>;
5
+ }
@@ -0,0 +1,9 @@
1
+ import { Table } from '@dascompany/database';
2
+ import * as SQL from '../../SQL.json';
3
+ export default class MarketPlacesTable extends Table {
4
+ async select(queryOptions) {
5
+ const query = this.createQuery(SQL.marketPlaces.select, queryOptions);
6
+ const result = await query.execute();
7
+ return result.getRows();
8
+ }
9
+ }
@@ -0,0 +1,6 @@
1
+ export default interface MarketPlaceRow {
2
+ id: string;
3
+ country: string;
4
+ language: string;
5
+ vat_rate: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "4.2.3",
3
+ "version": "4.2.4",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",