@dascompany/product 1.1.3 → 1.1.5

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
@@ -58,14 +58,14 @@
58
58
  "selectNextId": "SELECT nextval('personal_information.company_details_id'::regclass)"
59
59
  },
60
60
  "products": {
61
- "select": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE id = $id::BIGINT",
62
- "selectForUrl": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE LOWER( url ) = LOWER($url::TEXT)",
61
+ "select": "SELECT * FROM products WHERE id = $id::BIGINT",
62
+ "selectForUrl": "SELECT * FROM products WHERE LOWER( url ) = LOWER($url::TEXT)",
63
63
  "selectForSku": "SELECT * FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
64
64
  "selectAll": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products $WHERE $ORDERBY LIMIT $limit::BIGINT OFFSET $offset::BIGINT",
65
65
  "selectAllActive": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE deleted = false $PARAMS $ORDERBY LIMIT $limit::BIGINT OFFSET $offset::BIGINT",
66
66
  "selectIdForSku": "SELECT id FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT) AND deleted = false",
67
- "insert": "INSERT INTO products( id, sku, url, title, description, net_price, vat, color, quantity, width, length, height, file_id, deleted) VALUES ($id::BIGINT, $sku::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $vat::INT, $color::TEXT, $quantity::INT, $width::INT, $length::INT, $height::DOUBLE PRECISION,$file_id::BIGINT ,false::BOOL)",
68
- "update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT, description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, vat = $vat::INT, color = $color::TEXT, quantity = $quantity::INT, width = $width::INT, length = $length::INT, height = $height::DOUBLE PRECISION, file_id = $file_id::BIGINT WHERE id = $id::BIGINT",
67
+ "insert": "INSERT INTO products( id, sku, url, title, description, net_price, vat, color, quantity, width, length, height, file_id, deleted, json_data) VALUES ($id::BIGINT, $sku::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $vat::INT, $color::TEXT, $quantity::INT, $width::INT, $length::INT, $height::DOUBLE PRECISION,$file_id::BIGINT , $json_data::JSON, false::BOOL)",
68
+ "update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT, description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, vat = $vat::INT, color = $color::TEXT, quantity = $quantity::INT, width = $width::INT, length = $length::INT, height = $height::DOUBLE PRECISION, file_id = $file_id::BIGINT, json_data = $json_data::JSON WHERE id = $id::BIGINT",
69
69
  "delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
70
70
  "selectNextId": "SELECT nextval('product_id'::regclass)",
71
71
  "count": "SELECT COUNT(*) AS total_rows FROM products WHERE deleted = false $PARAMS"
@@ -51,7 +51,8 @@ export default class ProductReader {
51
51
  deleted: product.deleted,
52
52
  thumbnail: thumbnail ? thumbnail : null,
53
53
  files,
54
- grossPrice: calculateNetToGrossPrice(product.net_price, product.vat)
54
+ grossPrice: calculateNetToGrossPrice(product.net_price, product.vat),
55
+ jsonData: product.json_data
55
56
  };
56
57
  }
57
58
  }
@@ -16,8 +16,9 @@ export default class Product extends StockObject {
16
16
  private deleted;
17
17
  private createdAt;
18
18
  private file;
19
+ private jsonData;
19
20
  private files;
20
- constructor(sku: string, url: string, title: string, description: string, netPrice: number, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, deleted?: boolean);
21
+ constructor(sku: string, url: string, title: string, description: string, netPrice: number, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, jsonData: any, deleted?: boolean);
21
22
  getSku(): string;
22
23
  getUrl(): string;
23
24
  getTitle(): string;
@@ -31,6 +32,7 @@ export default class Product extends StockObject {
31
32
  getLength(): number;
32
33
  getHeight(): number;
33
34
  getFileId(): number;
35
+ getJsonData(): any;
34
36
  getDeleted(): boolean;
35
37
  getFile(): Promise<FileI | null>;
36
38
  getFiles(): Promise<FileI[] | null>;
@@ -64,6 +66,7 @@ export default class Product extends StockObject {
64
66
  setLength(length: number): number;
65
67
  setHeight(height: number): number;
66
68
  setFileId(fileId: number): number;
69
+ setJsonData(jsonData: any): any;
67
70
  setDeleted(deleted: boolean): boolean;
68
71
  protected getMapper(): StockObjectMapper;
69
72
  }
@@ -19,8 +19,9 @@ export default class Product extends StockObject {
19
19
  deleted;
20
20
  createdAt;
21
21
  file;
22
+ jsonData;
22
23
  files;
23
- constructor(sku, url, title, description, netPrice, vat, color, quantity, width, length, height, fileId, deleted = false) {
24
+ constructor(sku, url, title, description, netPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
24
25
  super();
25
26
  this.sku = sku;
26
27
  this.url = url;
@@ -34,6 +35,7 @@ export default class Product extends StockObject {
34
35
  this.length = length;
35
36
  this.height = height;
36
37
  this.fileId = fileId;
38
+ this.jsonData = jsonData;
37
39
  this.deleted = deleted;
38
40
  this.createdAt = null;
39
41
  this.file = null;
@@ -78,6 +80,9 @@ export default class Product extends StockObject {
78
80
  getFileId() {
79
81
  return this.fileId;
80
82
  }
83
+ getJsonData() {
84
+ return this.jsonData;
85
+ }
81
86
  getDeleted() {
82
87
  return this.deleted;
83
88
  }
@@ -154,6 +159,9 @@ export default class Product extends StockObject {
154
159
  setFileId(fileId) {
155
160
  return this.fileId = fileId;
156
161
  }
162
+ setJsonData(jsonData) {
163
+ return this.jsonData = jsonData;
164
+ }
157
165
  setDeleted(deleted) {
158
166
  return this.deleted = deleted;
159
167
  }
@@ -80,6 +80,7 @@ export default class ProductsTable extends Table {
80
80
  query.bindParameter('length', productData.getLength());
81
81
  query.bindParameter('height', productData.getHeight());
82
82
  query.bindParameter('file_id', productData.getFileId());
83
+ query.bindParameter('json_data', productData.getJsonData());
83
84
  }
84
85
  async selectNextId() {
85
86
  const query = this.createQuery(SQL.products.selectNextId);
@@ -17,4 +17,5 @@ export default interface ProductI {
17
17
  createdAt: string;
18
18
  deleted: boolean;
19
19
  files?: FileI[];
20
+ jsonData: any;
20
21
  }
@@ -14,4 +14,5 @@ export default interface ProductRow {
14
14
  length: number;
15
15
  created_at: string;
16
16
  deleted: boolean;
17
+ json_data: any;
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
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": "^2.1.2",
23
+ "@dascompany/database": "^2.1.3",
24
24
  "@types/pg": "^8.11.11",
25
25
  "pg": "^8.13.3"
26
26
  }