@smess/networking 1.2.0 → 2.0.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.
- package/CHANGELOG.md +211 -0
- package/README.md +165 -114
- package/dist/core/body.d.ts +10 -0
- package/dist/core/body.d.ts.map +1 -0
- package/dist/core/body.js +22 -0
- package/dist/core/body.js.map +1 -0
- package/dist/core/client.d.ts +74 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +124 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/decoders.d.ts +8 -0
- package/dist/core/decoders.d.ts.map +1 -0
- package/dist/core/decoders.js +26 -0
- package/dist/core/decoders.js.map +1 -0
- package/dist/core/endpoint.d.ts +69 -0
- package/dist/core/endpoint.d.ts.map +1 -0
- package/dist/core/endpoint.js +6 -0
- package/dist/core/endpoint.js.map +1 -0
- package/dist/core/hosts.d.ts +25 -0
- package/dist/core/hosts.d.ts.map +1 -0
- package/dist/core/hosts.js +22 -0
- package/dist/core/hosts.js.map +1 -0
- package/dist/core/pagination.d.ts +33 -0
- package/dist/core/pagination.d.ts.map +1 -0
- package/dist/core/pagination.js +23 -0
- package/dist/core/pagination.js.map +1 -0
- package/dist/core/pipeline.d.ts +25 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +12 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/retry.d.ts +18 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +47 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/transport.d.ts +30 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/transport.js +73 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/core/types.d.ts +24 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/url.d.ts +15 -0
- package/dist/core/url.d.ts.map +1 -0
- package/dist/core/url.js +46 -0
- package/dist/core/url.js.map +1 -0
- package/dist/errors/parse-error-body.d.ts +20 -0
- package/dist/errors/parse-error-body.d.ts.map +1 -0
- package/dist/errors/parse-error-body.js +73 -0
- package/dist/errors/parse-error-body.js.map +1 -0
- package/dist/errors/smess-api-error.d.ts +70 -0
- package/dist/errors/smess-api-error.d.ts.map +1 -0
- package/dist/errors/smess-api-error.js +84 -0
- package/dist/errors/smess-api-error.js.map +1 -0
- package/dist/index.d.ts +27 -25
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -29
- package/dist/index.js.map +1 -0
- package/dist/modules/authentication/index.d.ts +89 -0
- package/dist/modules/authentication/index.d.ts.map +1 -0
- package/dist/modules/authentication/index.js +128 -0
- package/dist/modules/authentication/index.js.map +1 -0
- package/dist/modules/campaign/index.d.ts +212 -0
- package/dist/modules/campaign/index.d.ts.map +1 -0
- package/dist/modules/campaign/index.js +193 -0
- package/dist/modules/campaign/index.js.map +1 -0
- package/dist/modules/campaign/types.d.ts +562 -0
- package/dist/modules/campaign/types.d.ts.map +1 -0
- package/dist/modules/campaign/types.js +2 -0
- package/dist/modules/campaign/types.js.map +1 -0
- package/dist/modules/danara/index.d.ts +153 -0
- package/dist/modules/danara/index.d.ts.map +1 -0
- package/dist/modules/danara/index.js +144 -0
- package/dist/modules/danara/index.js.map +1 -0
- package/dist/modules/danara/types.d.ts +479 -0
- package/dist/modules/danara/types.d.ts.map +1 -0
- package/dist/modules/danara/types.js +2 -0
- package/dist/modules/danara/types.js.map +1 -0
- package/dist/modules/smeup-file/index.d.ts +27 -0
- package/dist/modules/smeup-file/index.d.ts.map +1 -0
- package/dist/modules/smeup-file/index.js +17 -0
- package/dist/modules/smeup-file/index.js.map +1 -0
- package/dist/modules/sso/index.d.ts +40 -0
- package/dist/modules/sso/index.d.ts.map +1 -0
- package/dist/modules/sso/index.js +41 -0
- package/dist/modules/sso/index.js.map +1 -0
- package/dist/rx/index.d.ts +11 -0
- package/dist/rx/index.d.ts.map +1 -0
- package/dist/rx/index.js +20 -0
- package/dist/rx/index.js.map +1 -0
- package/dist/session/auth-middleware.d.ts +27 -0
- package/dist/session/auth-middleware.d.ts.map +1 -0
- package/dist/session/auth-middleware.js +122 -0
- package/dist/session/auth-middleware.js.map +1 -0
- package/dist/session/jwt.d.ts +20 -0
- package/dist/session/jwt.d.ts.map +1 -0
- package/dist/session/jwt.js +25 -0
- package/dist/session/jwt.js.map +1 -0
- package/dist/session/stores.d.ts +19 -0
- package/dist/session/stores.d.ts.map +1 -0
- package/dist/session/stores.js +103 -0
- package/dist/session/stores.js.map +1 -0
- package/dist/session/types.d.ts +28 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/package.json +80 -30
- package/dist/core/axios.d.ts +0 -51
- package/dist/core/axios.js +0 -65
- package/dist/core/axios.observable.d.ts +0 -11
- package/dist/core/axios.observable.js +0 -58
- package/dist/core/base.provider.advanced.test.d.ts +0 -1
- package/dist/core/base.provider.advanced.test.js +0 -29
- package/dist/core/base.provider.d.ts +0 -15
- package/dist/core/base.provider.js +0 -13
- package/dist/core/base.provider.test.d.ts +0 -1
- package/dist/core/base.provider.test.js +0 -36
- package/dist/core/base.service.wrapper.advanced.test.d.ts +0 -1
- package/dist/core/base.service.wrapper.advanced.test.js +0 -39
- package/dist/core/base.service.wrapper.d.ts +0 -7
- package/dist/core/base.service.wrapper.js +0 -11
- package/dist/core/base.service.wrapper.test.d.ts +0 -1
- package/dist/core/base.service.wrapper.test.js +0 -25
- package/dist/core/rx.http.service.d.ts +0 -51
- package/dist/core/rx.http.service.js +0 -65
- package/dist/services/auth.service.d.ts +0 -65
- package/dist/services/auth.service.js +0 -197
- package/dist/services/auth.service.test.d.ts +0 -1
- package/dist/services/auth.service.test.js +0 -334
- package/dist/services/cache.service.d.ts +0 -31
- package/dist/services/cache.service.js +0 -77
- package/dist/services/cache.service.test.d.ts +0 -1
- package/dist/services/cache.service.test.js +0 -88
- package/dist/services/customer.service.d.ts +0 -211
- package/dist/services/customer.service.js +0 -128
- package/dist/services/customer.service.test.d.ts +0 -1
- package/dist/services/customer.service.test.js +0 -430
- package/dist/services/employee.service.d.ts +0 -73
- package/dist/services/employee.service.js +0 -74
- package/dist/services/employee.service.test.d.ts +0 -1
- package/dist/services/employee.service.test.js +0 -127
- package/dist/services/logger.service.d.ts +0 -31
- package/dist/services/logger.service.js +0 -93
- package/dist/services/logger.service.test.d.ts +0 -1
- package/dist/services/logger.service.test.js +0 -31
- package/dist/services/order.service.d.ts +0 -73
- package/dist/services/order.service.js +0 -97
- package/dist/services/order.service.test.d.ts +0 -1
- package/dist/services/order.service.test.js +0 -163
- package/dist/services/product.service.d.ts +0 -21
- package/dist/services/product.service.js +0 -42
- package/dist/services/product.service.test.d.ts +0 -1
- package/dist/services/product.service.test.js +0 -61
- package/dist/services/smess.service.d.ts +0 -36
- package/dist/services/smess.service.js +0 -128
- package/dist/services/smess.service.test.d.ts +0 -1
- package/dist/services/smess.service.test.js +0 -103
- package/dist/services/store.cart.service.d.ts +0 -158
- package/dist/services/store.cart.service.js +0 -177
- package/dist/services/store.cart.service.test.d.ts +0 -1
- package/dist/services/store.cart.service.test.js +0 -394
- package/dist/services/store.product.service.d.ts +0 -124
- package/dist/services/store.product.service.js +0 -102
- package/dist/services/store.product.service.test.d.ts +0 -1
- package/dist/services/store.product.service.test.js +0 -319
- package/dist/services/store.service.d.ts +0 -79
- package/dist/services/store.service.js +0 -235
- package/dist/services/store.service.test.d.ts +0 -1
- package/dist/services/store.service.test.js +0 -274
- package/dist/services/storefront.cart.service.d.ts +0 -73
- package/dist/services/storefront.cart.service.js +0 -167
- package/dist/services/storefront.cart.service.test.d.ts +0 -1
- package/dist/services/storefront.cart.service.test.js +0 -211
- package/dist/services/storefront.checkout.service.d.ts +0 -62
- package/dist/services/storefront.checkout.service.js +0 -75
- package/dist/services/storefront.checkout.service.test.d.ts +0 -1
- package/dist/services/storefront.checkout.service.test.js +0 -158
- package/dist/services/storefront.customer.metadata.service.d.ts +0 -91
- package/dist/services/storefront.customer.metadata.service.js +0 -225
- package/dist/services/storefront.customer.metadata.service.test.d.ts +0 -1
- package/dist/services/storefront.customer.metadata.service.test.js +0 -271
- package/dist/services/storefront.order.service.d.ts +0 -45
- package/dist/services/storefront.order.service.js +0 -99
- package/dist/services/storefront.order.service.test.d.ts +0 -1
- package/dist/services/storefront.order.service.test.js +0 -158
- package/dist/services/storefront.product.service.d.ts +0 -52
- package/dist/services/storefront.product.service.js +0 -75
- package/dist/services/storefront.product.service.test.d.ts +0 -1
- package/dist/services/storefront.product.service.test.js +0 -120
- package/dist/services/storefront.store.service.d.ts +0 -54
- package/dist/services/storefront.store.service.js +0 -142
- package/dist/services/storefront.store.service.test.d.ts +0 -1
- package/dist/services/storefront.store.service.test.js +0 -90
- package/dist/services/user.service.d.ts +0 -16
- package/dist/services/user.service.js +0 -37
- package/dist/services/user.service.test.d.ts +0 -1
- package/dist/services/user.service.test.js +0 -52
- package/dist/services/utils/withAuthReset.d.ts +0 -3
- package/dist/services/utils/withAuthReset.js +0 -8
- package/dist/src/core/axios.d.ts +0 -51
- package/dist/src/core/axios.js +0 -65
- package/dist/src/core/axios.observable.d.ts +0 -11
- package/dist/src/core/axios.observable.js +0 -58
- package/dist/src/core/base.provider.advanced.test.d.ts +0 -1
- package/dist/src/core/base.provider.advanced.test.js +0 -29
- package/dist/src/core/base.provider.d.ts +0 -15
- package/dist/src/core/base.provider.js +0 -13
- package/dist/src/core/base.provider.test.d.ts +0 -1
- package/dist/src/core/base.provider.test.js +0 -36
- package/dist/src/core/base.service.wrapper.advanced.test.d.ts +0 -1
- package/dist/src/core/base.service.wrapper.advanced.test.js +0 -39
- package/dist/src/core/base.service.wrapper.d.ts +0 -7
- package/dist/src/core/base.service.wrapper.js +0 -11
- package/dist/src/core/base.service.wrapper.test.d.ts +0 -1
- package/dist/src/core/base.service.wrapper.test.js +0 -25
- package/dist/src/core/rx.http.service.d.ts +0 -51
- package/dist/src/core/rx.http.service.js +0 -65
- package/dist/src/index.d.ts +0 -25
- package/dist/src/index.js +0 -29
- package/dist/src/services/auth.service.d.ts +0 -65
- package/dist/src/services/auth.service.js +0 -197
- package/dist/src/services/auth.service.test.d.ts +0 -1
- package/dist/src/services/auth.service.test.js +0 -334
- package/dist/src/services/cache.service.d.ts +0 -31
- package/dist/src/services/cache.service.js +0 -77
- package/dist/src/services/cache.service.test.d.ts +0 -1
- package/dist/src/services/cache.service.test.js +0 -88
- package/dist/src/services/customer.service.d.ts +0 -199
- package/dist/src/services/customer.service.js +0 -114
- package/dist/src/services/customer.service.test.d.ts +0 -1
- package/dist/src/services/customer.service.test.js +0 -430
- package/dist/src/services/employee.service.d.ts +0 -73
- package/dist/src/services/employee.service.js +0 -74
- package/dist/src/services/employee.service.test.d.ts +0 -1
- package/dist/src/services/employee.service.test.js +0 -127
- package/dist/src/services/logger.service.d.ts +0 -31
- package/dist/src/services/logger.service.js +0 -93
- package/dist/src/services/logger.service.test.d.ts +0 -1
- package/dist/src/services/logger.service.test.js +0 -31
- package/dist/src/services/order.service.d.ts +0 -73
- package/dist/src/services/order.service.js +0 -97
- package/dist/src/services/order.service.test.d.ts +0 -1
- package/dist/src/services/order.service.test.js +0 -163
- package/dist/src/services/product.service.d.ts +0 -21
- package/dist/src/services/product.service.js +0 -42
- package/dist/src/services/product.service.test.d.ts +0 -1
- package/dist/src/services/product.service.test.js +0 -61
- package/dist/src/services/smess.service.d.ts +0 -36
- package/dist/src/services/smess.service.js +0 -128
- package/dist/src/services/smess.service.test.d.ts +0 -1
- package/dist/src/services/smess.service.test.js +0 -103
- package/dist/src/services/store.cart.service.d.ts +0 -158
- package/dist/src/services/store.cart.service.js +0 -177
- package/dist/src/services/store.cart.service.test.d.ts +0 -1
- package/dist/src/services/store.cart.service.test.js +0 -394
- package/dist/src/services/store.product.service.d.ts +0 -124
- package/dist/src/services/store.product.service.js +0 -102
- package/dist/src/services/store.product.service.test.d.ts +0 -1
- package/dist/src/services/store.product.service.test.js +0 -319
- package/dist/src/services/store.service.d.ts +0 -79
- package/dist/src/services/store.service.js +0 -235
- package/dist/src/services/store.service.test.d.ts +0 -1
- package/dist/src/services/store.service.test.js +0 -274
- package/dist/src/services/storefront.cart.service.d.ts +0 -73
- package/dist/src/services/storefront.cart.service.js +0 -167
- package/dist/src/services/storefront.cart.service.test.d.ts +0 -1
- package/dist/src/services/storefront.cart.service.test.js +0 -211
- package/dist/src/services/storefront.checkout.service.d.ts +0 -62
- package/dist/src/services/storefront.checkout.service.js +0 -75
- package/dist/src/services/storefront.checkout.service.test.d.ts +0 -1
- package/dist/src/services/storefront.checkout.service.test.js +0 -158
- package/dist/src/services/storefront.customer.metadata.service.d.ts +0 -91
- package/dist/src/services/storefront.customer.metadata.service.js +0 -225
- package/dist/src/services/storefront.customer.metadata.service.test.d.ts +0 -1
- package/dist/src/services/storefront.customer.metadata.service.test.js +0 -271
- package/dist/src/services/storefront.order.service.d.ts +0 -45
- package/dist/src/services/storefront.order.service.js +0 -99
- package/dist/src/services/storefront.order.service.test.d.ts +0 -1
- package/dist/src/services/storefront.order.service.test.js +0 -158
- package/dist/src/services/storefront.product.service.d.ts +0 -52
- package/dist/src/services/storefront.product.service.js +0 -75
- package/dist/src/services/storefront.product.service.test.d.ts +0 -1
- package/dist/src/services/storefront.product.service.test.js +0 -120
- package/dist/src/services/storefront.store.service.d.ts +0 -52
- package/dist/src/services/storefront.store.service.js +0 -140
- package/dist/src/services/storefront.store.service.test.d.ts +0 -1
- package/dist/src/services/storefront.store.service.test.js +0 -90
- package/dist/src/services/user.service.d.ts +0 -16
- package/dist/src/services/user.service.js +0 -37
- package/dist/src/services/user.service.test.d.ts +0 -1
- package/dist/src/services/user.service.test.js +0 -52
- package/dist/src/services/utils/withAuthReset.d.ts +0 -3
- package/dist/src/services/utils/withAuthReset.js +0 -8
- package/dist/src/types/types.d.ts +0 -93
- package/dist/src/types/types.js +0 -82
- package/dist/src/types/types.test.d.ts +0 -1
- package/dist/src/types/types.test.js +0 -25
- package/dist/src/utils/cache-import.d.ts +0 -3
- package/dist/src/utils/cache-import.js +0 -2
- package/dist/src/utils/networking-import.d.ts +0 -4
- package/dist/src/utils/networking-import.js +0 -3
- package/dist/src/utils/rxjs-import.d.ts +0 -5
- package/dist/src/utils/rxjs-import.js +0 -5
- package/dist/types/types.d.ts +0 -96
- package/dist/types/types.js +0 -82
- package/dist/types/types.test.d.ts +0 -1
- package/dist/types/types.test.js +0 -25
- package/dist/utils/cache-import.d.ts +0 -3
- package/dist/utils/cache-import.js +0 -2
- package/dist/utils/networking-import.d.ts +0 -4
- package/dist/utils/networking-import.js +0 -3
- package/dist/utils/rxjs-import.d.ts +0 -5
- package/dist/utils/rxjs-import.js +0 -5
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Accept, SMESSHeader, SmessService } from "./smess.service";
|
|
2
|
-
export class StoreProductProvider {
|
|
3
|
-
constructor(config, target) {
|
|
4
|
-
this.config = config;
|
|
5
|
-
this.target = target;
|
|
6
|
-
}
|
|
7
|
-
get baseURL() {
|
|
8
|
-
return this.config.version
|
|
9
|
-
? `${this.config.baseUrl}/${this.config.version}`
|
|
10
|
-
: this.config.baseUrl;
|
|
11
|
-
}
|
|
12
|
-
get path() {
|
|
13
|
-
switch (this.target) {
|
|
14
|
-
case "featured-product-list":
|
|
15
|
-
return "/store/featured-product-list";
|
|
16
|
-
case "featured-product-list-by-store":
|
|
17
|
-
return "/store/${id}/featured-product-list";
|
|
18
|
-
case "product-category-list":
|
|
19
|
-
return "/store/product-category/list";
|
|
20
|
-
case "product-get-by-id":
|
|
21
|
-
return "/store/product/${id}";
|
|
22
|
-
case "product-collection":
|
|
23
|
-
return "/store/product-collection";
|
|
24
|
-
case "product-collection-by-store":
|
|
25
|
-
return "/store/${id}/product-collection";
|
|
26
|
-
default:
|
|
27
|
-
return "/store";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
get method() {
|
|
31
|
-
return "GET";
|
|
32
|
-
}
|
|
33
|
-
get headers() {
|
|
34
|
-
let headers = SmessService.getHeaders(Accept.V1, null);
|
|
35
|
-
if (this.config.clientId) {
|
|
36
|
-
headers[SMESSHeader.ClientId] = this.config.clientId;
|
|
37
|
-
}
|
|
38
|
-
if (this.config.apiKey) {
|
|
39
|
-
headers[SMESSHeader.ApiKey] = this.config.apiKey;
|
|
40
|
-
}
|
|
41
|
-
return SmessService.filterHeaders(headers);
|
|
42
|
-
}
|
|
43
|
-
getPath(...queryParams) {
|
|
44
|
-
let definedPath = this.path;
|
|
45
|
-
const params = definedPath.match(/\$\{(.+?)\}/g);
|
|
46
|
-
params?.forEach((value, index) => {
|
|
47
|
-
definedPath = definedPath.replace(value, String(queryParams[index]));
|
|
48
|
-
});
|
|
49
|
-
return definedPath;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export class StoreProductService {
|
|
53
|
-
constructor(config) {
|
|
54
|
-
this.config = config;
|
|
55
|
-
}
|
|
56
|
-
provider(target) {
|
|
57
|
-
const targetWrapper = new StoreProductProvider(this.config, target);
|
|
58
|
-
return new SmessService(targetWrapper);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get featured product list
|
|
62
|
-
* GET /api/v1/store/featured-product-list
|
|
63
|
-
*/
|
|
64
|
-
getFeaturedProductList() {
|
|
65
|
-
return this.provider("featured-product-list").request();
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get featured product list by store
|
|
69
|
-
* GET /api/v1/store/{id}/featured-product-list
|
|
70
|
-
*/
|
|
71
|
-
getFeaturedProductListByStore(storeId) {
|
|
72
|
-
return this.provider("featured-product-list-by-store").request(undefined, undefined, storeId);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get product category list
|
|
76
|
-
* GET /api/v1/store/product-category/list
|
|
77
|
-
*/
|
|
78
|
-
getProductCategoryList() {
|
|
79
|
-
return this.provider("product-category-list").request();
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Get product by ID
|
|
83
|
-
* GET /api/v1/store/product/{id}
|
|
84
|
-
*/
|
|
85
|
-
getProductById(productId) {
|
|
86
|
-
return this.provider("product-get-by-id").request(undefined, undefined, productId);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get product collection
|
|
90
|
-
* GET /api/v1/store/product-collection
|
|
91
|
-
*/
|
|
92
|
-
getProductCollection(payload) {
|
|
93
|
-
return this.provider("product-collection").request(payload, undefined, undefined);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get product collection by store
|
|
97
|
-
* GET /api/v1/store/{id}/product-collection
|
|
98
|
-
*/
|
|
99
|
-
getProductCollectionByStore(storeId, payload) {
|
|
100
|
-
return this.provider("product-collection-by-store").request(payload, undefined, storeId);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { StoreProductService, } from "./store.product.service";
|
|
2
|
-
import { NetworkingUIEventWrapped, AlertModel, } from "../types/types";
|
|
3
|
-
import { of } from "rxjs";
|
|
4
|
-
describe("StoreProductService", () => {
|
|
5
|
-
const config = {
|
|
6
|
-
baseUrl: "https://api.example.com",
|
|
7
|
-
isProd: false,
|
|
8
|
-
clientId: "test-client-id",
|
|
9
|
-
apiKey: "test-api-key",
|
|
10
|
-
};
|
|
11
|
-
let service;
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
service = new StoreProductService(config);
|
|
14
|
-
});
|
|
15
|
-
describe("getFeaturedProductList", () => {
|
|
16
|
-
it("should get featured product list successfully", async () => {
|
|
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
|
-
};
|
|
50
|
-
jest.spyOn(service, "provider").mockReturnValue({
|
|
51
|
-
request: () => of(NetworkingUIEventWrapped.succeeded(response)),
|
|
52
|
-
});
|
|
53
|
-
const result = await service.getFeaturedProductList().toPromise();
|
|
54
|
-
expect(result?.hasSuccess).toBe(true);
|
|
55
|
-
expect(result?.response).toEqual(response);
|
|
56
|
-
});
|
|
57
|
-
it("should handle error", async () => {
|
|
58
|
-
jest.spyOn(service, "provider").mockReturnValue({
|
|
59
|
-
request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
|
|
60
|
-
});
|
|
61
|
-
const result = await service.getFeaturedProductList().toPromise();
|
|
62
|
-
expect(result?.hasFailed).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe("getFeaturedProductListByStore", () => {
|
|
66
|
-
it("should get featured product list by store successfully", async () => {
|
|
67
|
-
const storeId = "store-123";
|
|
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,
|
|
139
|
-
name: "Product 1",
|
|
140
|
-
barcode: "123",
|
|
141
|
-
category: "CONGELE",
|
|
142
|
-
vatInPercent: 5.5,
|
|
143
|
-
unit: "piece",
|
|
144
|
-
quantity: 1,
|
|
145
|
-
picture: "image.png",
|
|
146
|
-
slug: "product-1",
|
|
147
|
-
internalCode: "001",
|
|
148
|
-
inventory: true,
|
|
149
|
-
quantityInStock: 10,
|
|
150
|
-
minimumStockQuantity: 5,
|
|
151
|
-
pricePurchase: 10,
|
|
152
|
-
priceToSell: 15,
|
|
153
|
-
discountInPercent: 0,
|
|
154
|
-
priceAfterDiscount: 0,
|
|
155
|
-
expiryDate: null,
|
|
156
|
-
subCategory: null,
|
|
157
|
-
volume: null,
|
|
158
|
-
unitWeight: null,
|
|
159
|
-
articleWeight: null,
|
|
160
|
-
tareWeight: null,
|
|
161
|
-
supplier: null,
|
|
162
|
-
supplierCode: null,
|
|
163
|
-
supplierItemName: null,
|
|
164
|
-
htmlDescription: null,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
jest.spyOn(service, "provider").mockReturnValue({
|
|
168
|
-
request: () => of(NetworkingUIEventWrapped.succeeded(response)),
|
|
169
|
-
});
|
|
170
|
-
const result = await service.getProductById(productId).toPromise();
|
|
171
|
-
expect(result?.hasSuccess).toBe(true);
|
|
172
|
-
expect(result?.response).toEqual(response);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
describe("getProductCollection", () => {
|
|
176
|
-
it("should get product collection successfully", async () => {
|
|
177
|
-
const payload = {
|
|
178
|
-
page: 1,
|
|
179
|
-
per_page: 10,
|
|
180
|
-
search: "test",
|
|
181
|
-
};
|
|
182
|
-
const response = {
|
|
183
|
-
data: {
|
|
184
|
-
links: {
|
|
185
|
-
first: "/api/v1/store/product-collection?per_page=10&page=1",
|
|
186
|
-
last: "/api/v1/store/product-collection?per_page=10&page=5",
|
|
187
|
-
next: "/api/v1/store/product-collection?per_page=10&page=2",
|
|
188
|
-
},
|
|
189
|
-
items: [
|
|
190
|
-
{
|
|
191
|
-
id: "1",
|
|
192
|
-
name: "Product 1",
|
|
193
|
-
barcode: "123",
|
|
194
|
-
category: "CONGELE",
|
|
195
|
-
vatInPercent: 5.5,
|
|
196
|
-
unit: "piece",
|
|
197
|
-
quantity: 1,
|
|
198
|
-
picture: "image.png",
|
|
199
|
-
slug: "product-1",
|
|
200
|
-
internalCode: "001",
|
|
201
|
-
inventory: true,
|
|
202
|
-
quantityInStock: 10,
|
|
203
|
-
minimumStockQuantity: 5,
|
|
204
|
-
pricePurchase: 10,
|
|
205
|
-
priceToSell: 15,
|
|
206
|
-
discountInPercent: 0,
|
|
207
|
-
priceAfterDiscount: 0,
|
|
208
|
-
expiryDate: null,
|
|
209
|
-
subCategory: null,
|
|
210
|
-
volume: null,
|
|
211
|
-
unitWeight: null,
|
|
212
|
-
articleWeight: null,
|
|
213
|
-
tareWeight: null,
|
|
214
|
-
supplier: null,
|
|
215
|
-
supplierCode: null,
|
|
216
|
-
supplierItemName: null,
|
|
217
|
-
htmlDescription: null,
|
|
218
|
-
},
|
|
219
|
-
],
|
|
220
|
-
count: 10,
|
|
221
|
-
total: 50,
|
|
222
|
-
page: 1,
|
|
223
|
-
totalPage: 5,
|
|
224
|
-
perPage: 10,
|
|
225
|
-
metadata: [],
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
jest.spyOn(service, "provider").mockReturnValue({
|
|
229
|
-
request: () => of(NetworkingUIEventWrapped.succeeded(response)),
|
|
230
|
-
});
|
|
231
|
-
const result = await service.getProductCollection(payload).toPromise();
|
|
232
|
-
expect(result?.hasSuccess).toBe(true);
|
|
233
|
-
expect(result?.response).toEqual(response);
|
|
234
|
-
});
|
|
235
|
-
it("should get product collection without payload", async () => {
|
|
236
|
-
const response = {
|
|
237
|
-
data: {
|
|
238
|
-
links: {
|
|
239
|
-
first: "/api/v1/store/product-collection?per_page=24&page=1",
|
|
240
|
-
last: "/api/v1/store/product-collection?per_page=24&page=1",
|
|
241
|
-
},
|
|
242
|
-
items: [],
|
|
243
|
-
count: 0,
|
|
244
|
-
total: 0,
|
|
245
|
-
page: 1,
|
|
246
|
-
totalPage: 1,
|
|
247
|
-
perPage: 24,
|
|
248
|
-
metadata: [],
|
|
249
|
-
},
|
|
250
|
-
};
|
|
251
|
-
jest.spyOn(service, "provider").mockReturnValue({
|
|
252
|
-
request: () => of(NetworkingUIEventWrapped.succeeded(response)),
|
|
253
|
-
});
|
|
254
|
-
const result = await service.getProductCollection().toPromise();
|
|
255
|
-
expect(result?.hasSuccess).toBe(true);
|
|
256
|
-
expect(result?.response).toEqual(response);
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
describe("getProductCollectionByStore", () => {
|
|
260
|
-
it("should get product collection by store successfully", async () => {
|
|
261
|
-
const storeId = "store-123";
|
|
262
|
-
const payload = {
|
|
263
|
-
page: 1,
|
|
264
|
-
per_page: 10,
|
|
265
|
-
};
|
|
266
|
-
const response = {
|
|
267
|
-
data: {
|
|
268
|
-
links: {
|
|
269
|
-
first: "/api/v1/store/product-collection?per_page=10&page=1",
|
|
270
|
-
last: "/api/v1/store/product-collection?per_page=10&page=1",
|
|
271
|
-
},
|
|
272
|
-
items: [
|
|
273
|
-
{
|
|
274
|
-
id: "1",
|
|
275
|
-
name: "Product 1",
|
|
276
|
-
barcode: "123",
|
|
277
|
-
category: "CONGELE",
|
|
278
|
-
vatInPercent: 5.5,
|
|
279
|
-
unit: "piece",
|
|
280
|
-
quantity: 1,
|
|
281
|
-
picture: "image.png",
|
|
282
|
-
slug: "product-1",
|
|
283
|
-
internalCode: "001",
|
|
284
|
-
inventory: true,
|
|
285
|
-
quantityInStock: 10,
|
|
286
|
-
minimumStockQuantity: 5,
|
|
287
|
-
pricePurchase: 10,
|
|
288
|
-
priceToSell: 15,
|
|
289
|
-
discountInPercent: 0,
|
|
290
|
-
priceAfterDiscount: 0,
|
|
291
|
-
expiryDate: null,
|
|
292
|
-
subCategory: null,
|
|
293
|
-
volume: null,
|
|
294
|
-
unitWeight: null,
|
|
295
|
-
articleWeight: null,
|
|
296
|
-
tareWeight: null,
|
|
297
|
-
supplier: null,
|
|
298
|
-
supplierCode: null,
|
|
299
|
-
supplierItemName: null,
|
|
300
|
-
htmlDescription: null,
|
|
301
|
-
},
|
|
302
|
-
],
|
|
303
|
-
count: 1,
|
|
304
|
-
total: 1,
|
|
305
|
-
page: 1,
|
|
306
|
-
totalPage: 1,
|
|
307
|
-
perPage: 10,
|
|
308
|
-
metadata: [],
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
jest.spyOn(service, "provider").mockReturnValue({
|
|
312
|
-
request: () => of(NetworkingUIEventWrapped.succeeded(response)),
|
|
313
|
-
});
|
|
314
|
-
const result = await service.getProductCollectionByStore(storeId, payload).toPromise();
|
|
315
|
-
expect(result?.hasSuccess).toBe(true);
|
|
316
|
-
expect(result?.response).toEqual(response);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
|
|
2
|
-
import { SmessService } from "./smess.service";
|
|
3
|
-
import { BehaviorSubject, Observable } from "rxjs";
|
|
4
|
-
export type StoreTarget = "store-get" | "store-list" | "store-product-category-list" | "store-product-collection" | "store-featured-product-list";
|
|
5
|
-
export interface ProductCollectionRequest {
|
|
6
|
-
page?: number;
|
|
7
|
-
per_page?: number;
|
|
8
|
-
search?: string;
|
|
9
|
-
sort_by?: string;
|
|
10
|
-
category?: string;
|
|
11
|
-
min_price?: number;
|
|
12
|
-
max_price?: number;
|
|
13
|
-
only_discounted?: boolean;
|
|
14
|
-
unit?: string;
|
|
15
|
-
supplier?: string;
|
|
16
|
-
has_offer?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare class StoreProvider implements ProviderType {
|
|
19
|
-
private readonly config;
|
|
20
|
-
private readonly target;
|
|
21
|
-
constructor(config: NetworkingConfig, target: StoreTarget);
|
|
22
|
-
get baseURL(): string;
|
|
23
|
-
get path(): string;
|
|
24
|
-
get method(): string;
|
|
25
|
-
get headers(): Record<string, string>;
|
|
26
|
-
getPath(...queryParams: unknown[]): string;
|
|
27
|
-
}
|
|
28
|
-
export interface StoreData {
|
|
29
|
-
id: string;
|
|
30
|
-
data: HttpResponse;
|
|
31
|
-
timestamp: number;
|
|
32
|
-
}
|
|
33
|
-
export interface StoreListData {
|
|
34
|
-
data: HttpResponse;
|
|
35
|
-
timestamp: number;
|
|
36
|
-
}
|
|
37
|
-
export interface ProductCollectionData {
|
|
38
|
-
storeId: string;
|
|
39
|
-
request: ProductCollectionRequest;
|
|
40
|
-
data: HttpResponse;
|
|
41
|
-
timestamp: number;
|
|
42
|
-
}
|
|
43
|
-
export interface ProductCategoryData {
|
|
44
|
-
data: HttpResponse;
|
|
45
|
-
timestamp: number;
|
|
46
|
-
}
|
|
47
|
-
export interface FeaturedProductData {
|
|
48
|
-
storeId: string;
|
|
49
|
-
data: HttpResponse;
|
|
50
|
-
timestamp: number;
|
|
51
|
-
}
|
|
52
|
-
export declare class StoreService {
|
|
53
|
-
private readonly config;
|
|
54
|
-
readonly $selectedStoreId: BehaviorSubject<string | null>;
|
|
55
|
-
private readonly cacheService;
|
|
56
|
-
private readonly storeListCache;
|
|
57
|
-
private readonly productCollectionCache;
|
|
58
|
-
private readonly productCategoryCache;
|
|
59
|
-
private readonly featuredProductCache;
|
|
60
|
-
constructor(config: NetworkingConfig);
|
|
61
|
-
provider(target: StoreTarget): SmessService<StoreProvider>;
|
|
62
|
-
/**
|
|
63
|
-
* Set the selected store ID
|
|
64
|
-
*/
|
|
65
|
-
setSelectedStoreId(storeId: string | null): void;
|
|
66
|
-
/**
|
|
67
|
-
* Get the current selected store ID
|
|
68
|
-
*/
|
|
69
|
-
get currentSelectedStoreId(): string | null;
|
|
70
|
-
get(id: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
71
|
-
list(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
72
|
-
productCategoryList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
73
|
-
productCollection(id: string, payload: ProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
74
|
-
featuredProductList(id: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
75
|
-
clearCache(): Promise<void>;
|
|
76
|
-
clearStoreCache(id: string): Promise<void>;
|
|
77
|
-
clearProductCollectionCache(id: string): Promise<void>;
|
|
78
|
-
private isCacheValid;
|
|
79
|
-
}
|