@smess/networking 1.0.30 → 1.2.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.
@@ -2,7 +2,7 @@ import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse
2
2
  import { SmessService } from "./smess.service";
3
3
  import { PaginationLinks } from "./store.product.service";
4
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";
5
+ export type CustomerTarget = "register" | "get-profile" | "update-profile" | "update-shipping-address" | "update-billing-address" | "cart-collection" | "customer-product-collection" | "customer-product-create" | "customer-product-remove" | "customer-product-update-category";
6
6
  export interface CustomerRegisterRequest {
7
7
  client_id?: string;
8
8
  email: string;
@@ -22,6 +22,16 @@ export interface CustomerUpdateRequest {
22
22
  contact_email: string | null;
23
23
  phone_number: string | null;
24
24
  }
25
+ export interface CustomerUpdateAddressRequest {
26
+ name?: string | null;
27
+ address?: string | null;
28
+ postalCode?: string | null;
29
+ city?: string | null;
30
+ state?: string | null;
31
+ country?: string | null;
32
+ phone_number?: string | null;
33
+ marked_as_default?: boolean | null;
34
+ }
25
35
  export interface CustomerCartCollectionQuery {
26
36
  page?: number;
27
37
  per_page?: number;
@@ -191,6 +201,8 @@ export declare class CustomerService {
191
201
  register(payload: CustomerRegisterRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
192
202
  getProfile(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
193
203
  updateProfile(payload: CustomerUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
204
+ updateShippingAddress(payload: CustomerUpdateAddressRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
205
+ updateBillingAddress(payload: CustomerUpdateAddressRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
194
206
  getCartCollection(query?: CustomerCartCollectionQuery): Observable<NetworkingUIEventWrapped<HttpResponse>>;
195
207
  getCustomerProductCollection(query?: CustomerProductCollectionQuery): Observable<NetworkingUIEventWrapped<HttpResponse>>;
196
208
  createCustomerProduct(payload: CustomerProductCreateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
@@ -18,6 +18,10 @@ export class CustomerProvider {
18
18
  return "/authentication/customer/get-profile";
19
19
  case "update-profile":
20
20
  return "/authentication/customer/update";
21
+ case "update-shipping-address":
22
+ return "/authentication/customer/update-shipping-address";
23
+ case "update-billing-address":
24
+ return "/authentication/customer/update-billing-address";
21
25
  case "cart-collection":
22
26
  return "/store/cart/collection";
23
27
  case "customer-product-collection":
@@ -46,6 +50,10 @@ export class CustomerProvider {
46
50
  return "DELETE";
47
51
  case "customer-product-update-category":
48
52
  return "PATCH";
53
+ case "update-shipping-address":
54
+ return "PATCH";
55
+ case "update-billing-address":
56
+ return "PATCH";
49
57
  case "update-profile":
50
58
  return "PUT";
51
59
  default:
@@ -96,6 +104,12 @@ export class CustomerService {
96
104
  updateProfile(payload) {
97
105
  return this.provider("update-profile").request(payload);
98
106
  }
107
+ updateShippingAddress(payload) {
108
+ return this.provider("update-shipping-address").request(payload);
109
+ }
110
+ updateBillingAddress(payload) {
111
+ return this.provider("update-billing-address").request(payload);
112
+ }
99
113
  getCartCollection(query) {
100
114
  return this.provider("cart-collection").request(query);
101
115
  }
@@ -1,4 +1,4 @@
1
- import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
1
+ import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse, CacheOptions } from "../types/types";
2
2
  import { SmessService } from "./smess.service";
3
3
  import { Observable } from "rxjs";
4
4
  export type StorefrontStoreTarget = "store-list" | "store-information";
@@ -25,7 +25,9 @@ export declare class StorefrontStoreService {
25
25
  private readonly config;
26
26
  private readonly cacheService;
27
27
  private readonly storeListCache;
28
- constructor(config: NetworkingConfig);
28
+ private readonly cacheOptions;
29
+ private readonly cacheDuration;
30
+ constructor(config: NetworkingConfig, cacheOptions?: CacheOptions);
29
31
  provider(target: StorefrontStoreTarget): SmessService<StorefrontStoreProvider>;
30
32
  /**
31
33
  * List all accessible stores with shipping rules
@@ -46,7 +48,7 @@ export declare class StorefrontStoreService {
46
48
  */
47
49
  clearStoreCache(id: number): Promise<void>;
48
50
  /**
49
- * Check if cache is still valid (24 hours)
51
+ * Check if cache is still valid
50
52
  */
51
53
  private isCacheValid;
52
54
  }
@@ -46,8 +46,11 @@ export class StorefrontStoreProvider {
46
46
  }
47
47
  }
48
48
  export class StorefrontStoreService {
49
- constructor(config) {
49
+ constructor(config, cacheOptions) {
50
50
  this.config = config;
51
+ this.cacheOptions = cacheOptions || {};
52
+ this.cacheDuration =
53
+ this.cacheOptions.cacheTtlMs ?? 24 * 60 * 60 * 1000; // Default 24 hours
51
54
  // Initialize cache services for different data types
52
55
  this.cacheService = new GenericIndexedDBService("StorefrontStoreCache", "id, timestamp", (data) => data, (data) => data);
53
56
  this.storeListCache = new GenericIndexedDBService("StorefrontStoreListCache", "timestamp", (data) => data, (data) => data);
@@ -131,10 +134,9 @@ export class StorefrontStoreService {
131
134
  return this.cacheService.delete(String(id));
132
135
  }
133
136
  /**
134
- * Check if cache is still valid (24 hours)
137
+ * Check if cache is still valid
135
138
  */
136
139
  isCacheValid(timestamp) {
137
- const CACHE_DURATION = 24 * 60 * 60 * 1000; // 24 hours
138
- return Date.now() - timestamp < CACHE_DURATION;
140
+ return Date.now() - timestamp < this.cacheDuration;
139
141
  }
140
142
  }
@@ -90,4 +90,7 @@ export interface NetworkingConfig {
90
90
  clientId?: string;
91
91
  apiKey?: string;
92
92
  }
93
+ export interface CacheOptions {
94
+ cacheTtlMs?: number;
95
+ }
93
96
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smess/networking",
3
- "version": "1.0.30",
3
+ "version": "1.2.0",
4
4
  "description": "Networking utilities and services for SMESS platform.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",