@smess/networking 1.0.24 → 1.0.26

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 (90) 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 +29 -1
  4. package/dist/services/customer.service.js +35 -0
  5. package/dist/services/customer.service.test.js +174 -0
  6. package/dist/{src/services → services}/employee.service.js +4 -3
  7. package/dist/{src/services → services}/employee.service.test.js +13 -6
  8. package/dist/services/utils/withAuthReset.d.ts +3 -0
  9. package/dist/services/utils/withAuthReset.js +8 -0
  10. package/package.json +1 -1
  11. package/dist/scripts/dev-test.d.ts +0 -1
  12. package/dist/scripts/dev-test.js +0 -803
  13. package/dist/scripts/real-test.d.ts +0 -1
  14. package/dist/scripts/real-test.js +0 -341
  15. package/dist/src/core/axios.d.ts +0 -51
  16. package/dist/src/core/axios.js +0 -65
  17. package/dist/src/core/axios.observable.d.ts +0 -11
  18. package/dist/src/core/axios.observable.js +0 -58
  19. package/dist/src/core/base.provider.advanced.test.d.ts +0 -1
  20. package/dist/src/core/base.provider.advanced.test.js +0 -29
  21. package/dist/src/core/base.provider.d.ts +0 -15
  22. package/dist/src/core/base.provider.js +0 -13
  23. package/dist/src/core/base.provider.test.d.ts +0 -1
  24. package/dist/src/core/base.provider.test.js +0 -36
  25. package/dist/src/core/base.service.wrapper.advanced.test.d.ts +0 -1
  26. package/dist/src/core/base.service.wrapper.advanced.test.js +0 -39
  27. package/dist/src/core/base.service.wrapper.d.ts +0 -7
  28. package/dist/src/core/base.service.wrapper.js +0 -11
  29. package/dist/src/core/base.service.wrapper.test.d.ts +0 -1
  30. package/dist/src/core/base.service.wrapper.test.js +0 -25
  31. package/dist/src/core/rx.http.service.d.ts +0 -51
  32. package/dist/src/core/rx.http.service.js +0 -65
  33. package/dist/src/index.d.ts +0 -17
  34. package/dist/src/index.js +0 -21
  35. package/dist/src/services/auth.service.d.ts +0 -65
  36. package/dist/src/services/auth.service.js +0 -197
  37. package/dist/src/services/auth.service.test.d.ts +0 -1
  38. package/dist/src/services/auth.service.test.js +0 -334
  39. package/dist/src/services/cache.service.d.ts +0 -31
  40. package/dist/src/services/cache.service.js +0 -77
  41. package/dist/src/services/cache.service.test.d.ts +0 -1
  42. package/dist/src/services/cache.service.test.js +0 -88
  43. package/dist/src/services/customer.service.d.ts +0 -71
  44. package/dist/src/services/customer.service.js +0 -114
  45. package/dist/src/services/customer.service.test.d.ts +0 -1
  46. package/dist/src/services/customer.service.test.js +0 -274
  47. package/dist/src/services/logger.service.d.ts +0 -31
  48. package/dist/src/services/logger.service.js +0 -93
  49. package/dist/src/services/logger.service.test.d.ts +0 -1
  50. package/dist/src/services/logger.service.test.js +0 -31
  51. package/dist/src/services/order.service.d.ts +0 -73
  52. package/dist/src/services/order.service.js +0 -97
  53. package/dist/src/services/order.service.test.d.ts +0 -1
  54. package/dist/src/services/order.service.test.js +0 -163
  55. package/dist/src/services/product.service.d.ts +0 -21
  56. package/dist/src/services/product.service.js +0 -42
  57. package/dist/src/services/product.service.test.d.ts +0 -1
  58. package/dist/src/services/product.service.test.js +0 -61
  59. package/dist/src/services/smess.service.d.ts +0 -36
  60. package/dist/src/services/smess.service.js +0 -128
  61. package/dist/src/services/smess.service.test.d.ts +0 -1
  62. package/dist/src/services/smess.service.test.js +0 -103
  63. package/dist/src/services/store.cart.service.d.ts +0 -158
  64. package/dist/src/services/store.cart.service.js +0 -177
  65. package/dist/src/services/store.cart.service.test.d.ts +0 -1
  66. package/dist/src/services/store.cart.service.test.js +0 -394
  67. package/dist/src/services/store.product.service.d.ts +0 -123
  68. package/dist/src/services/store.product.service.js +0 -102
  69. package/dist/src/services/store.product.service.test.d.ts +0 -1
  70. package/dist/src/services/store.product.service.test.js +0 -319
  71. package/dist/src/services/store.service.d.ts +0 -79
  72. package/dist/src/services/store.service.js +0 -235
  73. package/dist/src/services/store.service.test.d.ts +0 -1
  74. package/dist/src/services/store.service.test.js +0 -274
  75. package/dist/src/services/user.service.d.ts +0 -16
  76. package/dist/src/services/user.service.js +0 -37
  77. package/dist/src/services/user.service.test.d.ts +0 -1
  78. package/dist/src/services/user.service.test.js +0 -52
  79. package/dist/src/types/types.d.ts +0 -93
  80. package/dist/src/types/types.js +0 -82
  81. package/dist/src/types/types.test.d.ts +0 -1
  82. package/dist/src/types/types.test.js +0 -25
  83. package/dist/src/utils/cache-import.d.ts +0 -3
  84. package/dist/src/utils/cache-import.js +0 -2
  85. package/dist/src/utils/networking-import.d.ts +0 -4
  86. package/dist/src/utils/networking-import.js +0 -3
  87. package/dist/src/utils/rxjs-import.d.ts +0 -5
  88. package/dist/src/utils/rxjs-import.js +0 -5
  89. /package/dist/{src/services → services}/employee.service.d.ts +0 -0
  90. /package/dist/{src/services → services}/employee.service.test.d.ts +0 -0
@@ -1,158 +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 StoreCartTarget = "cart-get" | "cart-update" | "cart-add-item" | "cart-update-item" | "cart-delete-item" | "cart-delete-all-items" | "cart-batch-items";
5
- export interface BillingInformation {
6
- email?: string;
7
- phone_number?: string;
8
- street?: string;
9
- city?: string;
10
- postal_code?: string;
11
- state?: string;
12
- country?: string;
13
- [key: string]: unknown;
14
- }
15
- export interface ShippingInformation {
16
- email?: string;
17
- phone_number?: string;
18
- street?: string;
19
- city?: string;
20
- postal_code?: string;
21
- state?: string;
22
- country?: string;
23
- [key: string]: unknown;
24
- }
25
- export interface CartItem {
26
- [key: string]: unknown;
27
- }
28
- export interface StoreInfo {
29
- [key: string]: unknown;
30
- }
31
- export interface Cart {
32
- dateCreated: string;
33
- dateModified: string;
34
- discountTotal: number;
35
- discountTax: number;
36
- shippingTotal: number;
37
- shippingTax: number;
38
- cartTax: number;
39
- total: number;
40
- totalTax: number;
41
- customerId: string | null;
42
- billingInformation: BillingInformation | null;
43
- shippingInformation: ShippingInformation | null;
44
- paymentMethod: string;
45
- deliveryType: string;
46
- transactionId: string | null;
47
- customerIpAddress: string;
48
- customerUserAgent: string;
49
- customerNote: string | null;
50
- cartHash: string;
51
- cartItems: CartItem[];
52
- paymentUrl: string | null;
53
- store: StoreInfo | null;
54
- [key: string]: unknown;
55
- }
56
- export interface CartUpdateRequest {
57
- status?: string;
58
- customer_note?: string;
59
- customer_id?: string;
60
- payment_method?: string;
61
- delivery_type?: string;
62
- billing_information?: BillingInformation;
63
- shipping_information?: ShippingInformation;
64
- [key: string]: unknown;
65
- }
66
- export interface CartAddItemRequest {
67
- product_id: string;
68
- quantity: number;
69
- [key: string]: unknown;
70
- }
71
- export interface CartUpdateItemQuantityRequest {
72
- quantity: number;
73
- }
74
- export interface CartBatchItemsRequest {
75
- create?: Array<{
76
- product_id: string;
77
- quantity: number;
78
- [key: string]: unknown;
79
- }>;
80
- update?: Array<{
81
- product_id: string;
82
- quantity: number;
83
- [key: string]: unknown;
84
- }>;
85
- [key: string]: unknown;
86
- }
87
- export declare class StoreCartProvider implements ProviderType {
88
- private readonly config;
89
- private readonly target;
90
- private readonly $cartHash;
91
- private readonly $storeId;
92
- constructor(config: NetworkingConfig, target: StoreCartTarget, $cartHash: BehaviorSubject<string | null>, $storeId: BehaviorSubject<string | null>);
93
- get baseURL(): string;
94
- get path(): string;
95
- get method(): string;
96
- get headers(): Record<string, string>;
97
- getPath(...queryParams: unknown[]): string;
98
- }
99
- export interface StoreCartServiceType {
100
- getCart(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
101
- updateCart(payload: CartUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
102
- addItem(payload: CartAddItemRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
103
- batchItems(payload: CartBatchItemsRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
104
- updateItemQuantity(itemId: string, payload: CartUpdateItemQuantityRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
105
- deleteItem(itemId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
106
- deleteAllItems(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
107
- }
108
- export declare class StoreCartService implements StoreCartServiceType {
109
- private readonly config;
110
- private readonly $cartHash;
111
- private readonly $storeId;
112
- constructor(config: NetworkingConfig, $storeId?: BehaviorSubject<string | null>);
113
- get currentCartHash(): string | null;
114
- get cartHash$(): BehaviorSubject<string | null>;
115
- get currentStoreId(): string | null;
116
- get storeId$(): BehaviorSubject<string | null>;
117
- setStoreId(storeId: string | null): void;
118
- provider(target: StoreCartTarget): SmessService<StoreCartProvider>;
119
- /**
120
- * Update the cart hash from cart response
121
- */
122
- private updateCartHash;
123
- /**
124
- * Get the current cart
125
- * GET api/v1/store/cart
126
- */
127
- getCart(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
128
- /**
129
- * Update cart (e.g., add notes, apply coupon)
130
- * PUT api/v1/store/cart
131
- */
132
- updateCart(payload: CartUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
133
- /**
134
- * Add item to cart
135
- * POST api/v1/store/cart/items
136
- */
137
- addItem(payload: CartAddItemRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
138
- /**
139
- * Batch create/update items in cart
140
- * POST api/v1/store/cart/items/batch
141
- */
142
- batchItems(payload: CartBatchItemsRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
143
- /**
144
- * Update item quantity in cart
145
- * PUT api/v1/store/cart/items/{id}
146
- */
147
- updateItemQuantity(itemId: string, payload: CartUpdateItemQuantityRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
148
- /**
149
- * Delete item from cart
150
- * DELETE api/v1/store/cart/items/{id}
151
- */
152
- deleteItem(itemId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
153
- /**
154
- * Delete all items from cart
155
- * DELETE api/v1/store/cart/items
156
- */
157
- deleteAllItems(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
158
- }
@@ -1,177 +0,0 @@
1
- import { Accept, SMESSHeader, SmessService } from "./smess.service";
2
- import { BehaviorSubject } from "rxjs";
3
- import { tap } from "rxjs/operators";
4
- export class StoreCartProvider {
5
- constructor(config, target, $cartHash, $storeId) {
6
- this.config = config;
7
- this.target = target;
8
- this.$cartHash = $cartHash;
9
- this.$storeId = $storeId;
10
- }
11
- get baseURL() {
12
- return this.config.version
13
- ? `${this.config.baseUrl}/${this.config.version}`
14
- : this.config.baseUrl;
15
- }
16
- get path() {
17
- switch (this.target) {
18
- case "cart-get":
19
- return "/store/cart";
20
- case "cart-update":
21
- return "/store/cart";
22
- case "cart-add-item":
23
- return "/store/cart/items";
24
- case "cart-update-item":
25
- return "/store/cart/items/\${id}";
26
- case "cart-delete-item":
27
- return "/store/cart/items/\${id}";
28
- case "cart-delete-all-items":
29
- return "/store/cart/items";
30
- case "cart-batch-items":
31
- return "/store/cart/items/batch";
32
- default:
33
- return "/store/cart";
34
- }
35
- }
36
- get method() {
37
- switch (this.target) {
38
- case "cart-get":
39
- return "GET";
40
- case "cart-update":
41
- return "PUT";
42
- case "cart-add-item":
43
- return "POST";
44
- case "cart-update-item":
45
- return "PUT";
46
- case "cart-delete-item":
47
- return "DELETE";
48
- case "cart-delete-all-items":
49
- return "DELETE";
50
- case "cart-batch-items":
51
- return "POST";
52
- default:
53
- return "GET";
54
- }
55
- }
56
- get headers() {
57
- let headers = SmessService.getHeaders(Accept.V1, null);
58
- if (this.config.clientId) {
59
- headers[SMESSHeader.ClientId] = this.config.clientId;
60
- }
61
- if (this.config.apiKey) {
62
- headers[SMESSHeader.ApiKey] = this.config.apiKey;
63
- }
64
- const filteredHeaders = SmessService.filterHeaders(headers);
65
- // Add X-Nonce-Token header if cartHash is available
66
- if (this.$cartHash.value) {
67
- filteredHeaders["X-Nonce-Token"] = this.$cartHash.value;
68
- }
69
- // Add X-Store-Id header if storeId is available
70
- if (this.$storeId.value) {
71
- filteredHeaders["X-Store-Id"] = this.$storeId.value;
72
- }
73
- return filteredHeaders;
74
- }
75
- getPath(...queryParams) {
76
- let definedPath = this.path;
77
- const params = definedPath.match(/\$\{(.+?)\}/g);
78
- params?.forEach((value, index) => {
79
- definedPath = definedPath.replace(value, String(queryParams[index]));
80
- });
81
- return definedPath;
82
- }
83
- }
84
- export class StoreCartService {
85
- constructor(config, $storeId) {
86
- this.config = config;
87
- this.$cartHash = new BehaviorSubject(null);
88
- // Use the provided BehaviorSubject or create a new one
89
- this.$storeId = $storeId || new BehaviorSubject(null);
90
- }
91
- // Getter to access the current cart hash
92
- get currentCartHash() {
93
- return this.$cartHash.value;
94
- }
95
- // Getter to access the cart hash as observable
96
- get cartHash$() {
97
- return this.$cartHash;
98
- }
99
- // Getter to access the current store ID
100
- get currentStoreId() {
101
- return this.$storeId.value;
102
- }
103
- // Getter to access the store ID as observable
104
- get storeId$() {
105
- return this.$storeId;
106
- }
107
- // Method to update the store ID
108
- setStoreId(storeId) {
109
- this.$storeId.next(storeId);
110
- }
111
- provider(target) {
112
- const targetWrapper = new StoreCartProvider(this.config, target, this.$cartHash, this.$storeId);
113
- return new SmessService(targetWrapper);
114
- }
115
- /**
116
- * Update the cart hash from cart response
117
- */
118
- updateCartHash(result) {
119
- if (result.hasSuccess && result.response) {
120
- const response = result.response;
121
- // Try to extract cartHash from different possible structures
122
- const cartHash = response.data?.cartHash || response.cartHash;
123
- if (cartHash) {
124
- this.$cartHash.next(cartHash);
125
- }
126
- }
127
- }
128
- /**
129
- * Get the current cart
130
- * GET api/v1/store/cart
131
- */
132
- getCart() {
133
- return this.provider("cart-get").request().pipe(tap((result) => this.updateCartHash(result)));
134
- }
135
- /**
136
- * Update cart (e.g., add notes, apply coupon)
137
- * PUT api/v1/store/cart
138
- */
139
- updateCart(payload) {
140
- return this.provider("cart-update").request(payload).pipe(tap((result) => this.updateCartHash(result)));
141
- }
142
- /**
143
- * Add item to cart
144
- * POST api/v1/store/cart/items
145
- */
146
- addItem(payload) {
147
- return this.provider("cart-add-item").request(payload).pipe(tap((result) => this.updateCartHash(result)));
148
- }
149
- /**
150
- * Batch create/update items in cart
151
- * POST api/v1/store/cart/items/batch
152
- */
153
- batchItems(payload) {
154
- return this.provider("cart-batch-items").request(payload).pipe(tap((result) => this.updateCartHash(result)));
155
- }
156
- /**
157
- * Update item quantity in cart
158
- * PUT api/v1/store/cart/items/{id}
159
- */
160
- updateItemQuantity(itemId, payload) {
161
- return this.provider("cart-update-item").request(payload, undefined, itemId).pipe(tap((result) => this.updateCartHash(result)));
162
- }
163
- /**
164
- * Delete item from cart
165
- * DELETE api/v1/store/cart/items/{id}
166
- */
167
- deleteItem(itemId) {
168
- return this.provider("cart-delete-item").request(undefined, undefined, itemId);
169
- }
170
- /**
171
- * Delete all items from cart
172
- * DELETE api/v1/store/cart/items
173
- */
174
- deleteAllItems() {
175
- return this.provider("cart-delete-all-items").request();
176
- }
177
- }
@@ -1 +0,0 @@
1
- export {};