@smess/networking 1.0.25 → 1.0.28

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 (91) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +2 -0
  3. package/dist/services/customer.service.d.ts +157 -1
  4. package/dist/services/customer.service.js +35 -0
  5. package/dist/services/customer.service.test.js +330 -0
  6. package/dist/services/store.product.service.d.ts +1 -0
  7. package/package.json +1 -1
  8. package/dist/scripts/dev-test.d.ts +0 -1
  9. package/dist/scripts/dev-test.js +0 -803
  10. package/dist/scripts/real-test.d.ts +0 -1
  11. package/dist/scripts/real-test.js +0 -341
  12. package/dist/src/core/axios.d.ts +0 -51
  13. package/dist/src/core/axios.js +0 -65
  14. package/dist/src/core/axios.observable.d.ts +0 -11
  15. package/dist/src/core/axios.observable.js +0 -58
  16. package/dist/src/core/base.provider.advanced.test.d.ts +0 -1
  17. package/dist/src/core/base.provider.advanced.test.js +0 -29
  18. package/dist/src/core/base.provider.d.ts +0 -15
  19. package/dist/src/core/base.provider.js +0 -13
  20. package/dist/src/core/base.provider.test.d.ts +0 -1
  21. package/dist/src/core/base.provider.test.js +0 -36
  22. package/dist/src/core/base.service.wrapper.advanced.test.d.ts +0 -1
  23. package/dist/src/core/base.service.wrapper.advanced.test.js +0 -39
  24. package/dist/src/core/base.service.wrapper.d.ts +0 -7
  25. package/dist/src/core/base.service.wrapper.js +0 -11
  26. package/dist/src/core/base.service.wrapper.test.d.ts +0 -1
  27. package/dist/src/core/base.service.wrapper.test.js +0 -25
  28. package/dist/src/core/rx.http.service.d.ts +0 -51
  29. package/dist/src/core/rx.http.service.js +0 -65
  30. package/dist/src/index.d.ts +0 -19
  31. package/dist/src/index.js +0 -23
  32. package/dist/src/services/auth.service.d.ts +0 -65
  33. package/dist/src/services/auth.service.js +0 -197
  34. package/dist/src/services/auth.service.test.d.ts +0 -1
  35. package/dist/src/services/auth.service.test.js +0 -334
  36. package/dist/src/services/cache.service.d.ts +0 -31
  37. package/dist/src/services/cache.service.js +0 -77
  38. package/dist/src/services/cache.service.test.d.ts +0 -1
  39. package/dist/src/services/cache.service.test.js +0 -88
  40. package/dist/src/services/customer.service.d.ts +0 -71
  41. package/dist/src/services/customer.service.js +0 -114
  42. package/dist/src/services/customer.service.test.d.ts +0 -1
  43. package/dist/src/services/customer.service.test.js +0 -274
  44. package/dist/src/services/logger.service.d.ts +0 -31
  45. package/dist/src/services/logger.service.js +0 -93
  46. package/dist/src/services/logger.service.test.d.ts +0 -1
  47. package/dist/src/services/logger.service.test.js +0 -31
  48. package/dist/src/services/order.service.d.ts +0 -73
  49. package/dist/src/services/order.service.js +0 -97
  50. package/dist/src/services/order.service.test.d.ts +0 -1
  51. package/dist/src/services/order.service.test.js +0 -163
  52. package/dist/src/services/product.service.d.ts +0 -21
  53. package/dist/src/services/product.service.js +0 -42
  54. package/dist/src/services/product.service.test.d.ts +0 -1
  55. package/dist/src/services/product.service.test.js +0 -61
  56. package/dist/src/services/smess.service.d.ts +0 -36
  57. package/dist/src/services/smess.service.js +0 -128
  58. package/dist/src/services/smess.service.test.d.ts +0 -1
  59. package/dist/src/services/smess.service.test.js +0 -103
  60. package/dist/src/services/store.cart.service.d.ts +0 -158
  61. package/dist/src/services/store.cart.service.js +0 -177
  62. package/dist/src/services/store.cart.service.test.d.ts +0 -1
  63. package/dist/src/services/store.cart.service.test.js +0 -394
  64. package/dist/src/services/store.product.service.d.ts +0 -123
  65. package/dist/src/services/store.product.service.js +0 -102
  66. package/dist/src/services/store.product.service.test.d.ts +0 -1
  67. package/dist/src/services/store.product.service.test.js +0 -319
  68. package/dist/src/services/store.service.d.ts +0 -79
  69. package/dist/src/services/store.service.js +0 -235
  70. package/dist/src/services/store.service.test.d.ts +0 -1
  71. package/dist/src/services/store.service.test.js +0 -274
  72. package/dist/src/services/user.service.d.ts +0 -16
  73. package/dist/src/services/user.service.js +0 -37
  74. package/dist/src/services/user.service.test.d.ts +0 -1
  75. package/dist/src/services/user.service.test.js +0 -52
  76. package/dist/src/types/types.d.ts +0 -93
  77. package/dist/src/types/types.js +0 -82
  78. package/dist/src/types/types.test.d.ts +0 -1
  79. package/dist/src/types/types.test.js +0 -25
  80. package/dist/src/utils/cache-import.d.ts +0 -3
  81. package/dist/src/utils/cache-import.js +0 -2
  82. package/dist/src/utils/networking-import.d.ts +0 -4
  83. package/dist/src/utils/networking-import.js +0 -3
  84. package/dist/src/utils/rxjs-import.d.ts +0 -5
  85. package/dist/src/utils/rxjs-import.js +0 -5
  86. /package/dist/{src/services → services}/employee.service.d.ts +0 -0
  87. /package/dist/{src/services → services}/employee.service.js +0 -0
  88. /package/dist/{src/services → services}/employee.service.test.d.ts +0 -0
  89. /package/dist/{src/services → services}/employee.service.test.js +0 -0
  90. /package/dist/{src/services → services}/utils/withAuthReset.d.ts +0 -0
  91. /package/dist/{src/services → services}/utils/withAuthReset.js +0 -0
package/dist/index.d.ts CHANGED
@@ -5,9 +5,11 @@ export * from "./services/store.service";
5
5
  export * from "./services/store.cart.service";
6
6
  export * from "./services/store.product.service";
7
7
  export * from "./services/customer.service";
8
+ export * from "./services/employee.service";
8
9
  export * from "./services/order.service";
9
10
  export * from "./services/cache.service";
10
11
  export * from "./services/smess.service";
12
+ export * from "./services/utils/withAuthReset";
11
13
  export * from "./core/base.provider";
12
14
  export * from "./core/base.service.wrapper";
13
15
  export * from "./core/axios.observable";
package/dist/index.js CHANGED
@@ -5,9 +5,11 @@ export * from "./services/store.service";
5
5
  export * from "./services/store.cart.service";
6
6
  export * from "./services/store.product.service";
7
7
  export * from "./services/customer.service";
8
+ export * from "./services/employee.service";
8
9
  export * from "./services/order.service";
9
10
  export * from "./services/cache.service";
10
11
  export * from "./services/smess.service";
12
+ export * from "./services/utils/withAuthReset";
11
13
  export * from "./core/base.provider";
12
14
  export * from "./core/base.service.wrapper";
13
15
  export * from "./core/axios.observable";
@@ -1,7 +1,8 @@
1
1
  import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
2
2
  import { SmessService } from "./smess.service";
3
+ import { PaginationLinks } from "./store.product.service";
3
4
  import { BehaviorSubject, Observable } from "rxjs";
4
- export type CustomerTarget = "register" | "get-profile" | "update-profile";
5
+ export type CustomerTarget = "register" | "get-profile" | "update-profile" | "cart-collection" | "customer-product-collection" | "customer-product-create" | "customer-product-remove" | "customer-product-update-category";
5
6
  export interface CustomerRegisterRequest {
6
7
  client_id?: string;
7
8
  email: string;
@@ -21,6 +22,156 @@ export interface CustomerUpdateRequest {
21
22
  contact_email: string | null;
22
23
  phone_number: string | null;
23
24
  }
25
+ export interface CustomerCartCollectionQuery {
26
+ page?: number;
27
+ per_page?: number;
28
+ status?: string;
29
+ search?: string;
30
+ sort_by?: string;
31
+ sort_order?: "asc" | "desc";
32
+ }
33
+ export interface CustomerCartCollectionData {
34
+ links: PaginationLinks;
35
+ items: CustomerCartSummary[];
36
+ count: number;
37
+ total: number;
38
+ page: number;
39
+ totalPage: number;
40
+ perPage: number;
41
+ metadata: unknown[];
42
+ }
43
+ export type CustomerCartCollectionResponse = HttpResponse & {
44
+ data: CustomerCartCollectionData;
45
+ };
46
+ export interface CustomerCartSummary {
47
+ cartId: string;
48
+ reference: string;
49
+ dateCreated: string;
50
+ dateModified: string;
51
+ discountTotal: number;
52
+ discountTax: number;
53
+ shippingTotal: number;
54
+ shippingTax: number;
55
+ cartTax: number;
56
+ total: number;
57
+ totalTax: number;
58
+ customerId: string | null;
59
+ billingInformation: CustomerCartContactInformation | null;
60
+ shippingInformation: CustomerCartContactInformation | null;
61
+ status: string | null;
62
+ paymentMethod: string | null;
63
+ deliveryType: string | null;
64
+ transactionId: string | null;
65
+ customerIpAddress: string | null;
66
+ customerUserAgent: string | null;
67
+ customerNote: string | null;
68
+ cartHash: string | null;
69
+ cartItems: CustomerCartItem[];
70
+ paymentUrl: string | null;
71
+ store: Record<string, unknown> | null;
72
+ }
73
+ export interface CustomerCartContactInformation {
74
+ email?: string | null;
75
+ phoneNumber?: string | null;
76
+ street?: string | null;
77
+ city?: string | null;
78
+ postalCode?: string | null;
79
+ state?: string | null;
80
+ country?: string | null;
81
+ [key: string]: unknown;
82
+ }
83
+ export interface CustomerCartItem {
84
+ id: string;
85
+ productId: string;
86
+ productName: string;
87
+ quantity: number;
88
+ unit: string | null;
89
+ unitPrice: number;
90
+ subtotal: number;
91
+ total: number;
92
+ picture: string | null;
93
+ [key: string]: unknown;
94
+ }
95
+ export interface CustomerProductCollectionQuery {
96
+ page?: number;
97
+ per_page?: number;
98
+ }
99
+ export interface CustomerProductCollectionData {
100
+ links: PaginationLinks;
101
+ items: CustomerProductItem[];
102
+ count: number;
103
+ total: number;
104
+ page: number;
105
+ totalPage: number;
106
+ perPage: number;
107
+ metadata: unknown[];
108
+ }
109
+ export type CustomerProductCollectionResponse = HttpResponse & {
110
+ data: CustomerProductCollectionData;
111
+ };
112
+ export type CustomerProductCreateResponse = HttpResponse & {
113
+ data: CustomerProductItem;
114
+ };
115
+ export type CustomerProductUpdateCategoryResponse = HttpResponse & {
116
+ data: boolean;
117
+ };
118
+ export type CustomerProductRemoveResponse = HttpResponse & {
119
+ data: {
120
+ message: string;
121
+ };
122
+ };
123
+ export interface CustomerProductItem {
124
+ customerId: string;
125
+ productId: string;
126
+ category: string | null;
127
+ notes: string | null;
128
+ createdAt: string;
129
+ updatedAt: string;
130
+ product: CustomerProductProduct | null;
131
+ }
132
+ export interface CustomerProductProduct {
133
+ id: string;
134
+ barcode: string | null;
135
+ expiryDate: string | null;
136
+ name: string;
137
+ category: string | null;
138
+ subCategory: string | null;
139
+ vatInPercent: number | null;
140
+ unit: string | null;
141
+ volume: number | null;
142
+ quantity: number | null;
143
+ unitWeight: number | null;
144
+ articleWeight: number | null;
145
+ tareWeight: number | null;
146
+ supplier: string | null;
147
+ supplierCode: string | null;
148
+ supplierItemName: string | null;
149
+ picture: string | null;
150
+ slug: string | null;
151
+ internalCode: string | null;
152
+ htmlDescription: string | null;
153
+ inventory: boolean;
154
+ quantityInStock: number | null;
155
+ minimumStockQuantity: number | null;
156
+ pricePurchase: number | null;
157
+ priceToSell: number | null;
158
+ discountInPercent: number | null;
159
+ priceAfterDiscount: number | null;
160
+ priceByWeight: boolean | null;
161
+ }
162
+ export interface CustomerProductCreateRequest {
163
+ product_id: string;
164
+ notes?: string;
165
+ category?: string | null;
166
+ }
167
+ export interface CustomerProductRemoveRequest {
168
+ product_id: string;
169
+ }
170
+ export interface CustomerProductUpdateCategoryRequest {
171
+ product_id: string | null;
172
+ old_category: string;
173
+ category: string;
174
+ }
24
175
  export declare class CustomerProvider implements ProviderType {
25
176
  private readonly config;
26
177
  private readonly target;
@@ -40,4 +191,9 @@ export declare class CustomerService {
40
191
  register(payload: CustomerRegisterRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
41
192
  getProfile(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
42
193
  updateProfile(payload: CustomerUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
194
+ getCartCollection(query?: CustomerCartCollectionQuery): Observable<NetworkingUIEventWrapped<HttpResponse>>;
195
+ getCustomerProductCollection(query?: CustomerProductCollectionQuery): Observable<NetworkingUIEventWrapped<HttpResponse>>;
196
+ createCustomerProduct(payload: CustomerProductCreateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
197
+ removeCustomerProduct(payload: CustomerProductRemoveRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
198
+ updateCustomerProductCategory(payload: CustomerProductUpdateCategoryRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
43
199
  }
@@ -18,6 +18,16 @@ export class CustomerProvider {
18
18
  return "/authentication/customer/get-profile";
19
19
  case "update-profile":
20
20
  return "/authentication/customer/update";
21
+ case "cart-collection":
22
+ return "/store/cart/collection";
23
+ case "customer-product-collection":
24
+ return "/store/customer-product/collection";
25
+ case "customer-product-create":
26
+ return "/store/customer-product";
27
+ case "customer-product-remove":
28
+ return "/store/customer-product/remove";
29
+ case "customer-product-update-category":
30
+ return "/store/customer-product/category";
21
31
  default:
22
32
  return "/authentication/customer";
23
33
  }
@@ -26,6 +36,16 @@ export class CustomerProvider {
26
36
  switch (this.target) {
27
37
  case "get-profile":
28
38
  return "GET";
39
+ case "cart-collection":
40
+ return "GET";
41
+ case "customer-product-collection":
42
+ return "GET";
43
+ case "customer-product-create":
44
+ return "POST";
45
+ case "customer-product-remove":
46
+ return "DELETE";
47
+ case "customer-product-update-category":
48
+ return "PATCH";
29
49
  case "update-profile":
30
50
  return "PUT";
31
51
  default:
@@ -76,4 +96,19 @@ export class CustomerService {
76
96
  updateProfile(payload) {
77
97
  return this.provider("update-profile").request(payload);
78
98
  }
99
+ getCartCollection(query) {
100
+ return this.provider("cart-collection").request(query);
101
+ }
102
+ getCustomerProductCollection(query) {
103
+ return this.provider("customer-product-collection").request(query);
104
+ }
105
+ createCustomerProduct(payload) {
106
+ return this.provider("customer-product-create").request(payload);
107
+ }
108
+ removeCustomerProduct(payload) {
109
+ return this.provider("customer-product-remove").request(payload);
110
+ }
111
+ updateCustomerProductCategory(payload) {
112
+ return this.provider("customer-product-update-category").request(payload);
113
+ }
79
114
  }
@@ -97,4 +97,334 @@ describe("CustomerService", () => {
97
97
  expect(result?.hasFailed).toBe(true);
98
98
  expect(result?.alertModel).toBeInstanceOf(AlertModel);
99
99
  });
100
+ it("getCartCollection success", async () => {
101
+ const cartItem = {
102
+ id: "45bfb315-bc60-11f0-90ea-0242ac120004",
103
+ productId: "352235aa-a6bc-11f0-a3ef-0242ac120004",
104
+ productName: "GARAM MASALA 100G",
105
+ quantity: 2,
106
+ unit: "piece",
107
+ unitPrice: 1.55,
108
+ subtotal: 3.1,
109
+ total: 3.1,
110
+ picture: "https://s3.smeservices.cloud/grandparismarche-fr/2025-04/3276650136216.png",
111
+ };
112
+ const cartSummary = {
113
+ cartId: "45acc017-bc60-11f0-90ea-0242ac120004",
114
+ reference: "ORD-A121C9-220935",
115
+ dateCreated: "2025-11-08 05:03:32",
116
+ dateModified: "2025-11-08 16:08:55",
117
+ discountTotal: 0,
118
+ discountTax: 0,
119
+ shippingTotal: 0,
120
+ shippingTax: 0,
121
+ cartTax: 0,
122
+ total: 13.95,
123
+ totalTax: 0,
124
+ customerId: "244cac49-d014-11ef-8404-0242ac120003",
125
+ billingInformation: null,
126
+ shippingInformation: {
127
+ email: "john.doe@example.com",
128
+ phoneNumber: "+1-555-123-4567",
129
+ street: "123 Main Street",
130
+ city: "san_francisco",
131
+ postalCode: "94105",
132
+ state: "ca",
133
+ country: "us",
134
+ },
135
+ status: "confirmed",
136
+ paymentMethod: "bank_transfer",
137
+ deliveryType: "pickup",
138
+ transactionId: null,
139
+ customerIpAddress: "172.18.0.1",
140
+ customerUserAgent: "IntelliJ HTTP Client/PhpStorm 2024.3.6",
141
+ customerNote: null,
142
+ cartHash: "a121c980b381419d8341556b1f90445c05cbfa4605d6257330df605d20de2c87",
143
+ cartItems: [cartItem],
144
+ paymentUrl: null,
145
+ store: null,
146
+ };
147
+ const data = {
148
+ links: {
149
+ first: "/api/v1/store/cart/collection?per_page=24&page=1",
150
+ last: "/api/v1/store/cart/collection?per_page=24&page=1",
151
+ },
152
+ items: [cartSummary],
153
+ count: 1,
154
+ total: 1,
155
+ page: 1,
156
+ totalPage: 1,
157
+ perPage: 24,
158
+ metadata: [],
159
+ };
160
+ const response = {
161
+ data,
162
+ };
163
+ const requestMock = jest
164
+ .fn()
165
+ .mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
166
+ jest.spyOn(service, "provider").mockReturnValue({
167
+ request: requestMock,
168
+ });
169
+ const query = {
170
+ page: 1,
171
+ per_page: 24,
172
+ status: "confirmed",
173
+ };
174
+ const result = await service.getCartCollection(query).toPromise();
175
+ expect(requestMock).toHaveBeenCalledWith(query);
176
+ expect(result?.hasSuccess).toBe(true);
177
+ expect(result?.response).toEqual(response);
178
+ });
179
+ it("getCartCollection error", async () => {
180
+ const requestMock = jest
181
+ .fn()
182
+ .mockReturnValue(of(NetworkingUIEventWrapped.failed(AlertModel.default())));
183
+ jest.spyOn(service, "provider").mockReturnValue({
184
+ request: requestMock,
185
+ });
186
+ const query = {
187
+ page: 1,
188
+ per_page: 24,
189
+ };
190
+ const result = await service.getCartCollection(query).toPromise();
191
+ expect(requestMock).toHaveBeenCalledWith(query);
192
+ expect(result?.hasFailed).toBe(true);
193
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
194
+ });
195
+ it("getCustomerProductCollection success", async () => {
196
+ const product = {
197
+ id: "504e061d-a6bc-11f0-a3ef-0242ac120004",
198
+ barcode: "8935063610908",
199
+ expiryDate: null,
200
+ name: "AUBERGINE MARINE PIMENTEE NGOC LIEN 400G",
201
+ category: "CONSERVE",
202
+ subCategory: null,
203
+ vatInPercent: 5.5,
204
+ unit: "piece",
205
+ volume: null,
206
+ quantity: 1,
207
+ unitWeight: null,
208
+ articleWeight: null,
209
+ tareWeight: null,
210
+ supplier: "TCHEQUE",
211
+ supplierCode: null,
212
+ supplierItemName: null,
213
+ picture: "https://s3.smeservices.cloud/grandparismarche-fr/2025-04/8935063610908.png",
214
+ slug: "aubergine-marine-pimentee-ngoc-lien-400g-8935063610908",
215
+ internalCode: "5215",
216
+ htmlDescription: null,
217
+ inventory: true,
218
+ quantityInStock: 9,
219
+ minimumStockQuantity: 0,
220
+ pricePurchase: 3.25,
221
+ priceToSell: 3.25,
222
+ discountInPercent: 0,
223
+ priceAfterDiscount: 0,
224
+ priceByWeight: false,
225
+ };
226
+ const item = {
227
+ customerId: "c0e25a90-bc54-11f0-90ea-0242ac120004",
228
+ productId: "504e061d-a6bc-11f0-a3ef-0242ac120004",
229
+ category: "New Cate",
230
+ notes: "Customer note for this favorite product",
231
+ createdAt: "2025-11-08 03:45:51",
232
+ updatedAt: "2025-11-08 03:45:51",
233
+ product,
234
+ };
235
+ const productCollectionData = {
236
+ links: {
237
+ first: "/api/v1/store/customer-product/collection?per_page=24&page=1",
238
+ last: "/api/v1/store/customer-product/collection?per_page=24&page=1",
239
+ },
240
+ items: [item],
241
+ count: 1,
242
+ total: 1,
243
+ page: 1,
244
+ totalPage: 1,
245
+ perPage: 24,
246
+ metadata: [],
247
+ };
248
+ const response = {
249
+ data: productCollectionData,
250
+ };
251
+ const requestMock = jest
252
+ .fn()
253
+ .mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
254
+ jest.spyOn(service, "provider").mockReturnValue({
255
+ request: requestMock,
256
+ });
257
+ const query = {
258
+ page: 1,
259
+ per_page: 24,
260
+ };
261
+ const result = await service.getCustomerProductCollection(query).toPromise();
262
+ expect(requestMock).toHaveBeenCalledWith(query);
263
+ expect(result?.hasSuccess).toBe(true);
264
+ expect(result?.response).toEqual(response);
265
+ });
266
+ it("getCustomerProductCollection error", async () => {
267
+ const requestMock = jest
268
+ .fn()
269
+ .mockReturnValue(of(NetworkingUIEventWrapped.failed(AlertModel.default())));
270
+ jest.spyOn(service, "provider").mockReturnValue({
271
+ request: requestMock,
272
+ });
273
+ const query = {
274
+ page: 1,
275
+ per_page: 24,
276
+ };
277
+ const result = await service.getCustomerProductCollection(query).toPromise();
278
+ expect(requestMock).toHaveBeenCalledWith(query);
279
+ expect(result?.hasFailed).toBe(true);
280
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
281
+ });
282
+ it("createCustomerProduct success", async () => {
283
+ const product = {
284
+ id: "504e061d-a6bc-11f0-a3ef-0242ac120004",
285
+ barcode: "8935063610908",
286
+ expiryDate: null,
287
+ name: "AUBERGINE MARINE PIMENTEE NGOC LIEN 400G",
288
+ category: "CONSERVE",
289
+ subCategory: null,
290
+ vatInPercent: 5.5,
291
+ unit: "piece",
292
+ volume: null,
293
+ quantity: 1,
294
+ unitWeight: null,
295
+ articleWeight: null,
296
+ tareWeight: null,
297
+ supplier: "TCHEQUE",
298
+ supplierCode: null,
299
+ supplierItemName: null,
300
+ picture: "https://s3.smeservices.cloud/grandparismarche-fr/2025-04/8935063610908.png",
301
+ slug: "aubergine-marine-pimentee-ngoc-lien-400g-8935063610908",
302
+ internalCode: "5215",
303
+ htmlDescription: null,
304
+ inventory: true,
305
+ quantityInStock: 9,
306
+ minimumStockQuantity: 0,
307
+ pricePurchase: 3.25,
308
+ priceToSell: 3.25,
309
+ discountInPercent: 0,
310
+ priceAfterDiscount: 0,
311
+ priceByWeight: false,
312
+ };
313
+ const response = {
314
+ data: {
315
+ customerId: "c0e25a90-bc54-11f0-90ea-0242ac120004",
316
+ productId: "504e061d-a6bc-11f0-a3ef-0242ac120004",
317
+ category: "New Cate",
318
+ notes: "Customer note for this favorite product",
319
+ createdAt: "2025-11-08 03:45:51",
320
+ updatedAt: "2025-11-09 16:34:39",
321
+ product,
322
+ },
323
+ };
324
+ const requestMock = jest
325
+ .fn()
326
+ .mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
327
+ jest.spyOn(service, "provider").mockReturnValue({
328
+ request: requestMock,
329
+ });
330
+ const payload = {
331
+ product_id: "product-123",
332
+ notes: "Customer note for this favorite product",
333
+ category: "New Cate",
334
+ };
335
+ const result = await service.createCustomerProduct(payload).toPromise();
336
+ expect(requestMock).toHaveBeenCalledWith(payload);
337
+ expect(result?.hasSuccess).toBe(true);
338
+ expect(result?.response).toEqual(response);
339
+ });
340
+ it("createCustomerProduct error", async () => {
341
+ const requestMock = jest
342
+ .fn()
343
+ .mockReturnValue(of(NetworkingUIEventWrapped.failed(AlertModel.default())));
344
+ jest.spyOn(service, "provider").mockReturnValue({
345
+ request: requestMock,
346
+ });
347
+ const payload = {
348
+ product_id: "product-123",
349
+ notes: "Customer note for this favorite product",
350
+ };
351
+ const result = await service.createCustomerProduct(payload).toPromise();
352
+ expect(requestMock).toHaveBeenCalledWith(payload);
353
+ expect(result?.hasFailed).toBe(true);
354
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
355
+ });
356
+ it("removeCustomerProduct success", async () => {
357
+ const response = {
358
+ data: {
359
+ message: "Favorite removed successfully",
360
+ },
361
+ };
362
+ const requestMock = jest
363
+ .fn()
364
+ .mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
365
+ jest.spyOn(service, "provider").mockReturnValue({
366
+ request: requestMock,
367
+ });
368
+ const payload = {
369
+ product_id: "product-123",
370
+ };
371
+ const result = await service.removeCustomerProduct(payload).toPromise();
372
+ expect(requestMock).toHaveBeenCalledWith(payload);
373
+ expect(result?.hasSuccess).toBe(true);
374
+ expect(result?.response).toEqual(response);
375
+ });
376
+ it("removeCustomerProduct error", async () => {
377
+ const requestMock = jest
378
+ .fn()
379
+ .mockReturnValue(of(NetworkingUIEventWrapped.failed(AlertModel.default())));
380
+ jest.spyOn(service, "provider").mockReturnValue({
381
+ request: requestMock,
382
+ });
383
+ const payload = {
384
+ product_id: "product-123",
385
+ };
386
+ const result = await service.removeCustomerProduct(payload).toPromise();
387
+ expect(requestMock).toHaveBeenCalledWith(payload);
388
+ expect(result?.hasFailed).toBe(true);
389
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
390
+ });
391
+ it("updateCustomerProductCategory success", async () => {
392
+ const response = { data: true };
393
+ const requestMock = jest
394
+ .fn()
395
+ .mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
396
+ jest.spyOn(service, "provider").mockReturnValue({
397
+ request: requestMock,
398
+ });
399
+ const payload = {
400
+ product_id: "product-123",
401
+ old_category: "Standard",
402
+ category: "Preferred",
403
+ };
404
+ const result = await service
405
+ .updateCustomerProductCategory(payload)
406
+ .toPromise();
407
+ expect(requestMock).toHaveBeenCalledWith(payload);
408
+ expect(result?.hasSuccess).toBe(true);
409
+ expect(result?.response).toEqual(response);
410
+ });
411
+ it("updateCustomerProductCategory error", async () => {
412
+ const requestMock = jest
413
+ .fn()
414
+ .mockReturnValue(of(NetworkingUIEventWrapped.failed(AlertModel.default())));
415
+ jest.spyOn(service, "provider").mockReturnValue({
416
+ request: requestMock,
417
+ });
418
+ const payload = {
419
+ product_id: "product-123",
420
+ old_category: "Standard",
421
+ category: "Preferred",
422
+ };
423
+ const result = await service
424
+ .updateCustomerProductCategory(payload)
425
+ .toPromise();
426
+ expect(requestMock).toHaveBeenCalledWith(payload);
427
+ expect(result?.hasFailed).toBe(true);
428
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
429
+ });
100
430
  });
@@ -51,6 +51,7 @@ export interface StoreProduct {
51
51
  priceToSell: number;
52
52
  discountInPercent: number;
53
53
  priceAfterDiscount: number;
54
+ priceByWeight: boolean;
54
55
  [key: string]: unknown;
55
56
  }
56
57
  export interface StoreProductCollectionResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smess/networking",
3
- "version": "1.0.25",
3
+ "version": "1.0.28",
4
4
  "description": "Networking utilities and services for SMESS platform.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- import "fake-indexeddb/auto";