@smess/networking 1.0.18 → 1.0.19

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.
@@ -1,4 +1,4 @@
1
- import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped } from "../types/types";
1
+ import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
2
2
  import { SmessService } from "./smess.service";
3
3
  import { BehaviorSubject, Observable } from "rxjs";
4
4
  export type StoreCartTarget = "cart-get" | "cart-update" | "cart-add-item" | "cart-update-item" | "cart-delete-item" | "cart-delete-all-items";
@@ -84,12 +84,12 @@ export declare class StoreCartProvider implements ProviderType {
84
84
  getPath(...queryParams: unknown[]): string;
85
85
  }
86
86
  export interface StoreCartServiceType {
87
- getCart(): Observable<NetworkingUIEventWrapped<Cart>>;
88
- updateCart(payload: CartUpdateRequest): Observable<NetworkingUIEventWrapped<Cart>>;
89
- addItem(payload: CartAddItemRequest): Observable<NetworkingUIEventWrapped<Cart>>;
90
- updateItemQuantity(itemId: string, payload: CartUpdateItemQuantityRequest): Observable<NetworkingUIEventWrapped<Cart>>;
91
- deleteItem(itemId: string): Observable<NetworkingUIEventWrapped<void>>;
92
- deleteAllItems(): Observable<NetworkingUIEventWrapped<void>>;
87
+ getCart(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
88
+ updateCart(payload: CartUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
89
+ addItem(payload: CartAddItemRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
90
+ updateItemQuantity(itemId: string, payload: CartUpdateItemQuantityRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
91
+ deleteItem(itemId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
92
+ deleteAllItems(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
93
93
  }
94
94
  export declare class StoreCartService implements StoreCartServiceType {
95
95
  private readonly config;
@@ -110,30 +110,30 @@ export declare class StoreCartService implements StoreCartServiceType {
110
110
  * Get the current cart
111
111
  * GET api/v1/store/cart
112
112
  */
113
- getCart(): Observable<NetworkingUIEventWrapped<Cart>>;
113
+ getCart(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
114
114
  /**
115
115
  * Update cart (e.g., add notes, apply coupon)
116
116
  * PUT api/v1/store/cart
117
117
  */
118
- updateCart(payload: CartUpdateRequest): Observable<NetworkingUIEventWrapped<Cart>>;
118
+ updateCart(payload: CartUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
119
119
  /**
120
120
  * Add item to cart
121
121
  * POST api/v1/store/cart/items
122
122
  */
123
- addItem(payload: CartAddItemRequest): Observable<NetworkingUIEventWrapped<Cart>>;
123
+ addItem(payload: CartAddItemRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
124
124
  /**
125
125
  * Update item quantity in cart
126
126
  * PUT api/v1/store/cart/items/{id}
127
127
  */
128
- updateItemQuantity(itemId: string, payload: CartUpdateItemQuantityRequest): Observable<NetworkingUIEventWrapped<Cart>>;
128
+ updateItemQuantity(itemId: string, payload: CartUpdateItemQuantityRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
129
129
  /**
130
130
  * Delete item from cart
131
131
  * DELETE api/v1/store/cart/items/{id}
132
132
  */
133
- deleteItem(itemId: string): Observable<NetworkingUIEventWrapped<void>>;
133
+ deleteItem(itemId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
134
134
  /**
135
135
  * Delete all items from cart
136
136
  * DELETE api/v1/store/cart/items
137
137
  */
138
- deleteAllItems(): Observable<NetworkingUIEventWrapped<void>>;
138
+ deleteAllItems(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
139
139
  }
@@ -81,14 +81,14 @@ export declare class StoreProductProvider implements ProviderType {
81
81
  getPath(...queryParams: unknown[]): string;
82
82
  }
83
83
  export interface StoreProductServiceType {
84
- getFeaturedProductList(): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
85
- getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
86
- getProductCategoryList(): Observable<NetworkingUIEventWrapped<ProductCategory[]>>;
87
- getProductById(productId: string): Observable<NetworkingUIEventWrapped<StoreProduct>>;
84
+ getFeaturedProductList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
85
+ getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
86
+ getProductCategoryList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
87
+ getProductById(productId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
88
88
  getStoreList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
89
89
  getStoreInformation(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
90
- getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
91
- getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
90
+ getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
91
+ getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
92
92
  updateProductBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
93
93
  updateCustomerBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
94
94
  updateCartBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
@@ -102,22 +102,22 @@ export declare class StoreProductService implements StoreProductServiceType {
102
102
  * Get featured product list
103
103
  * GET /api/v1/store/featured-product-list
104
104
  */
105
- getFeaturedProductList(): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
105
+ getFeaturedProductList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
106
106
  /**
107
107
  * Get featured product list by store
108
108
  * GET /api/v1/store/{id}/featured-product-list
109
109
  */
110
- getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
110
+ getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
111
111
  /**
112
112
  * Get product category list
113
113
  * GET /api/v1/store/product-category/list
114
114
  */
115
- getProductCategoryList(): Observable<NetworkingUIEventWrapped<ProductCategory[]>>;
115
+ getProductCategoryList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
116
116
  /**
117
117
  * Get product by ID
118
118
  * GET /api/v1/store/product/{id}
119
119
  */
120
- getProductById(productId: string): Observable<NetworkingUIEventWrapped<StoreProduct>>;
120
+ getProductById(productId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
121
121
  /**
122
122
  * Get store list
123
123
  * GET /api/v1/store/list
@@ -132,12 +132,12 @@ export declare class StoreProductService implements StoreProductServiceType {
132
132
  * Get product collection
133
133
  * GET /api/v1/store/product-collection
134
134
  */
135
- getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
135
+ getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
136
136
  /**
137
137
  * Get product collection by store
138
138
  * GET /api/v1/store/{id}/product-collection
139
139
  */
140
- getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
140
+ getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
141
141
  /**
142
142
  * Update product batch
143
143
  * POST /api/v1/store/{id}/product
@@ -14,37 +14,39 @@ describe("StoreProductService", () => {
14
14
  });
15
15
  describe("getFeaturedProductList", () => {
16
16
  it("should get featured product list successfully", async () => {
17
- const response = [
18
- {
19
- id: "1",
20
- name: "Product 1",
21
- barcode: "123",
22
- category: "CONGELE",
23
- vatInPercent: 5.5,
24
- unit: "piece",
25
- quantity: 1,
26
- picture: "image.png",
27
- slug: "product-1",
28
- internalCode: "001",
29
- inventory: true,
30
- quantityInStock: 10,
31
- minimumStockQuantity: 5,
32
- pricePurchase: 10,
33
- priceToSell: 15,
34
- discountInPercent: 0,
35
- priceAfterDiscount: 0,
36
- expiryDate: null,
37
- subCategory: null,
38
- volume: null,
39
- unitWeight: null,
40
- articleWeight: null,
41
- tareWeight: null,
42
- supplier: null,
43
- supplierCode: null,
44
- supplierItemName: null,
45
- htmlDescription: null,
46
- },
47
- ];
17
+ const response = {
18
+ data: [
19
+ {
20
+ id: "1",
21
+ name: "Product 1",
22
+ barcode: "123",
23
+ category: "CONGELE",
24
+ vatInPercent: 5.5,
25
+ unit: "piece",
26
+ quantity: 1,
27
+ picture: "image.png",
28
+ slug: "product-1",
29
+ internalCode: "001",
30
+ inventory: true,
31
+ quantityInStock: 10,
32
+ minimumStockQuantity: 5,
33
+ pricePurchase: 10,
34
+ priceToSell: 15,
35
+ discountInPercent: 0,
36
+ priceAfterDiscount: 0,
37
+ expiryDate: null,
38
+ subCategory: null,
39
+ volume: null,
40
+ unitWeight: null,
41
+ articleWeight: null,
42
+ tareWeight: null,
43
+ supplier: null,
44
+ supplierCode: null,
45
+ supplierItemName: null,
46
+ htmlDescription: null,
47
+ },
48
+ ],
49
+ };
48
50
  jest.spyOn(service, "provider").mockReturnValue({
49
51
  request: () => of(NetworkingUIEventWrapped.succeeded(response)),
50
52
  });
@@ -63,9 +65,77 @@ describe("StoreProductService", () => {
63
65
  describe("getFeaturedProductListByStore", () => {
64
66
  it("should get featured product list by store successfully", async () => {
65
67
  const storeId = "store-123";
66
- const response = [
67
- {
68
- id: "1",
68
+ const response = {
69
+ data: [
70
+ {
71
+ id: "1",
72
+ name: "Product 1",
73
+ barcode: "123",
74
+ category: "CONGELE",
75
+ vatInPercent: 5.5,
76
+ unit: "piece",
77
+ quantity: 1,
78
+ picture: "image.png",
79
+ slug: "product-1",
80
+ internalCode: "001",
81
+ inventory: true,
82
+ quantityInStock: 10,
83
+ minimumStockQuantity: 5,
84
+ pricePurchase: 10,
85
+ priceToSell: 15,
86
+ discountInPercent: 0,
87
+ priceAfterDiscount: 0,
88
+ expiryDate: null,
89
+ subCategory: null,
90
+ volume: null,
91
+ unitWeight: null,
92
+ articleWeight: null,
93
+ tareWeight: null,
94
+ supplier: null,
95
+ supplierCode: null,
96
+ supplierItemName: null,
97
+ htmlDescription: null,
98
+ },
99
+ ],
100
+ };
101
+ jest.spyOn(service, "provider").mockReturnValue({
102
+ request: () => of(NetworkingUIEventWrapped.succeeded(response)),
103
+ });
104
+ const result = await service.getFeaturedProductListByStore(storeId).toPromise();
105
+ expect(result?.hasSuccess).toBe(true);
106
+ expect(result?.response).toEqual(response);
107
+ });
108
+ });
109
+ describe("getProductCategoryList", () => {
110
+ it("should get product category list successfully", async () => {
111
+ const response = {
112
+ data: [
113
+ {
114
+ name: "BOISSON",
115
+ numberOfProducts: 443,
116
+ image: null,
117
+ },
118
+ {
119
+ name: "CONGELE",
120
+ numberOfProducts: 324,
121
+ image: null,
122
+ },
123
+ ],
124
+ };
125
+ jest.spyOn(service, "provider").mockReturnValue({
126
+ request: () => of(NetworkingUIEventWrapped.succeeded(response)),
127
+ });
128
+ const result = await service.getProductCategoryList().toPromise();
129
+ expect(result?.hasSuccess).toBe(true);
130
+ expect(result?.response).toEqual(response);
131
+ });
132
+ });
133
+ describe("getProductById", () => {
134
+ it("should get product by id successfully", async () => {
135
+ const productId = "product-123";
136
+ const response = {
137
+ data: {
138
+ id: productId,
69
139
  name: "Product 1",
70
140
  barcode: "123",
71
141
  category: "CONGELE",
@@ -93,68 +163,6 @@ describe("StoreProductService", () => {
93
163
  supplierItemName: null,
94
164
  htmlDescription: null,
95
165
  },
96
- ];
97
- jest.spyOn(service, "provider").mockReturnValue({
98
- request: () => of(NetworkingUIEventWrapped.succeeded(response)),
99
- });
100
- const result = await service.getFeaturedProductListByStore(storeId).toPromise();
101
- expect(result?.hasSuccess).toBe(true);
102
- expect(result?.response).toEqual(response);
103
- });
104
- });
105
- describe("getProductCategoryList", () => {
106
- it("should get product category list successfully", async () => {
107
- const response = [
108
- {
109
- name: "BOISSON",
110
- numberOfProducts: 443,
111
- image: null,
112
- },
113
- {
114
- name: "CONGELE",
115
- numberOfProducts: 324,
116
- image: null,
117
- },
118
- ];
119
- jest.spyOn(service, "provider").mockReturnValue({
120
- request: () => of(NetworkingUIEventWrapped.succeeded(response)),
121
- });
122
- const result = await service.getProductCategoryList().toPromise();
123
- expect(result?.hasSuccess).toBe(true);
124
- expect(result?.response).toEqual(response);
125
- });
126
- });
127
- describe("getProductById", () => {
128
- it("should get product by id successfully", async () => {
129
- const productId = "product-123";
130
- const response = {
131
- id: productId,
132
- name: "Product 1",
133
- barcode: "123",
134
- category: "CONGELE",
135
- vatInPercent: 5.5,
136
- unit: "piece",
137
- quantity: 1,
138
- picture: "image.png",
139
- slug: "product-1",
140
- internalCode: "001",
141
- inventory: true,
142
- quantityInStock: 10,
143
- minimumStockQuantity: 5,
144
- pricePurchase: 10,
145
- priceToSell: 15,
146
- discountInPercent: 0,
147
- priceAfterDiscount: 0,
148
- expiryDate: null,
149
- subCategory: null,
150
- volume: null,
151
- unitWeight: null,
152
- articleWeight: null,
153
- tareWeight: null,
154
- supplier: null,
155
- supplierCode: null,
156
- supplierItemName: null,
157
- htmlDescription: null,
158
166
  };
159
167
  jest.spyOn(service, "provider").mockReturnValue({
160
168
  request: () => of(NetworkingUIEventWrapped.succeeded(response)),
@@ -195,48 +203,50 @@ describe("StoreProductService", () => {
195
203
  search: "test",
196
204
  };
197
205
  const response = {
198
- links: {
199
- first: "/api/v1/store/product-collection?per_page=10&page=1",
200
- last: "/api/v1/store/product-collection?per_page=10&page=5",
201
- next: "/api/v1/store/product-collection?per_page=10&page=2",
202
- },
203
- items: [
204
- {
205
- id: "1",
206
- name: "Product 1",
207
- barcode: "123",
208
- category: "CONGELE",
209
- vatInPercent: 5.5,
210
- unit: "piece",
211
- quantity: 1,
212
- picture: "image.png",
213
- slug: "product-1",
214
- internalCode: "001",
215
- inventory: true,
216
- quantityInStock: 10,
217
- minimumStockQuantity: 5,
218
- pricePurchase: 10,
219
- priceToSell: 15,
220
- discountInPercent: 0,
221
- priceAfterDiscount: 0,
222
- expiryDate: null,
223
- subCategory: null,
224
- volume: null,
225
- unitWeight: null,
226
- articleWeight: null,
227
- tareWeight: null,
228
- supplier: null,
229
- supplierCode: null,
230
- supplierItemName: null,
231
- htmlDescription: null,
206
+ data: {
207
+ links: {
208
+ first: "/api/v1/store/product-collection?per_page=10&page=1",
209
+ last: "/api/v1/store/product-collection?per_page=10&page=5",
210
+ next: "/api/v1/store/product-collection?per_page=10&page=2",
232
211
  },
233
- ],
234
- count: 10,
235
- total: 50,
236
- page: 1,
237
- totalPage: 5,
238
- perPage: 10,
239
- metadata: [],
212
+ items: [
213
+ {
214
+ id: "1",
215
+ name: "Product 1",
216
+ barcode: "123",
217
+ category: "CONGELE",
218
+ vatInPercent: 5.5,
219
+ unit: "piece",
220
+ quantity: 1,
221
+ picture: "image.png",
222
+ slug: "product-1",
223
+ internalCode: "001",
224
+ inventory: true,
225
+ quantityInStock: 10,
226
+ minimumStockQuantity: 5,
227
+ pricePurchase: 10,
228
+ priceToSell: 15,
229
+ discountInPercent: 0,
230
+ priceAfterDiscount: 0,
231
+ expiryDate: null,
232
+ subCategory: null,
233
+ volume: null,
234
+ unitWeight: null,
235
+ articleWeight: null,
236
+ tareWeight: null,
237
+ supplier: null,
238
+ supplierCode: null,
239
+ supplierItemName: null,
240
+ htmlDescription: null,
241
+ },
242
+ ],
243
+ count: 10,
244
+ total: 50,
245
+ page: 1,
246
+ totalPage: 5,
247
+ perPage: 10,
248
+ metadata: [],
249
+ },
240
250
  };
241
251
  jest.spyOn(service, "provider").mockReturnValue({
242
252
  request: () => of(NetworkingUIEventWrapped.succeeded(response)),
@@ -247,17 +257,19 @@ describe("StoreProductService", () => {
247
257
  });
248
258
  it("should get product collection without payload", async () => {
249
259
  const response = {
250
- links: {
251
- first: "/api/v1/store/product-collection?per_page=24&page=1",
252
- last: "/api/v1/store/product-collection?per_page=24&page=1",
260
+ data: {
261
+ links: {
262
+ first: "/api/v1/store/product-collection?per_page=24&page=1",
263
+ last: "/api/v1/store/product-collection?per_page=24&page=1",
264
+ },
265
+ items: [],
266
+ count: 0,
267
+ total: 0,
268
+ page: 1,
269
+ totalPage: 1,
270
+ perPage: 24,
271
+ metadata: [],
253
272
  },
254
- items: [],
255
- count: 0,
256
- total: 0,
257
- page: 1,
258
- totalPage: 1,
259
- perPage: 24,
260
- metadata: [],
261
273
  };
262
274
  jest.spyOn(service, "provider").mockReturnValue({
263
275
  request: () => of(NetworkingUIEventWrapped.succeeded(response)),
@@ -275,47 +287,49 @@ describe("StoreProductService", () => {
275
287
  per_page: 10,
276
288
  };
277
289
  const response = {
278
- links: {
279
- first: "/api/v1/store/product-collection?per_page=10&page=1",
280
- last: "/api/v1/store/product-collection?per_page=10&page=1",
281
- },
282
- items: [
283
- {
284
- id: "1",
285
- name: "Product 1",
286
- barcode: "123",
287
- category: "CONGELE",
288
- vatInPercent: 5.5,
289
- unit: "piece",
290
- quantity: 1,
291
- picture: "image.png",
292
- slug: "product-1",
293
- internalCode: "001",
294
- inventory: true,
295
- quantityInStock: 10,
296
- minimumStockQuantity: 5,
297
- pricePurchase: 10,
298
- priceToSell: 15,
299
- discountInPercent: 0,
300
- priceAfterDiscount: 0,
301
- expiryDate: null,
302
- subCategory: null,
303
- volume: null,
304
- unitWeight: null,
305
- articleWeight: null,
306
- tareWeight: null,
307
- supplier: null,
308
- supplierCode: null,
309
- supplierItemName: null,
310
- htmlDescription: null,
290
+ data: {
291
+ links: {
292
+ first: "/api/v1/store/product-collection?per_page=10&page=1",
293
+ last: "/api/v1/store/product-collection?per_page=10&page=1",
311
294
  },
312
- ],
313
- count: 1,
314
- total: 1,
315
- page: 1,
316
- totalPage: 1,
317
- perPage: 10,
318
- metadata: [],
295
+ items: [
296
+ {
297
+ id: "1",
298
+ name: "Product 1",
299
+ barcode: "123",
300
+ category: "CONGELE",
301
+ vatInPercent: 5.5,
302
+ unit: "piece",
303
+ quantity: 1,
304
+ picture: "image.png",
305
+ slug: "product-1",
306
+ internalCode: "001",
307
+ inventory: true,
308
+ quantityInStock: 10,
309
+ minimumStockQuantity: 5,
310
+ pricePurchase: 10,
311
+ priceToSell: 15,
312
+ discountInPercent: 0,
313
+ priceAfterDiscount: 0,
314
+ expiryDate: null,
315
+ subCategory: null,
316
+ volume: null,
317
+ unitWeight: null,
318
+ articleWeight: null,
319
+ tareWeight: null,
320
+ supplier: null,
321
+ supplierCode: null,
322
+ supplierItemName: null,
323
+ htmlDescription: null,
324
+ },
325
+ ],
326
+ count: 1,
327
+ total: 1,
328
+ page: 1,
329
+ totalPage: 1,
330
+ perPage: 10,
331
+ metadata: [],
332
+ },
319
333
  };
320
334
  jest.spyOn(service, "provider").mockReturnValue({
321
335
  request: () => of(NetworkingUIEventWrapped.succeeded(response)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smess/networking",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Networking utilities and services for SMESS platform.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",