@smess/networking 1.0.29 → 1.0.30

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 (131) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.js +6 -0
  3. package/dist/services/storefront.cart.service.d.ts +73 -0
  4. package/dist/services/storefront.cart.service.js +167 -0
  5. package/dist/services/storefront.cart.service.test.d.ts +1 -0
  6. package/dist/services/storefront.cart.service.test.js +211 -0
  7. package/dist/services/storefront.checkout.service.d.ts +62 -0
  8. package/dist/services/storefront.checkout.service.js +75 -0
  9. package/dist/services/storefront.checkout.service.test.d.ts +1 -0
  10. package/dist/services/storefront.checkout.service.test.js +158 -0
  11. package/dist/services/storefront.customer.metadata.service.d.ts +91 -0
  12. package/dist/services/storefront.customer.metadata.service.js +225 -0
  13. package/dist/services/storefront.customer.metadata.service.test.d.ts +1 -0
  14. package/dist/services/storefront.customer.metadata.service.test.js +271 -0
  15. package/dist/services/storefront.order.service.d.ts +45 -0
  16. package/dist/services/storefront.order.service.js +99 -0
  17. package/dist/services/storefront.order.service.test.d.ts +1 -0
  18. package/dist/services/storefront.order.service.test.js +158 -0
  19. package/dist/services/storefront.product.service.d.ts +52 -0
  20. package/dist/services/storefront.product.service.js +75 -0
  21. package/dist/services/storefront.product.service.test.d.ts +1 -0
  22. package/dist/services/storefront.product.service.test.js +120 -0
  23. package/dist/services/storefront.store.service.d.ts +52 -0
  24. package/dist/services/storefront.store.service.js +140 -0
  25. package/dist/services/storefront.store.service.test.d.ts +1 -0
  26. package/dist/services/storefront.store.service.test.js +90 -0
  27. package/dist/src/core/axios.d.ts +51 -0
  28. package/dist/src/core/axios.js +65 -0
  29. package/dist/src/core/axios.observable.d.ts +11 -0
  30. package/dist/src/core/axios.observable.js +58 -0
  31. package/dist/src/core/base.provider.advanced.test.d.ts +1 -0
  32. package/dist/src/core/base.provider.advanced.test.js +29 -0
  33. package/dist/src/core/base.provider.d.ts +15 -0
  34. package/dist/src/core/base.provider.js +13 -0
  35. package/dist/src/core/base.provider.test.d.ts +1 -0
  36. package/dist/src/core/base.provider.test.js +36 -0
  37. package/dist/src/core/base.service.wrapper.advanced.test.d.ts +1 -0
  38. package/dist/src/core/base.service.wrapper.advanced.test.js +39 -0
  39. package/dist/src/core/base.service.wrapper.d.ts +7 -0
  40. package/dist/src/core/base.service.wrapper.js +11 -0
  41. package/dist/src/core/base.service.wrapper.test.d.ts +1 -0
  42. package/dist/src/core/base.service.wrapper.test.js +25 -0
  43. package/dist/src/core/rx.http.service.d.ts +51 -0
  44. package/dist/src/core/rx.http.service.js +65 -0
  45. package/dist/src/index.d.ts +25 -0
  46. package/dist/src/index.js +29 -0
  47. package/dist/src/services/auth.service.d.ts +65 -0
  48. package/dist/src/services/auth.service.js +197 -0
  49. package/dist/src/services/auth.service.test.d.ts +1 -0
  50. package/dist/src/services/auth.service.test.js +334 -0
  51. package/dist/src/services/cache.service.d.ts +31 -0
  52. package/dist/src/services/cache.service.js +77 -0
  53. package/dist/src/services/cache.service.test.d.ts +1 -0
  54. package/dist/src/services/cache.service.test.js +88 -0
  55. package/dist/src/services/customer.service.d.ts +199 -0
  56. package/dist/src/services/customer.service.js +114 -0
  57. package/dist/src/services/customer.service.test.d.ts +1 -0
  58. package/dist/src/services/customer.service.test.js +430 -0
  59. package/dist/src/services/employee.service.d.ts +73 -0
  60. package/dist/src/services/employee.service.js +74 -0
  61. package/dist/src/services/employee.service.test.d.ts +1 -0
  62. package/dist/src/services/employee.service.test.js +127 -0
  63. package/dist/src/services/logger.service.d.ts +31 -0
  64. package/dist/src/services/logger.service.js +93 -0
  65. package/dist/src/services/logger.service.test.d.ts +1 -0
  66. package/dist/src/services/logger.service.test.js +31 -0
  67. package/dist/src/services/order.service.d.ts +73 -0
  68. package/dist/src/services/order.service.js +97 -0
  69. package/dist/src/services/order.service.test.d.ts +1 -0
  70. package/dist/src/services/order.service.test.js +163 -0
  71. package/dist/src/services/product.service.d.ts +21 -0
  72. package/dist/src/services/product.service.js +42 -0
  73. package/dist/src/services/product.service.test.d.ts +1 -0
  74. package/dist/src/services/product.service.test.js +61 -0
  75. package/dist/src/services/smess.service.d.ts +36 -0
  76. package/dist/src/services/smess.service.js +128 -0
  77. package/dist/src/services/smess.service.test.d.ts +1 -0
  78. package/dist/src/services/smess.service.test.js +103 -0
  79. package/dist/src/services/store.cart.service.d.ts +158 -0
  80. package/dist/src/services/store.cart.service.js +177 -0
  81. package/dist/src/services/store.cart.service.test.d.ts +1 -0
  82. package/dist/src/services/store.cart.service.test.js +394 -0
  83. package/dist/src/services/store.product.service.d.ts +124 -0
  84. package/dist/src/services/store.product.service.js +102 -0
  85. package/dist/src/services/store.product.service.test.d.ts +1 -0
  86. package/dist/src/services/store.product.service.test.js +319 -0
  87. package/dist/src/services/store.service.d.ts +79 -0
  88. package/dist/src/services/store.service.js +235 -0
  89. package/dist/src/services/store.service.test.d.ts +1 -0
  90. package/dist/src/services/store.service.test.js +274 -0
  91. package/dist/src/services/storefront.cart.service.d.ts +73 -0
  92. package/dist/src/services/storefront.cart.service.js +167 -0
  93. package/dist/src/services/storefront.cart.service.test.d.ts +1 -0
  94. package/dist/src/services/storefront.cart.service.test.js +211 -0
  95. package/dist/src/services/storefront.checkout.service.d.ts +62 -0
  96. package/dist/src/services/storefront.checkout.service.js +75 -0
  97. package/dist/src/services/storefront.checkout.service.test.d.ts +1 -0
  98. package/dist/src/services/storefront.checkout.service.test.js +158 -0
  99. package/dist/src/services/storefront.customer.metadata.service.d.ts +91 -0
  100. package/dist/src/services/storefront.customer.metadata.service.js +225 -0
  101. package/dist/src/services/storefront.customer.metadata.service.test.d.ts +1 -0
  102. package/dist/src/services/storefront.customer.metadata.service.test.js +271 -0
  103. package/dist/src/services/storefront.order.service.d.ts +45 -0
  104. package/dist/src/services/storefront.order.service.js +99 -0
  105. package/dist/src/services/storefront.order.service.test.d.ts +1 -0
  106. package/dist/src/services/storefront.order.service.test.js +158 -0
  107. package/dist/src/services/storefront.product.service.d.ts +52 -0
  108. package/dist/src/services/storefront.product.service.js +75 -0
  109. package/dist/src/services/storefront.product.service.test.d.ts +1 -0
  110. package/dist/src/services/storefront.product.service.test.js +120 -0
  111. package/dist/src/services/storefront.store.service.d.ts +52 -0
  112. package/dist/src/services/storefront.store.service.js +140 -0
  113. package/dist/src/services/storefront.store.service.test.d.ts +1 -0
  114. package/dist/src/services/storefront.store.service.test.js +90 -0
  115. package/dist/src/services/user.service.d.ts +16 -0
  116. package/dist/src/services/user.service.js +37 -0
  117. package/dist/src/services/user.service.test.d.ts +1 -0
  118. package/dist/src/services/user.service.test.js +52 -0
  119. package/dist/src/services/utils/withAuthReset.d.ts +3 -0
  120. package/dist/src/services/utils/withAuthReset.js +8 -0
  121. package/dist/src/types/types.d.ts +93 -0
  122. package/dist/src/types/types.js +82 -0
  123. package/dist/src/types/types.test.d.ts +1 -0
  124. package/dist/src/types/types.test.js +25 -0
  125. package/dist/src/utils/cache-import.d.ts +3 -0
  126. package/dist/src/utils/cache-import.js +2 -0
  127. package/dist/src/utils/networking-import.d.ts +4 -0
  128. package/dist/src/utils/networking-import.js +3 -0
  129. package/dist/src/utils/rxjs-import.d.ts +5 -0
  130. package/dist/src/utils/rxjs-import.js +5 -0
  131. package/package.json +1 -1
@@ -0,0 +1,199 @@
1
+ import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
2
+ import { SmessService } from "./smess.service";
3
+ import { PaginationLinks } from "./store.product.service";
4
+ import { BehaviorSubject, Observable } from "rxjs";
5
+ export type CustomerTarget = "register" | "get-profile" | "update-profile" | "cart-collection" | "customer-product-collection" | "customer-product-create" | "customer-product-remove" | "customer-product-update-category";
6
+ export interface CustomerRegisterRequest {
7
+ client_id?: string;
8
+ email: string;
9
+ password: string;
10
+ phone_number?: string;
11
+ name?: string;
12
+ address?: string;
13
+ tax_identification_number?: string | null;
14
+ }
15
+ export interface CustomerUpdateRequest {
16
+ name: string;
17
+ address: string;
18
+ postal_code: string;
19
+ city: string;
20
+ state: string | null;
21
+ country: string | null;
22
+ contact_email: string | null;
23
+ phone_number: string | null;
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
+ }
175
+ export declare class CustomerProvider implements ProviderType {
176
+ private readonly config;
177
+ private readonly target;
178
+ private readonly $authToken;
179
+ constructor(config: NetworkingConfig, target: CustomerTarget, $authToken: BehaviorSubject<string | null>);
180
+ get baseURL(): string;
181
+ get path(): string;
182
+ get method(): string;
183
+ get headers(): Record<string, string>;
184
+ getPath(...queryParams: unknown[]): string;
185
+ }
186
+ export declare class CustomerService {
187
+ private readonly config;
188
+ private readonly $authToken;
189
+ constructor(config: NetworkingConfig, $authToken: BehaviorSubject<string | null>);
190
+ provider(target: CustomerTarget): SmessService<CustomerProvider>;
191
+ register(payload: CustomerRegisterRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
192
+ getProfile(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
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>>;
199
+ }
@@ -0,0 +1,114 @@
1
+ import { Accept, SMESSHeader, SmessService } from "./smess.service";
2
+ export class CustomerProvider {
3
+ constructor(config, target, $authToken) {
4
+ this.config = config;
5
+ this.target = target;
6
+ this.$authToken = $authToken;
7
+ }
8
+ get baseURL() {
9
+ return this.config.version
10
+ ? `${this.config.baseUrl}/${this.config.version}`
11
+ : this.config.baseUrl;
12
+ }
13
+ get path() {
14
+ switch (this.target) {
15
+ case "register":
16
+ return "/authentication/customer/register";
17
+ case "get-profile":
18
+ return "/authentication/customer/get-profile";
19
+ case "update-profile":
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/add";
27
+ case "customer-product-remove":
28
+ return "/store/customer-product/remove";
29
+ case "customer-product-update-category":
30
+ return "/store/customer-product/category";
31
+ default:
32
+ return "/authentication/customer";
33
+ }
34
+ }
35
+ get method() {
36
+ switch (this.target) {
37
+ case "get-profile":
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";
49
+ case "update-profile":
50
+ return "PUT";
51
+ default:
52
+ return "POST";
53
+ }
54
+ }
55
+ get headers() {
56
+ let headers = SmessService.getHeaders(Accept.V1, this.$authToken.value);
57
+ switch (this.target) {
58
+ case "register":
59
+ headers = SmessService.getHeaders(Accept.V1);
60
+ break;
61
+ default:
62
+ headers = SmessService.getHeaders(Accept.V1, this.$authToken.value);
63
+ }
64
+ if (this.config.clientId) {
65
+ headers[SMESSHeader.ClientId] = this.config.clientId;
66
+ }
67
+ if (this.config.apiKey) {
68
+ headers[SMESSHeader.ApiKey] = this.config.apiKey;
69
+ }
70
+ return SmessService.filterHeaders(headers);
71
+ }
72
+ getPath(...queryParams) {
73
+ let definedPath = this.path;
74
+ const params = definedPath.match(/\$\{(.+?)\}/g);
75
+ params?.forEach((value, index) => {
76
+ definedPath = definedPath.replace(value, String(queryParams[index]));
77
+ });
78
+ return definedPath;
79
+ }
80
+ }
81
+ export class CustomerService {
82
+ constructor(config, $authToken) {
83
+ this.config = config;
84
+ this.$authToken = $authToken;
85
+ }
86
+ provider(target) {
87
+ const targetWrapper = new CustomerProvider(this.config, target, this.$authToken);
88
+ return new SmessService(targetWrapper);
89
+ }
90
+ register(payload) {
91
+ return this.provider("register").request(payload);
92
+ }
93
+ getProfile() {
94
+ return this.provider("get-profile").request();
95
+ }
96
+ updateProfile(payload) {
97
+ return this.provider("update-profile").request(payload);
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
+ }
114
+ }
@@ -0,0 +1 @@
1
+ export {};