@dascompany/product 1.1.7 → 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.
Files changed (120) hide show
  1. package/dist/SQL.json +39 -59
  2. package/dist/reader/AddressesReader.d.ts +2 -2
  3. package/dist/reader/AddressesReader.js +2 -6
  4. package/dist/reader/AdminReader.d.ts +5 -7
  5. package/dist/reader/AdminReader.js +8 -8
  6. package/dist/reader/ClientAccountReader.d.ts +4 -7
  7. package/dist/reader/ClientAccountReader.js +8 -12
  8. package/dist/reader/CompanyDataReader.js +4 -1
  9. package/dist/reader/CompanyDetailsReader.d.ts +2 -1
  10. package/dist/reader/CompanyDetailsReader.js +3 -3
  11. package/dist/reader/ContactDetailsReader.d.ts +2 -1
  12. package/dist/reader/ContactDetailsReader.js +9 -4
  13. package/dist/reader/DeliveryDetailsReader.d.ts +2 -1
  14. package/dist/reader/DeliveryDetailsReader.js +18 -8
  15. package/dist/reader/DeliveryMethodReader.d.ts +3 -3
  16. package/dist/reader/DeliveryMethodReader.js +4 -8
  17. package/dist/reader/DeliveryStatusReader.d.ts +3 -2
  18. package/dist/reader/DeliveryStatusReader.js +8 -5
  19. package/dist/reader/FileConnectionsReader.d.ts +2 -1
  20. package/dist/reader/FileConnectionsReader.js +2 -2
  21. package/dist/reader/FilesReader.d.ts +5 -6
  22. package/dist/reader/FilesReader.js +5 -5
  23. package/dist/reader/InvoiceDetailsReader.d.ts +2 -1
  24. package/dist/reader/InvoiceDetailsReader.js +21 -6
  25. package/dist/reader/OrderProductsReader.d.ts +2 -2
  26. package/dist/reader/OrderProductsReader.js +6 -17
  27. package/dist/reader/OrderReader.d.ts +5 -7
  28. package/dist/reader/OrderReader.js +18 -11
  29. package/dist/reader/OrderStatusReader.d.ts +3 -2
  30. package/dist/reader/OrderStatusReader.js +4 -4
  31. package/dist/reader/PersonalDataReader.d.ts +2 -1
  32. package/dist/reader/PersonalDataReader.js +10 -3
  33. package/dist/reader/ProductReader.d.ts +6 -7
  34. package/dist/reader/ProductReader.js +18 -18
  35. package/dist/reader/payment/PaymentDetailsReader.d.ts +2 -2
  36. package/dist/reader/payment/PaymentDetailsReader.js +17 -8
  37. package/dist/reader/payment/PaymentMethodReader.d.ts +3 -3
  38. package/dist/reader/payment/PaymentMethodReader.js +4 -8
  39. package/dist/reader/payment/PaymentStatusesReader.d.ts +3 -2
  40. package/dist/reader/payment/PaymentStatusesReader.js +8 -5
  41. package/dist/repo/AddressesRepo.d.ts +2 -1
  42. package/dist/repo/AddressesRepo.js +2 -2
  43. package/dist/repo/AdminRepo.d.ts +5 -7
  44. package/dist/repo/AdminRepo.js +8 -5
  45. package/dist/repo/ClientAccountRepo.d.ts +2 -3
  46. package/dist/repo/ClientAccountRepo.js +2 -10
  47. package/dist/repo/CompanyDetailsRepo.d.ts +2 -1
  48. package/dist/repo/CompanyDetailsRepo.js +2 -2
  49. package/dist/repo/ContactDetailsRepo.d.ts +2 -1
  50. package/dist/repo/ContactDetailsRepo.js +2 -2
  51. package/dist/repo/DeliveryDetailsRepo.d.ts +2 -1
  52. package/dist/repo/DeliveryDetailsRepo.js +2 -2
  53. package/dist/repo/DeliveryMethodRepo.d.ts +2 -1
  54. package/dist/repo/DeliveryMethodRepo.js +2 -2
  55. package/dist/repo/FileConnectionsRepo.d.ts +3 -2
  56. package/dist/repo/FileConnectionsRepo.js +4 -4
  57. package/dist/repo/FilesRepo.d.ts +3 -3
  58. package/dist/repo/FilesRepo.js +4 -4
  59. package/dist/repo/InvoiceDetailsRepo.d.ts +2 -1
  60. package/dist/repo/InvoiceDetailsRepo.js +2 -2
  61. package/dist/repo/OrderProductsRepo.d.ts +2 -2
  62. package/dist/repo/OrderProductsRepo.js +2 -15
  63. package/dist/repo/OrderRepo.d.ts +2 -1
  64. package/dist/repo/OrderRepo.js +2 -2
  65. package/dist/repo/OrderStatusRepo.d.ts +3 -2
  66. package/dist/repo/OrderStatusRepo.js +4 -4
  67. package/dist/repo/PaymentDetailsRepo.d.ts +2 -1
  68. package/dist/repo/PaymentDetailsRepo.js +2 -2
  69. package/dist/repo/PaymentMethodRepo.d.ts +2 -1
  70. package/dist/repo/PaymentMethodRepo.js +2 -2
  71. package/dist/repo/PersonalDataRepo.d.ts +2 -1
  72. package/dist/repo/PersonalDataRepo.js +2 -2
  73. package/dist/repo/ProductRepo.d.ts +2 -2
  74. package/dist/repo/ProductRepo.js +2 -6
  75. package/dist/stockObjects/Order.js +4 -2
  76. package/dist/stockObjects/PersonalData.js +6 -3
  77. package/dist/stockObjects/Product.js +9 -4
  78. package/dist/tables/clients/ClientAccountsTable.d.ts +5 -7
  79. package/dist/tables/clients/ClientAccountsTable.js +13 -23
  80. package/dist/tables/files/FileConnectionsTable.d.ts +3 -6
  81. package/dist/tables/files/FileConnectionsTable.js +4 -19
  82. package/dist/tables/files/FilesTable.d.ts +6 -7
  83. package/dist/tables/files/FilesTable.js +9 -12
  84. package/dist/tables/orders/OrdersProductsTable.d.ts +4 -5
  85. package/dist/tables/orders/OrdersProductsTable.js +14 -20
  86. package/dist/tables/orders/OrdersTable.d.ts +4 -5
  87. package/dist/tables/orders/OrdersTable.js +3 -10
  88. package/dist/tables/orders/PaymentDetailsTable.d.ts +2 -2
  89. package/dist/tables/orders/PaymentDetailsTable.js +2 -3
  90. package/dist/tables/orders/PaymentStatusTypesTable.d.ts +2 -2
  91. package/dist/tables/orders/PaymentStatusTypesTable.js +2 -3
  92. package/dist/tables/orders/PaymentStatusesTable.d.ts +3 -3
  93. package/dist/tables/orders/PaymentStatusesTable.js +4 -6
  94. package/dist/tables/orders/StatusesTable.d.ts +3 -3
  95. package/dist/tables/orders/StatusesTable.js +4 -6
  96. package/dist/tables/personalInformation/AddressesTable.d.ts +2 -2
  97. package/dist/tables/personalInformation/AddressesTable.js +2 -3
  98. package/dist/tables/personalInformation/CompanyDetailsTable.d.ts +2 -2
  99. package/dist/tables/personalInformation/CompanyDetailsTable.js +2 -3
  100. package/dist/tables/personalInformation/ContactDetailsTable.d.ts +2 -2
  101. package/dist/tables/personalInformation/ContactDetailsTable.js +2 -3
  102. package/dist/tables/personalInformation/DeliveryDetailsTable.d.ts +2 -2
  103. package/dist/tables/personalInformation/DeliveryDetailsTable.js +2 -3
  104. package/dist/tables/personalInformation/DeliveryStatusTypesTable.d.ts +2 -2
  105. package/dist/tables/personalInformation/DeliveryStatusTypesTable.js +2 -3
  106. package/dist/tables/personalInformation/DeliveryStatusesTable.d.ts +3 -3
  107. package/dist/tables/personalInformation/DeliveryStatusesTable.js +4 -6
  108. package/dist/tables/personalInformation/InvoiceDetailsTable.d.ts +2 -2
  109. package/dist/tables/personalInformation/InvoiceDetailsTable.js +2 -3
  110. package/dist/tables/personalInformation/PersonalDataTable.d.ts +2 -2
  111. package/dist/tables/personalInformation/PersonalDataTable.js +2 -3
  112. package/dist/tables/public/AdminAccountsTable.d.ts +5 -5
  113. package/dist/tables/public/AdminAccountsTable.js +11 -9
  114. package/dist/tables/public/ProductsTable.d.ts +7 -10
  115. package/dist/tables/public/ProductsTable.js +28 -43
  116. package/dist/tables/settings/DeliveryMethodsTable.d.ts +4 -5
  117. package/dist/tables/settings/DeliveryMethodsTable.js +10 -14
  118. package/dist/tables/settings/PaymentMethodsTable.d.ts +4 -5
  119. package/dist/tables/settings/PaymentMethodsTable.js +10 -14
  120. package/package.json +2 -2
@@ -1,7 +1,8 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import FileConnection from "../stockObjects/FileConnection";
2
3
  export default class FileConnectionsRepo {
3
- static getAllForFileId(fileId: number): Promise<FileConnection[]>;
4
- static deleteAllForConnection(connectionType: string, connectionId: number): Promise<boolean>;
4
+ static getAll(queryOptions: QueryOptions): Promise<FileConnection[]>;
5
+ static delete(id: number): Promise<boolean>;
5
6
  private static correctFileConnections;
6
7
  private static correctFileConnection;
7
8
  }
@@ -1,12 +1,12 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import FileConnection from "../stockObjects/FileConnection";
3
3
  export default class FileConnectionsRepo {
4
- static async getAllForFileId(fileId) {
5
- const fileConnections = await DatabaseConnection.getInstance().fileConnections.selectForFileId(fileId);
4
+ static async getAll(queryOptions) {
5
+ const fileConnections = await DatabaseConnection.getInstance().fileConnections.selectAll(queryOptions);
6
6
  return this.correctFileConnections(fileConnections);
7
7
  }
8
- static async deleteAllForConnection(connectionType, connectionId) {
9
- return await DatabaseConnection.getInstance().fileConnections.deleteForConnection(connectionType, connectionId);
8
+ static async delete(id) {
9
+ return await DatabaseConnection.getInstance().fileConnections.delete(id);
10
10
  }
11
11
  static correctFileConnections(dataRows) {
12
12
  const fileConnections = [];
@@ -1,7 +1,7 @@
1
- import FileConnectionTypeE from "../types/FileConnectionTypeE";
1
+ import { QueryOptions } from "@dascompany/database";
2
2
  export default class FilesRepo {
3
- static get(fileId: number): Promise<any>;
4
- static getAllForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<any>;
3
+ static get(queryOptions: QueryOptions): Promise<any>;
4
+ static getAll(queryOptions: QueryOptions): Promise<any>;
5
5
  private static createFilesFromRows;
6
6
  private static createFileFromRow;
7
7
  }
@@ -1,12 +1,12 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import File from "../stockObjects/File";
3
3
  export default class FilesRepo {
4
- static async get(fileId) {
5
- const file = await DatabaseConnection.getInstance().files.select(fileId);
4
+ static async get(queryOptions) {
5
+ const file = await DatabaseConnection.getInstance().files.select(queryOptions);
6
6
  return this.createFileFromRow(file);
7
7
  }
8
- static async getAllForConnection(connectionType, connectionId) {
9
- const files = await DatabaseConnection.getInstance().files.selectForConnection(connectionType, connectionId);
8
+ static async getAll(queryOptions) {
9
+ const files = await DatabaseConnection.getInstance().files.selectForConnection(queryOptions);
10
10
  return this.createFilesFromRows(files);
11
11
  }
12
12
  static async createFilesFromRows(dataRows) {
@@ -1,5 +1,6 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import InvoiceDetails from "../stockObjects/InvoiceDetails";
2
3
  export default class InvoiceDetailsRepo {
3
- static get(invoiceDetailsId: number): Promise<InvoiceDetails>;
4
+ static get(queryOptions: QueryOptions): Promise<InvoiceDetails>;
4
5
  private static createInvoiceDetailsFromRow;
5
6
  }
@@ -1,8 +1,8 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import InvoiceDetails from "../stockObjects/InvoiceDetails";
3
3
  export default class InvoiceDetailsRepo {
4
- static async get(invoiceDetailsId) {
5
- const invoiceDetailsRow = await DatabaseConnection.getInstance().invoiceDetails.select(invoiceDetailsId);
4
+ static async get(queryOptions) {
5
+ const invoiceDetailsRow = await DatabaseConnection.getInstance().invoiceDetails.select(queryOptions);
6
6
  return this.createInvoiceDetailsFromRow(invoiceDetailsRow);
7
7
  }
8
8
  static createInvoiceDetailsFromRow(invoiceDetailsRow) {
@@ -1,7 +1,7 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import OrderProduct from "../stockObjects/OrderProduct";
2
3
  export default class OrderProductsRepo {
3
- static getAllActive(orderId: number): Promise<OrderProduct[]>;
4
- static getAllForIds(orderProductsIds: number[]): Promise<OrderProduct[]>;
4
+ static getAll(queryOptions: QueryOptions): Promise<OrderProduct[]>;
5
5
  private static createOrdersProductsFromRows;
6
6
  private static createOrdersProductFromRow;
7
7
  }
@@ -1,21 +1,8 @@
1
- import { ConnectorE, ParameterType } from "@dascompany/database";
2
1
  import DatabaseConnection from "../DatabaseConnection";
3
2
  import OrderProduct from "../stockObjects/OrderProduct";
4
3
  export default class OrderProductsRepo {
5
- static async getAllActive(orderId) {
6
- const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAllActive(orderId);
7
- return this.createOrdersProductsFromRows(orderProducts);
8
- }
9
- static async getAllForIds(orderProductsIds) {
10
- const queryOptions = {
11
- where: {
12
- connector: ConnectorE.and,
13
- parameters: [
14
- { name: 'id', type: ParameterType.arrayBigint, value: orderProductsIds },
15
- ]
16
- }
17
- };
18
- const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAllForIds(queryOptions);
4
+ static async getAll(queryOptions) {
5
+ const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAll(queryOptions);
19
6
  return this.createOrdersProductsFromRows(orderProducts);
20
7
  }
21
8
  static async createOrdersProductsFromRows(dataRows) {
@@ -1,5 +1,6 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import Order from "../stockObjects/Order";
2
3
  export default class OrderRepo {
3
- static get(orderId: number): Promise<Order>;
4
+ static get(queryOptions: QueryOptions): Promise<Order>;
4
5
  private static createOrderFromRow;
5
6
  }
@@ -1,8 +1,8 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import Order from "../stockObjects/Order";
3
3
  export default class OrderRepo {
4
- static async get(orderId) {
5
- const orderData = await DatabaseConnection.getInstance().orders.select(orderId);
4
+ static async get(queryOptions) {
5
+ const orderData = await DatabaseConnection.getInstance().orders.select(queryOptions);
6
6
  return this.createOrderFromRow(orderData);
7
7
  }
8
8
  static createOrderFromRow(orderData) {
@@ -1,7 +1,8 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import Status from "../stockObjects/Status";
2
3
  export default class OrderStatusRepo {
3
- static get(orderId: number): Promise<Status>;
4
- static getAll(orderId: number): Promise<Status[]>;
4
+ static get(queryOptions: QueryOptions): Promise<Status>;
5
+ static getAll(queryOptions: QueryOptions): Promise<Status[]>;
5
6
  private static createStatusesFromRows;
6
7
  private static createStatusFromRow;
7
8
  }
@@ -1,12 +1,12 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import Status from "../stockObjects/Status";
3
3
  export default class OrderStatusRepo {
4
- static async get(orderId) {
5
- const status = await DatabaseConnection.getInstance().statuses.select(orderId);
4
+ static async get(queryOptions) {
5
+ const status = await DatabaseConnection.getInstance().statuses.select(queryOptions);
6
6
  return this.createStatusFromRow(status);
7
7
  }
8
- static async getAll(orderId) {
9
- const statuses = await DatabaseConnection.getInstance().statuses.selectAll(orderId);
8
+ static async getAll(queryOptions) {
9
+ const statuses = await DatabaseConnection.getInstance().statuses.selectAll(queryOptions);
10
10
  return this.createStatusesFromRows(statuses);
11
11
  }
12
12
  static async createStatusesFromRows(dataRows) {
@@ -1,5 +1,6 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import PaymentDetails from "../stockObjects/PaymentDetails";
2
3
  export default class PaymentDetailsRepo {
3
- static get(paymentDetailsId: number): Promise<PaymentDetails>;
4
+ static get(queryOptions: QueryOptions): Promise<PaymentDetails>;
4
5
  private static createPaymentDetailsFromRow;
5
6
  }
@@ -1,8 +1,8 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import PaymentDetails from "../stockObjects/PaymentDetails";
3
3
  export default class PaymentDetailsRepo {
4
- static async get(paymentDetailsId) {
5
- const paymentDetailsRow = await DatabaseConnection.getInstance().paymentDetails.select(paymentDetailsId);
4
+ static async get(queryOptions) {
5
+ const paymentDetailsRow = await DatabaseConnection.getInstance().paymentDetails.select(queryOptions);
6
6
  return this.createPaymentDetailsFromRow(paymentDetailsRow);
7
7
  }
8
8
  static createPaymentDetailsFromRow(paymentDetailsRow) {
@@ -1,4 +1,5 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import PaymentMethods from "../stockObjects/PaymentMethods";
2
3
  export default class PaymentMethodRepo {
3
- static get(id: number): Promise<PaymentMethods>;
4
+ static get(queryOptions: QueryOptions): Promise<PaymentMethods>;
4
5
  }
@@ -1,8 +1,8 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  import PaymentMethods from "../stockObjects/PaymentMethods";
3
3
  export default class PaymentMethodRepo {
4
- static async get(id) {
5
- const paymentMethodsRow = await DatabaseConnection.getInstance().paymentMethods.select(id);
4
+ static async get(queryOptions) {
5
+ const paymentMethodsRow = await DatabaseConnection.getInstance().paymentMethods.select(queryOptions);
6
6
  const paymentMethods = new PaymentMethods(paymentMethodsRow.key, paymentMethodsRow.active);
7
7
  paymentMethods.setId(paymentMethodsRow.id);
8
8
  return paymentMethods;
@@ -1,5 +1,6 @@
1
+ import { QueryOptions } from "@dascompany/database";
1
2
  import PersonalData from "../stockObjects/PersonalData";
2
3
  export default class PersonalDataRepo {
3
- static get(personalDataId: number): Promise<PersonalData>;
4
+ static get(queryOptions: QueryOptions): Promise<PersonalData>;
4
5
  private static createPersonalDataFromRow;
5
6
  }
@@ -2,8 +2,8 @@ import DatabaseConnection from "../DatabaseConnection";
2
2
  import PersonalData from "../stockObjects/PersonalData";
3
3
  import correctPhoneNumber from "../utils/correctPhoneNumber";
4
4
  export default class PersonalDataRepo {
5
- static async get(personalDataId) {
6
- const personalData = await DatabaseConnection.getInstance().personalData.select(personalDataId);
5
+ static async get(queryOptions) {
6
+ const personalData = await DatabaseConnection.getInstance().personalData.select(queryOptions);
7
7
  return this.createPersonalDataFromRow(personalData);
8
8
  }
9
9
  static createPersonalDataFromRow(dataRow) {
@@ -1,6 +1,6 @@
1
1
  import Product from "../stockObjects/Product";
2
+ import { QueryOptions } from "@dascompany/database";
2
3
  export default class ProductRepo {
3
- static get(productId: number): Promise<Product>;
4
- static getForSku(productSku: string): Promise<Product>;
4
+ static get(queryOptions: QueryOptions): Promise<Product>;
5
5
  private static createProductFromRow;
6
6
  }
@@ -1,12 +1,8 @@
1
1
  import Product from "../stockObjects/Product";
2
2
  import DatabaseConnection from "../DatabaseConnection";
3
3
  export default class ProductRepo {
4
- static async get(productId) {
5
- const product = await DatabaseConnection.getInstance().products.select(productId);
6
- return this.createProductFromRow(product);
7
- }
8
- static async getForSku(productSku) {
9
- const product = await DatabaseConnection.getInstance().products.selectForSku(productSku);
4
+ static async get(queryOptions) {
5
+ const product = await DatabaseConnection.getInstance().products.select(queryOptions);
10
6
  return this.createProductFromRow(product);
11
7
  }
12
8
  static createProductFromRow(productRow) {
@@ -1,4 +1,4 @@
1
- import { StockObject } from "@dascompany/database";
1
+ import { ParameterType, QueryOptions, StockObject } from "@dascompany/database";
2
2
  import OrderMapper from "../mappers/OrderMapper";
3
3
  import OrderProductsRepo from "../repo/OrderProductsRepo";
4
4
  import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
@@ -87,7 +87,9 @@ export default class Order extends StockObject {
87
87
  const id = this.getId();
88
88
  if (id) {
89
89
  let totalPrice = 0;
90
- const orderProducts = await OrderProductsRepo.getAllActive(id);
90
+ const queryOptions = new QueryOptions();
91
+ queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: id }]);
92
+ const orderProducts = await OrderProductsRepo.getAll(queryOptions);
91
93
  for (const product of orderProducts) {
92
94
  totalPrice += product.getNetPrice();
93
95
  }
@@ -1,4 +1,4 @@
1
- import { StockObject } from "@dascompany/database";
1
+ import { ParameterType, QueryOptions, StockObject } from "@dascompany/database";
2
2
  import PersonalDataMapper from "../mappers/PersonalDataMapper";
3
3
  import CompanyDetailsRepo from "../repo/CompanyDetailsRepo";
4
4
  export default class PersonalData extends StockObject {
@@ -35,8 +35,11 @@ export default class PersonalData extends StockObject {
35
35
  return companyDetailsData;
36
36
  }
37
37
  async getCompanyDetails() {
38
- if (this.companyDetailsId && !this.companyDetails)
39
- this.companyDetails = await CompanyDetailsRepo.get(this.companyDetailsId);
38
+ if (this.companyDetailsId && !this.companyDetails) {
39
+ const queryOptions = new QueryOptions();
40
+ queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: this.companyDetailsId }]);
41
+ this.companyDetails = await CompanyDetailsRepo.get(queryOptions);
42
+ }
40
43
  return this.companyDetails;
41
44
  }
42
45
  isCompany() {
@@ -1,4 +1,4 @@
1
- import { StockObject } from "@dascompany/database";
1
+ import { ParameterType, QueryOptions, StockObject } from "@dascompany/database";
2
2
  import ProductMapper from "../mappers/ProductMapper";
3
3
  import FilesReader from "../reader/FilesReader";
4
4
  import FileConnectionTypeE from "../types/FileConnectionTypeE";
@@ -87,15 +87,20 @@ export default class Product extends StockObject {
87
87
  return this.deleted;
88
88
  }
89
89
  async getFile() {
90
- if (!this.file && this.fileId)
91
- this.file = await FilesReader.get(this.fileId);
90
+ if (!this.file && this.fileId) {
91
+ const queryOptions = new QueryOptions();
92
+ queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: this.fileId }]);
93
+ this.file = await FilesReader.get(queryOptions);
94
+ }
92
95
  return this.file;
93
96
  }
94
97
  async getFiles() {
95
98
  if (!this.files) {
96
99
  const id = this.getId();
97
100
  if (id) {
98
- const files = await FilesReader.getForConnection(FileConnectionTypeE.product, id);
101
+ const queryOptions = new QueryOptions();
102
+ queryOptions.setWhere([{ name: 'connection_id', type: ParameterType.bigint, value: id }, { name: 'connection_type', type: ParameterType.string, value: FileConnectionTypeE.product }]);
103
+ const files = await FilesReader.getForConnection(queryOptions);
99
104
  this.files = files;
100
105
  }
101
106
  }
@@ -1,16 +1,14 @@
1
- import { QueryOptionsI, Table } from '@dascompany/database';
1
+ import { QueryOptions, Table } from '@dascompany/database';
2
2
  import ClientAccountRow from '../../types/rows/ClientAccountRow';
3
3
  import Client from '../../stockObjects/Client';
4
4
  export default class ClientAccountsTable extends Table {
5
- select(accountId: number): Promise<ClientAccountRow>;
6
- selectEmail(id: number): Promise<string>;
7
- count(queryOptions: QueryOptionsI): Promise<number>;
8
- selectAll(queryOptions: QueryOptionsI): Promise<ClientAccountRow[]>;
9
- selectForEmail(email: string): Promise<ClientAccountRow>;
5
+ select(queryOptions: QueryOptions): Promise<ClientAccountRow>;
6
+ selectAll(queryOptions: QueryOptions): Promise<ClientAccountRow[]>;
7
+ selectId(queryOptions: QueryOptions): Promise<number | null>;
8
+ count(queryOptions: QueryOptions): Promise<number>;
10
9
  update(clientData: Client): Promise<void>;
11
10
  delete(accountId: number): Promise<number>;
12
11
  private bindParameters;
13
12
  insert(clientAccount: Client): Promise<void>;
14
- getIdForEmail(email: string): Promise<number>;
15
13
  private selectNextId;
16
14
  }
@@ -1,15 +1,18 @@
1
- import { Table } from '@dascompany/database';
1
+ import { ParameterType, QueryOptions, Table } from '@dascompany/database';
2
2
  import * as SQL from '../../SQL.json';
3
3
  export default class ClientAccountsTable extends Table {
4
- async select(accountId) {
5
- const query = this.createQuery(SQL.accounts.select);
6
- query.bindParameter('account_id', accountId);
4
+ async select(queryOptions) {
5
+ const query = this.createQuery(SQL.accounts.select, queryOptions);
7
6
  const result = await query.execute();
8
7
  return result.getRow();
9
8
  }
10
- async selectEmail(id) {
11
- const query = this.createQuery(SQL.accounts.selectEmail);
12
- query.bindParameter('id', id);
9
+ async selectAll(queryOptions) {
10
+ const query = this.createQuery(SQL.accounts.select, queryOptions);
11
+ const result = await query.execute();
12
+ return result.getRows();
13
+ }
14
+ async selectId(queryOptions) {
15
+ const query = this.createQuery(SQL.accounts.selectId, queryOptions);
13
16
  const result = await query.execute();
14
17
  return result.getValue();
15
18
  }
@@ -18,15 +21,6 @@ export default class ClientAccountsTable extends Table {
18
21
  const result = await query.execute();
19
22
  return result.getValue();
20
23
  }
21
- async selectAll(queryOptions) {
22
- const query = this.createQuery(SQL.accounts.selectAll, queryOptions);
23
- const result = await query.execute();
24
- return result.getRows();
25
- }
26
- async selectForEmail(email) {
27
- const id = await this.getIdForEmail(email);
28
- return await this.select(id);
29
- }
30
24
  async update(clientData) {
31
25
  const query = this.createQuery(SQL.accounts.update);
32
26
  query.bindParameter('id', clientData.getId());
@@ -48,7 +42,9 @@ export default class ClientAccountsTable extends Table {
48
42
  }
49
43
  async insert(clientAccount) {
50
44
  const clientEmail = clientAccount.getEmail();
51
- let accountId = await this.getIdForEmail(clientEmail);
45
+ const queryOptions = new QueryOptions();
46
+ queryOptions.setWhere([{ name: 'email', type: ParameterType.string, value: clientEmail }]);
47
+ let accountId = await this.selectId(queryOptions);
52
48
  if (accountId)
53
49
  throw new Error(`Client account with email: ${clientEmail} already exist!`);
54
50
  else
@@ -60,12 +56,6 @@ export default class ClientAccountsTable extends Table {
60
56
  await query.execute();
61
57
  clientAccount.setId(accountId);
62
58
  }
63
- async getIdForEmail(email) {
64
- const query = this.createQuery(SQL.accounts.getIdForEmail);
65
- query.bindParameter('email', String(email).toUpperCase());
66
- const result = await query.execute();
67
- return result.getValue();
68
- }
69
59
  async selectNextId() {
70
60
  const query = this.createQuery(SQL.accounts.selectNextId);
71
61
  const result = await query.execute();
@@ -1,12 +1,9 @@
1
- import { Table } from '@dascompany/database';
2
- import FileConnectionTypeE from '../../types/FileConnectionTypeE';
1
+ import { QueryOptions, Table } from '@dascompany/database';
3
2
  import FileConnection from '../../stockObjects/FileConnection';
4
3
  import FileConnectionRow from '../../types/rows/FileConnectionRow';
5
4
  export default class FileConnectionsTable extends Table {
6
- select(connectionType: FileConnectionTypeE, connection_id: number): Promise<any[]>;
7
- selectForFileId(fileId: number): Promise<FileConnectionRow[]>;
5
+ selectAll(queryOptions: QueryOptions): Promise<FileConnectionRow[]>;
8
6
  insert(fileConnection: FileConnection): Promise<void>;
9
- delete(fileId: number): Promise<boolean>;
10
- deleteForConnection(connectionType: string, connectionId: number): Promise<boolean>;
7
+ delete(id: number): Promise<boolean>;
11
8
  private bindParameters;
12
9
  }
@@ -1,16 +1,8 @@
1
1
  import { Table } from '@dascompany/database';
2
2
  import * as SQL from '../../SQL.json';
3
3
  export default class FileConnectionsTable extends Table {
4
- async select(connectionType, connection_id) {
5
- const query = this.createQuery(SQL.fileConnections.select);
6
- query.bindParameter('connectionType', connectionType);
7
- query.bindParameter('connection_id', connection_id);
8
- const result = await query.execute();
9
- return result.getRows();
10
- }
11
- async selectForFileId(fileId) {
12
- const query = this.createQuery(SQL.fileConnections.selectForFileId);
13
- query.bindParameter('file_id', fileId);
4
+ async selectAll(queryOptions) {
5
+ const query = this.createQuery(SQL.fileConnections.select, queryOptions);
14
6
  const result = await query.execute();
15
7
  return result.getRows();
16
8
  }
@@ -19,16 +11,9 @@ export default class FileConnectionsTable extends Table {
19
11
  this.bindParameters(query, fileConnection);
20
12
  await query.execute();
21
13
  }
22
- async delete(fileId) {
14
+ async delete(id) {
23
15
  const query = this.createQuery(SQL.fileConnections.delete);
24
- query.bindParameter('file_id', fileId);
25
- await query.execute();
26
- return true;
27
- }
28
- async deleteForConnection(connectionType, connectionId) {
29
- const query = this.createQuery(SQL.fileConnections.deleteForConnection);
30
- query.bindParameter('connection_type', connectionType);
31
- query.bindParameter('connection_id', connectionId);
16
+ query.bindParameter('id', id);
32
17
  await query.execute();
33
18
  return true;
34
19
  }
@@ -1,15 +1,14 @@
1
- import { QueryOptionsI, Table } from '@dascompany/database';
1
+ import { QueryOptions, Table } from '@dascompany/database';
2
2
  import FileRow from '../../types/rows/FileRow';
3
- import FileConnectionTypeE from '../../types/FileConnectionTypeE';
4
3
  import File from '../../stockObjects/File';
5
4
  export default class FilesTable extends Table {
6
- selectId(queryOptions: QueryOptionsI): Promise<number>;
7
- selectAll(queryOptions: QueryOptionsI): Promise<FileRow[]>;
8
- select(fileId: number): Promise<FileRow>;
9
- selectForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<FileRow[]>;
5
+ select(queryOptions: QueryOptions): Promise<FileRow>;
6
+ selectAll(queryOptions: QueryOptions): Promise<FileRow[]>;
7
+ selectId(queryOptions: QueryOptions): Promise<number>;
8
+ selectForConnection(queryOptions: QueryOptions): Promise<FileRow[]>;
10
9
  insert(file: File): Promise<boolean>;
11
10
  update(fileData: File): Promise<boolean>;
12
- count(queryOptions: QueryOptionsI): Promise<number>;
11
+ count(queryOptions: QueryOptions): Promise<number>;
13
12
  private bindParameters;
14
13
  delete(fileId: number): Promise<number>;
15
14
  private selectNextId;
@@ -1,26 +1,23 @@
1
1
  import { Table } from '@dascompany/database';
2
2
  import * as SQL from '../../SQL.json';
3
3
  export default class FilesTable extends Table {
4
- async selectId(queryOptions) {
5
- const query = this.createQuery(SQL.files.selectId, queryOptions);
4
+ async select(queryOptions) {
5
+ const query = this.createQuery(SQL.files.select, queryOptions);
6
6
  const result = await query.execute();
7
- return result.getValue();
7
+ return result.getRow();
8
8
  }
9
9
  async selectAll(queryOptions) {
10
- const query = this.createQuery(SQL.files.selectAll, queryOptions);
10
+ const query = this.createQuery(SQL.files.select, queryOptions);
11
11
  const result = await query.execute();
12
12
  return result.getRows();
13
13
  }
14
- async select(fileId) {
15
- const query = this.createQuery(SQL.files.select);
16
- query.bindParameter('id', fileId);
14
+ async selectId(queryOptions) {
15
+ const query = this.createQuery(SQL.files.selectId, queryOptions);
17
16
  const result = await query.execute();
18
- return result.getRow();
17
+ return result.getValue();
19
18
  }
20
- async selectForConnection(connectionType, connectionId) {
21
- const query = this.createQuery(SQL.files.selectForConnection);
22
- query.bindParameter('connection_type', connectionType);
23
- query.bindParameter('connection_id', connectionId);
19
+ async selectForConnection(queryOptions) {
20
+ const query = this.createQuery(SQL.files.selectForConnection, queryOptions);
24
21
  const result = await query.execute();
25
22
  return result.getRows();
26
23
  }
@@ -1,11 +1,10 @@
1
- import { QueryOptionsI, Table } from '@dascompany/database';
1
+ import { QueryOptions, Table } from '@dascompany/database';
2
2
  import OrderProductRow from '../../types/rows/OrderProductRow';
3
3
  import OrderProduct from '../../stockObjects/OrderProduct';
4
4
  export default class OrdersProductsTable extends Table {
5
- selectAllActive(orderId: number): Promise<OrderProductRow[]>;
6
- selectAllForIds(queryOprions: QueryOptionsI): Promise<OrderProductRow[]>;
7
- delete(orderProduct: OrderProduct): Promise<boolean>;
8
- private bindParams;
5
+ selectAll(queryOprions: QueryOptions): Promise<OrderProductRow[]>;
9
6
  insert(orderProduct: OrderProduct): Promise<boolean>;
7
+ delete(orderProduct: OrderProduct): Promise<boolean>;
10
8
  private selectNextId;
9
+ private bindParams;
11
10
  }
@@ -1,30 +1,11 @@
1
1
  import { Table } from '@dascompany/database';
2
2
  import * as SQL from '../../SQL.json';
3
3
  export default class OrdersProductsTable extends Table {
4
- async selectAllActive(orderId) {
5
- const query = this.createQuery(SQL.ordersProducts.selectAllActive);
6
- query.bindParameter('order_id', orderId);
7
- const result = await query.execute();
8
- return result.getRows();
9
- }
10
- async selectAllForIds(queryOprions) {
4
+ async selectAll(queryOprions) {
11
5
  const query = this.createQuery(SQL.ordersProducts.selectAll, queryOprions);
12
6
  const result = await query.execute();
13
7
  return result.getRows();
14
8
  }
15
- async delete(orderProduct) {
16
- const query = this.createQuery(SQL.ordersProducts.delete);
17
- const id = orderProduct.getId();
18
- query.bindParameter('id', id);
19
- await query.execute();
20
- return true;
21
- }
22
- bindParams(query, orderProduct) {
23
- query.bindParameter('order_id', orderProduct.getOrderId());
24
- query.bindParameter('product_id', orderProduct.getProductId());
25
- query.bindParameter('net_price', orderProduct.getNetPrice());
26
- query.bindParameter('in_order', orderProduct.getInOrder());
27
- }
28
9
  async insert(orderProduct) {
29
10
  const query = this.createQuery(SQL.ordersProducts.insert);
30
11
  const id = await this.selectNextId();
@@ -34,9 +15,22 @@ export default class OrdersProductsTable extends Table {
34
15
  orderProduct.setId(id);
35
16
  return true;
36
17
  }
18
+ async delete(orderProduct) {
19
+ const query = this.createQuery(SQL.ordersProducts.delete);
20
+ const id = orderProduct.getId();
21
+ query.bindParameter('id', id);
22
+ await query.execute();
23
+ return true;
24
+ }
37
25
  async selectNextId() {
38
26
  const query = this.createQuery(SQL.ordersProducts.selectNextId);
39
27
  const result = await query.execute();
40
28
  return result.getValue();
41
29
  }
30
+ bindParams(query, orderProduct) {
31
+ query.bindParameter('order_id', orderProduct.getOrderId());
32
+ query.bindParameter('product_id', orderProduct.getProductId());
33
+ query.bindParameter('net_price', orderProduct.getNetPrice());
34
+ query.bindParameter('in_order', orderProduct.getInOrder());
35
+ }
42
36
  }
@@ -1,11 +1,10 @@
1
- import { QueryOptionsI, Table } from '@dascompany/database';
1
+ import { QueryOptions, Table } from '@dascompany/database';
2
2
  import OrderRow from '../../types/rows/OrderRow';
3
3
  import Order from '../../stockObjects/Order';
4
4
  export default class OrdersTable extends Table {
5
- select(orderId: number): Promise<OrderRow>;
6
- selectForClient(clientId: number): Promise<OrderRow[]>;
7
- selectAll(queryOption: QueryOptionsI): Promise<OrderRow[]>;
8
- count(queryOptions?: QueryOptionsI): Promise<number>;
5
+ select(queryOptions: QueryOptions): Promise<OrderRow>;
6
+ selectAll(queryOption: QueryOptions): Promise<OrderRow[]>;
7
+ count(queryOptions?: QueryOptions): Promise<number>;
9
8
  insert(order: Order): Promise<void>;
10
9
  update(order: Order): Promise<void>;
11
10
  private bindParameters;