feeef 0.5.38-dev.2 → 0.5.38-dev.3
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/build/index.js +602 -29
- package/build/index.js.map +1 -1
- package/build/src/core/entities/city.d.ts +17 -0
- package/build/src/core/entities/country.d.ts +17 -0
- package/build/src/core/entities/order.d.ts +1 -0
- package/build/src/core/entities/product.d.ts +1 -0
- package/build/src/core/entities/shipping_price.d.ts +120 -0
- package/build/src/core/entities/state.d.ts +17 -0
- package/build/src/core/entities/store.d.ts +1 -0
- package/build/src/feeef/feeef.d.ts +20 -0
- package/build/src/feeef/repositories/cities.d.ts +78 -0
- package/build/src/feeef/repositories/countries.d.ts +20 -0
- package/build/src/feeef/repositories/shipping_prices.d.ts +28 -0
- package/build/src/feeef/repositories/states.d.ts +62 -0
- package/build/src/feeef/services/cart.d.ts +46 -5
- package/build/src/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* City Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a city with composite key (countryCode + stateCode + name).
|
|
5
|
+
*/
|
|
6
|
+
export interface CityEntity {
|
|
7
|
+
/** Country code (part of composite primary key) */
|
|
8
|
+
countryCode: string;
|
|
9
|
+
/** State code (part of composite primary key) */
|
|
10
|
+
stateCode: string;
|
|
11
|
+
/** City name (part of composite primary key) */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Additional metadata as key-value pairs */
|
|
14
|
+
metadata: Record<string, any>;
|
|
15
|
+
/** Creation timestamp */
|
|
16
|
+
createdAt: any;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Country Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a country with ISO 3166-1 alpha-2 country code.
|
|
5
|
+
*/
|
|
6
|
+
export interface CountryEntity {
|
|
7
|
+
/** ISO 3166-1 alpha-2 country code (e.g., US, DZ, SA) */
|
|
8
|
+
code: string;
|
|
9
|
+
/** Country name (e.g., United States, Algeria, Saudi Arabia) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Phone country code without + (e.g., 1, 213, 966) */
|
|
12
|
+
phone: string;
|
|
13
|
+
/** Additional metadata as key-value pairs */
|
|
14
|
+
metadata: Record<string, any>;
|
|
15
|
+
/** Creation timestamp */
|
|
16
|
+
createdAt: any;
|
|
17
|
+
}
|
|
@@ -33,6 +33,7 @@ export interface OrderEntity {
|
|
|
33
33
|
shippingAddress?: string | null;
|
|
34
34
|
shippingCity?: string | null;
|
|
35
35
|
shippingState?: string | null;
|
|
36
|
+
shippingCountry?: string | null;
|
|
36
37
|
shippingMethodId?: string | null;
|
|
37
38
|
shippingType: ShippingType;
|
|
38
39
|
trackingCode: string | null;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shipping Price Entity
|
|
3
|
+
*
|
|
4
|
+
* A simplified, country-aware shipping pricing system that replaces
|
|
5
|
+
* the legacy array-based shipping rates with a structured approach.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Country codes as keys (ISO 3166-1 alpha-2)
|
|
9
|
+
* - State codes as keys (no fragile array indexes)
|
|
10
|
+
* - Named price types for extensibility
|
|
11
|
+
* - Gradual migration path from legacy system
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const prices: ShippingPriceRates = {
|
|
16
|
+
* "DZ": {
|
|
17
|
+
* "01": { home: 800, desk: 400, pickup: 0 },
|
|
18
|
+
* "16": { home: 600, desk: 300, pickup: 0 }
|
|
19
|
+
* },
|
|
20
|
+
* "IQ": {
|
|
21
|
+
* "01": { home: 15000, desk: 10000, pickup: 5000 }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Individual state shipping rates with named price types.
|
|
28
|
+
* Using named properties instead of array indexes for clarity and extensibility.
|
|
29
|
+
*/
|
|
30
|
+
export interface ShippingStateRates {
|
|
31
|
+
/** Price for home delivery (nullable if unavailable) */
|
|
32
|
+
home: number | null;
|
|
33
|
+
/** Price for desk/office pickup (nullable if unavailable) */
|
|
34
|
+
desk: number | null;
|
|
35
|
+
/** Price for store pickup (nullable if unavailable) */
|
|
36
|
+
pickup: number | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shipping rates organized by country code and state code.
|
|
40
|
+
* Structure: { [countryCode]: { [stateCode]: ShippingStateRates } }
|
|
41
|
+
*/
|
|
42
|
+
export type ShippingPriceRates = Record<string, Record<string, ShippingStateRates>>;
|
|
43
|
+
/**
|
|
44
|
+
* Status of the shipping price configuration.
|
|
45
|
+
*/
|
|
46
|
+
export declare enum ShippingPriceStatus {
|
|
47
|
+
/** Not yet published, only visible to store owner */
|
|
48
|
+
draft = "draft",
|
|
49
|
+
/** Active and used for shipping calculations */
|
|
50
|
+
published = "published"
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Shipping Price Entity
|
|
54
|
+
*
|
|
55
|
+
* Represents a shipping pricing configuration for a store.
|
|
56
|
+
* Supports multi-country operations with state-level pricing.
|
|
57
|
+
*/
|
|
58
|
+
export interface ShippingPriceEntity {
|
|
59
|
+
/** Unique identifier (24-char string) */
|
|
60
|
+
id: string;
|
|
61
|
+
/** Display name for this pricing configuration */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Optional logo URL for branding */
|
|
64
|
+
logoUrl: string | null;
|
|
65
|
+
/** Store this pricing belongs to */
|
|
66
|
+
storeId: string;
|
|
67
|
+
/**
|
|
68
|
+
* Pricing data structured by country and state codes.
|
|
69
|
+
* @see ShippingPriceRates
|
|
70
|
+
*/
|
|
71
|
+
prices: ShippingPriceRates;
|
|
72
|
+
/** Publication status */
|
|
73
|
+
status: ShippingPriceStatus;
|
|
74
|
+
/** Creation timestamp */
|
|
75
|
+
createdAt: any;
|
|
76
|
+
/** Last update timestamp */
|
|
77
|
+
updatedAt: any;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Shipping type enumeration for order shipping type.
|
|
81
|
+
* Maps to the pricing structure keys.
|
|
82
|
+
*/
|
|
83
|
+
export type ShippingPriceType = keyof ShippingStateRates;
|
|
84
|
+
/**
|
|
85
|
+
* Helper function to get shipping price from rates.
|
|
86
|
+
*
|
|
87
|
+
* @param prices - The shipping price rates object
|
|
88
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
89
|
+
* @param stateCode - State/province code
|
|
90
|
+
* @param type - Shipping type (home, desk, pickup)
|
|
91
|
+
* @returns The price or null if not available
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const price = getShippingPrice(shippingPrice.prices, 'DZ', '16', 'home')
|
|
96
|
+
* // Returns 600 or null
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function getShippingPrice(prices: ShippingPriceRates, countryCode: string, stateCode: string, type: ShippingPriceType): number | null;
|
|
100
|
+
/**
|
|
101
|
+
* Helper function to check if shipping is available for a location.
|
|
102
|
+
*
|
|
103
|
+
* @param prices - The shipping price rates object
|
|
104
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
105
|
+
* @param stateCode - State/province code
|
|
106
|
+
* @returns True if any shipping type is available for this location
|
|
107
|
+
*/
|
|
108
|
+
export declare function isShippingAvailable(prices: ShippingPriceRates, countryCode: string, stateCode: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Helper function to get all available shipping types for a location.
|
|
111
|
+
*
|
|
112
|
+
* @param prices - The shipping price rates object
|
|
113
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
114
|
+
* @param stateCode - State/province code
|
|
115
|
+
* @returns Array of available shipping types with their prices
|
|
116
|
+
*/
|
|
117
|
+
export declare function getAvailableShippingTypes(prices: ShippingPriceRates, countryCode: string, stateCode: string): Array<{
|
|
118
|
+
type: ShippingPriceType;
|
|
119
|
+
price: number;
|
|
120
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State/Province Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a state or province with composite key (countryCode + code).
|
|
5
|
+
*/
|
|
6
|
+
export interface StateEntity {
|
|
7
|
+
/** Country code (part of composite primary key) */
|
|
8
|
+
countryCode: string;
|
|
9
|
+
/** State/province code (part of composite primary key) */
|
|
10
|
+
code: string;
|
|
11
|
+
/** State/province name */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Additional metadata as key-value pairs */
|
|
14
|
+
metadata: Record<string, any>;
|
|
15
|
+
/** Creation timestamp */
|
|
16
|
+
createdAt: any;
|
|
17
|
+
}
|
|
@@ -5,6 +5,10 @@ import { StoreRepository } from './repositories/stores.js';
|
|
|
5
5
|
import { UserRepository } from './repositories/users.js';
|
|
6
6
|
import { DepositRepository } from './repositories/deposits.js';
|
|
7
7
|
import { CategoryRepository } from './repositories/categories.js';
|
|
8
|
+
import { CountryRepository } from './repositories/countries.js';
|
|
9
|
+
import { StateRepository } from './repositories/states.js';
|
|
10
|
+
import { CityRepository } from './repositories/cities.js';
|
|
11
|
+
import { ShippingPriceRepository } from './repositories/shipping_prices.js';
|
|
8
12
|
import { CartService } from './services/cart.js';
|
|
9
13
|
import { ActionsService } from './services/actions.js';
|
|
10
14
|
/**
|
|
@@ -67,6 +71,22 @@ export declare class FeeeF {
|
|
|
67
71
|
* The repository for managing categories.
|
|
68
72
|
*/
|
|
69
73
|
categories: CategoryRepository;
|
|
74
|
+
/**
|
|
75
|
+
* The repository for managing countries.
|
|
76
|
+
*/
|
|
77
|
+
countries: CountryRepository;
|
|
78
|
+
/**
|
|
79
|
+
* The repository for managing states.
|
|
80
|
+
*/
|
|
81
|
+
states: StateRepository;
|
|
82
|
+
/**
|
|
83
|
+
* The repository for managing cities.
|
|
84
|
+
*/
|
|
85
|
+
cities: CityRepository;
|
|
86
|
+
/**
|
|
87
|
+
* The repository for managing shipping prices.
|
|
88
|
+
*/
|
|
89
|
+
shippingPrices: ShippingPriceRepository;
|
|
70
90
|
/**
|
|
71
91
|
* The cart service for managing the cart.
|
|
72
92
|
*/
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository, ModelListOptions } from './repository.js';
|
|
3
|
+
import { CityEntity } from '../../core/entities/city.js';
|
|
4
|
+
/**
|
|
5
|
+
* Repository for managing City entities.
|
|
6
|
+
* Cities have composite keys (countryCode + stateCode + name) and are nested under states.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CityRepository extends ModelRepository<CityEntity, any, any> {
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new CityRepository instance.
|
|
11
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
12
|
+
*/
|
|
13
|
+
constructor(client: AxiosInstance);
|
|
14
|
+
/**
|
|
15
|
+
* Lists cities, optionally filtered by country code and/or state code.
|
|
16
|
+
* @param options - The options for listing cities, including filters.
|
|
17
|
+
* @returns A Promise that resolves to a list of City entities.
|
|
18
|
+
*/
|
|
19
|
+
list(options?: ModelListOptions & {
|
|
20
|
+
countryCode?: string;
|
|
21
|
+
stateCode?: string;
|
|
22
|
+
}): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Lists cities for a specific country and state (nested route).
|
|
25
|
+
* @param countryCode - The country code.
|
|
26
|
+
* @param stateCode - The state code.
|
|
27
|
+
* @param options - Optional list options.
|
|
28
|
+
* @returns A Promise that resolves to a list of City entities.
|
|
29
|
+
*/
|
|
30
|
+
listByState(countryCode: string, stateCode: string, options?: ModelListOptions): Promise<any>;
|
|
31
|
+
/**
|
|
32
|
+
* Finds a city by country code, state code, and city name.
|
|
33
|
+
* @param countryCode - The country code.
|
|
34
|
+
* @param stateCode - The state code.
|
|
35
|
+
* @param cityName - The city name.
|
|
36
|
+
* @param params - Optional query parameters.
|
|
37
|
+
* @returns A Promise that resolves to the found City entity.
|
|
38
|
+
*/
|
|
39
|
+
findByName(countryCode: string, stateCode: string, cityName: string, params?: Record<string, any>): Promise<CityEntity>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new city (nested under country/state).
|
|
42
|
+
* @param countryCode - The country code.
|
|
43
|
+
* @param stateCode - The state code.
|
|
44
|
+
* @param data - The city data.
|
|
45
|
+
* @param params - Optional query parameters.
|
|
46
|
+
* @returns A Promise that resolves to the created City entity.
|
|
47
|
+
*/
|
|
48
|
+
createByState(countryCode: string, stateCode: string, data: any, params?: Record<string, any>): Promise<CityEntity>;
|
|
49
|
+
/**
|
|
50
|
+
* Updates a city (nested under country/state).
|
|
51
|
+
* @param countryCode - The country code.
|
|
52
|
+
* @param stateCode - The state code.
|
|
53
|
+
* @param cityName - The city name.
|
|
54
|
+
* @param data - The update data.
|
|
55
|
+
* @param params - Optional query parameters.
|
|
56
|
+
* @returns A Promise that resolves to the updated City entity.
|
|
57
|
+
*/
|
|
58
|
+
updateByState(countryCode: string, stateCode: string, cityName: string, data: any, params?: Record<string, any>): Promise<CityEntity>;
|
|
59
|
+
/**
|
|
60
|
+
* Deletes a city (nested under country/state).
|
|
61
|
+
* @param countryCode - The country code.
|
|
62
|
+
* @param stateCode - The state code.
|
|
63
|
+
* @param cityName - The city name.
|
|
64
|
+
* @param params - Optional query parameters.
|
|
65
|
+
* @returns A Promise that resolves when the city is deleted.
|
|
66
|
+
*/
|
|
67
|
+
deleteByState(countryCode: string, stateCode: string, cityName: string, params?: Record<string, any>): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Searches cities by name (autocomplete).
|
|
70
|
+
* @param query - The search query.
|
|
71
|
+
* @param options - Optional filters (countryCode, stateCode).
|
|
72
|
+
* @returns A Promise that resolves to a list of matching City entities.
|
|
73
|
+
*/
|
|
74
|
+
search(query: string, options?: {
|
|
75
|
+
countryCode?: string;
|
|
76
|
+
stateCode?: string;
|
|
77
|
+
}): Promise<CityEntity[]>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository } from './repository.js';
|
|
3
|
+
import { CountryEntity } from '../../core/entities/country.js';
|
|
4
|
+
/**
|
|
5
|
+
* Repository for managing Country entities.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CountryRepository extends ModelRepository<CountryEntity, any, any> {
|
|
8
|
+
/**
|
|
9
|
+
* Constructs a new CountryRepository instance.
|
|
10
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
11
|
+
*/
|
|
12
|
+
constructor(client: AxiosInstance);
|
|
13
|
+
/**
|
|
14
|
+
* Finds a country by its code (ID is the country code).
|
|
15
|
+
* @param code - The country code (ISO 3166-1 alpha-2).
|
|
16
|
+
* @param params - Optional query parameters.
|
|
17
|
+
* @returns A Promise that resolves to the found Country entity.
|
|
18
|
+
*/
|
|
19
|
+
findByCode(code: string, params?: Record<string, any>): Promise<CountryEntity>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository, ModelCreateOptions } from './repository.js';
|
|
3
|
+
import { ShippingPriceEntity } from '../../core/entities/shipping_price.js';
|
|
4
|
+
/**
|
|
5
|
+
* Repository for managing ShippingPrice entities.
|
|
6
|
+
*
|
|
7
|
+
* ShippingPrice is the new geo-based shipping system that replaces
|
|
8
|
+
* the legacy array-based ShippingMethod rates.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ShippingPriceRepository extends ModelRepository<ShippingPriceEntity, any, any> {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new ShippingPriceRepository instance.
|
|
13
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
14
|
+
*/
|
|
15
|
+
constructor(client: AxiosInstance);
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new ShippingPrice entity.
|
|
18
|
+
* @param options The options for creating the ShippingPrice entity.
|
|
19
|
+
* @returns A Promise that resolves to the created ShippingPrice entity.
|
|
20
|
+
*/
|
|
21
|
+
create(options: ModelCreateOptions<any>): Promise<ShippingPriceEntity>;
|
|
22
|
+
/**
|
|
23
|
+
* Finds a ShippingPrice by store ID.
|
|
24
|
+
* @param storeId The store ID to search for.
|
|
25
|
+
* @returns A Promise that resolves to the ShippingPrice entities for the store.
|
|
26
|
+
*/
|
|
27
|
+
listByStore(storeId: string): Promise<ShippingPriceEntity[]>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository, ModelListOptions } from './repository.js';
|
|
3
|
+
import { StateEntity } from '../../core/entities/state.js';
|
|
4
|
+
/**
|
|
5
|
+
* Repository for managing State entities.
|
|
6
|
+
* States have composite keys (countryCode + code) and can be nested under countries.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StateRepository extends ModelRepository<StateEntity, any, any> {
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new StateRepository instance.
|
|
11
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
12
|
+
*/
|
|
13
|
+
constructor(client: AxiosInstance);
|
|
14
|
+
/**
|
|
15
|
+
* Lists states, optionally filtered by country code.
|
|
16
|
+
* @param options - The options for listing states, including countryCode filter.
|
|
17
|
+
* @returns A Promise that resolves to a list of State entities.
|
|
18
|
+
*/
|
|
19
|
+
list(options?: ModelListOptions & {
|
|
20
|
+
countryCode?: string;
|
|
21
|
+
}): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Lists states for a specific country (nested route).
|
|
24
|
+
* @param countryCode - The country code.
|
|
25
|
+
* @param options - Optional list options.
|
|
26
|
+
* @returns A Promise that resolves to a list of State entities.
|
|
27
|
+
*/
|
|
28
|
+
listByCountry(countryCode: string, options?: ModelListOptions): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Finds a state by country code and state code.
|
|
31
|
+
* @param countryCode - The country code.
|
|
32
|
+
* @param stateCode - The state code.
|
|
33
|
+
* @param params - Optional query parameters.
|
|
34
|
+
* @returns A Promise that resolves to the found State entity.
|
|
35
|
+
*/
|
|
36
|
+
findByCode(countryCode: string, stateCode: string, params?: Record<string, any>): Promise<StateEntity>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new state (nested under country).
|
|
39
|
+
* @param countryCode - The country code.
|
|
40
|
+
* @param data - The state data.
|
|
41
|
+
* @param params - Optional query parameters.
|
|
42
|
+
* @returns A Promise that resolves to the created State entity.
|
|
43
|
+
*/
|
|
44
|
+
createByCountry(countryCode: string, data: any, params?: Record<string, any>): Promise<StateEntity>;
|
|
45
|
+
/**
|
|
46
|
+
* Updates a state (nested under country).
|
|
47
|
+
* @param countryCode - The country code.
|
|
48
|
+
* @param stateCode - The state code.
|
|
49
|
+
* @param data - The update data.
|
|
50
|
+
* @param params - Optional query parameters.
|
|
51
|
+
* @returns A Promise that resolves to the updated State entity.
|
|
52
|
+
*/
|
|
53
|
+
updateByCountry(countryCode: string, stateCode: string, data: any, params?: Record<string, any>): Promise<StateEntity>;
|
|
54
|
+
/**
|
|
55
|
+
* Deletes a state (nested under country).
|
|
56
|
+
* @param countryCode - The country code.
|
|
57
|
+
* @param stateCode - The state code.
|
|
58
|
+
* @param params - Optional query parameters.
|
|
59
|
+
* @returns A Promise that resolves when the state is deleted.
|
|
60
|
+
*/
|
|
61
|
+
deleteByCountry(countryCode: string, stateCode: string, params?: Record<string, any>): Promise<void>;
|
|
62
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ShippingType } from '../../core/entities/order.js';
|
|
2
2
|
import { ProductEntity, ProductOffer } from '../../core/entities/product.js';
|
|
3
3
|
import { ShippingMethodEntity } from '../../core/entities/shipping_method.js';
|
|
4
|
+
import { ShippingPriceEntity } from '../../core/entities/shipping_price.js';
|
|
4
5
|
import { StoreEntity } from '../../core/entities/store.js';
|
|
5
6
|
import { NotifiableService } from './service.js';
|
|
6
7
|
/**
|
|
@@ -37,6 +38,8 @@ export interface CartShippingAddress {
|
|
|
37
38
|
export declare class CartService extends NotifiableService {
|
|
38
39
|
private items;
|
|
39
40
|
private shippingMethod;
|
|
41
|
+
private shippingPrice;
|
|
42
|
+
private store;
|
|
40
43
|
private shippingAddress;
|
|
41
44
|
private cachedSubtotal;
|
|
42
45
|
private currentItem;
|
|
@@ -187,11 +190,48 @@ export declare class CartService extends NotifiableService {
|
|
|
187
190
|
*/
|
|
188
191
|
setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify?: boolean): void;
|
|
189
192
|
/**
|
|
190
|
-
*
|
|
193
|
+
* Sets the shipping price (new system).
|
|
194
|
+
* @param shippingPrice - The shipping price entity.
|
|
195
|
+
* @param notify - Whether to notify listeners.
|
|
196
|
+
*/
|
|
197
|
+
setShippingPrice(shippingPrice: ShippingPriceEntity | null, notify?: boolean): void;
|
|
198
|
+
/**
|
|
199
|
+
* Sets the store entity.
|
|
200
|
+
* @param store - The store entity.
|
|
201
|
+
* @param notify - Whether to notify listeners.
|
|
202
|
+
*/
|
|
203
|
+
setStore(store: StoreEntity | null, notify?: boolean): void;
|
|
204
|
+
/**
|
|
205
|
+
* Maps ShippingType enum to ShippingPriceType string.
|
|
206
|
+
* @param shippingType - The shipping type enum.
|
|
207
|
+
* @returns The corresponding shipping price type.
|
|
208
|
+
*/
|
|
209
|
+
private mapShippingTypeToPriceType;
|
|
210
|
+
/**
|
|
211
|
+
* Resolves shipping price using the priority chain.
|
|
212
|
+
* Priority: 1. Product shippingPriceId, 2. Store shippingPriceId, 3. Product shippingMethodId, 4. Store defaultShippingRates
|
|
213
|
+
*
|
|
214
|
+
* Note: Shipping prices must be loaded and set via setShippingPrice() for the new system to work.
|
|
215
|
+
* If shipping prices are not loaded, the method falls back to the legacy system.
|
|
216
|
+
*
|
|
217
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (optional, required for new system)
|
|
218
|
+
* @param stateCode - State/province code
|
|
219
|
+
* @param shippingType - The shipping type
|
|
220
|
+
* @returns The shipping price or null if not available
|
|
221
|
+
*/
|
|
222
|
+
private resolveShippingPrice;
|
|
223
|
+
/**
|
|
224
|
+
* Gets shipping price using legacy system (array-based rates).
|
|
225
|
+
* @param type - The shipping type
|
|
226
|
+
* @returns The shipping price or null if not available
|
|
227
|
+
*/
|
|
228
|
+
private getShippingPriceForTypeLegacy;
|
|
229
|
+
/**
|
|
230
|
+
* Retrieves the available shipping types using the priority chain.
|
|
231
|
+
* Priority: 1. Product shippingPriceId, 2. Store shippingPriceId, 3. Product shippingMethodId, 4. Store defaultShippingRates
|
|
191
232
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* if the fee value is 0, then it's free shipping, and if it's null, then it's not available
|
|
233
|
+
* Note: Shipping prices must be loaded and set via setShippingPrice() for the new system to work.
|
|
234
|
+
* If shipping prices are not loaded, the method falls back to the legacy system.
|
|
195
235
|
*
|
|
196
236
|
* @returns An array of available shipping types.
|
|
197
237
|
*/
|
|
@@ -217,7 +257,8 @@ export declare class CartService extends NotifiableService {
|
|
|
217
257
|
*/
|
|
218
258
|
getShippingPrice(): number;
|
|
219
259
|
/**
|
|
220
|
-
* Gets the shipping price for a specific shipping type using the
|
|
260
|
+
* Gets the shipping price for a specific shipping type using the priority chain.
|
|
261
|
+
* Priority: 1. Product shippingPriceId, 2. Store shippingPriceId, 3. Product shippingMethodId, 4. Store defaultShippingRates
|
|
221
262
|
* @param type - The shipping type to check (pickup, home, store)
|
|
222
263
|
* @returns The shipping price for the specified type, or null if not available
|
|
223
264
|
*/
|
package/build/src/index.d.ts
CHANGED
|
@@ -4,8 +4,13 @@ export * from './core/entities/store.js';
|
|
|
4
4
|
export * from './core/entities/product.js';
|
|
5
5
|
export * from './core/entities/user.js';
|
|
6
6
|
export * from './core/entities/shipping_method.js';
|
|
7
|
+
export * from './core/entities/shipping_price.js';
|
|
7
8
|
export * from './core/entities/category.js';
|
|
9
|
+
export * from './core/entities/country.js';
|
|
10
|
+
export * from './core/entities/state.js';
|
|
11
|
+
export * from './core/entities/city.js';
|
|
8
12
|
export * from './feeef/repositories/deposits.js';
|
|
13
|
+
export * from './feeef/repositories/shipping_prices.js';
|
|
9
14
|
export * from './core/embadded/address.js';
|
|
10
15
|
export * from './core/embadded/category.js';
|
|
11
16
|
export * from './core/embadded/contact.js';
|