feeef 0.5.38-dev.2 → 0.5.38-dev.4
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 +897 -42
- 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/currency.d.ts +21 -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/core/entities/user.d.ts +155 -0
- package/build/src/feeef/feeef.d.ts +30 -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/currencies.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/repositories/transfers.d.ts +38 -0
- package/build/src/feeef/repositories/users.d.ts +124 -12
- package/build/src/feeef/services/cart.d.ts +46 -5
- package/build/src/index.d.ts +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository } from './repository.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a transfer entity for double-entry accounting transactions
|
|
5
|
+
*/
|
|
6
|
+
export interface TransferEntity {
|
|
7
|
+
id: string;
|
|
8
|
+
debitAccountId: string;
|
|
9
|
+
creditAccountId: string;
|
|
10
|
+
amount: number;
|
|
11
|
+
type: 'deposit' | 'subscription' | 'points' | 'store_due' | 'user_transfer' | 'ai_generation' | 'refund' | 'adjustment';
|
|
12
|
+
referenceId?: string | null;
|
|
13
|
+
description?: string | null;
|
|
14
|
+
metadata: Record<string, any>;
|
|
15
|
+
createdAt: any;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Input data for creating a new transfer
|
|
19
|
+
*/
|
|
20
|
+
export interface TransferCreateInput {
|
|
21
|
+
debitAccountId: string;
|
|
22
|
+
creditAccountId: string;
|
|
23
|
+
amount: number;
|
|
24
|
+
type: TransferEntity['type'];
|
|
25
|
+
referenceId?: string | null;
|
|
26
|
+
description?: string | null;
|
|
27
|
+
metadata?: Record<string, any>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Repository for managing transfer data
|
|
31
|
+
*/
|
|
32
|
+
export declare class TransferRepository extends ModelRepository<TransferEntity, TransferCreateInput, any> {
|
|
33
|
+
/**
|
|
34
|
+
* Constructs a new TransferRepository instance
|
|
35
|
+
* @param client - The AxiosInstance used for making HTTP requests
|
|
36
|
+
*/
|
|
37
|
+
constructor(client: AxiosInstance);
|
|
38
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { ModelRepository } from './repository.js';
|
|
3
|
-
import { AuthToken, UserEntity } from '../../core/entities/user.js';
|
|
3
|
+
import { AccessToken, AuthToken, CreateUserOptions, FinishPasskeyAuthenticationOptions, FinishPasskeyRegistrationOptions, LinkSocialAccountOptions, Passkey, SigninCredentials, SigninWithSocialOptions, SignupCredentials, TransferMoneyOptions, TransferMoneyResponse, UpdateUserOptions, UserEntity, UserUpdate, StartPasskeyAuthenticationOptions, StartPasskeyRegistrationOptions } from '../../core/entities/user.js';
|
|
4
4
|
/**
|
|
5
5
|
* Represents the response returned by the authentication process.
|
|
6
6
|
*/
|
|
@@ -9,14 +9,23 @@ export interface AuthResponse {
|
|
|
9
9
|
user: UserEntity;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Represents a repository for managing user data.
|
|
13
|
-
* Extends the ModelRepository class.
|
|
12
|
+
* Represents a repository for managing user data and authentication.
|
|
13
|
+
* Extends the ModelRepository class with authentication capabilities.
|
|
14
14
|
*/
|
|
15
|
-
export declare class UserRepository extends ModelRepository<UserEntity,
|
|
15
|
+
export declare class UserRepository extends ModelRepository<UserEntity, CreateUserOptions, UpdateUserOptions> {
|
|
16
16
|
/**
|
|
17
|
-
* Represents the authentication response.
|
|
17
|
+
* Represents the current authentication response.
|
|
18
|
+
* Set automatically after signin, signup, or signinWithToken.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
private _auth;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the current authentication response.
|
|
23
|
+
*/
|
|
24
|
+
get auth(): AuthResponse | null;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the authentication response and updates the Authorization header.
|
|
27
|
+
*/
|
|
28
|
+
private set auth(value);
|
|
20
29
|
/**
|
|
21
30
|
* Constructs a new UserRepository instance.
|
|
22
31
|
* @param client - The AxiosInstance used for making HTTP requests.
|
|
@@ -24,25 +33,128 @@ export declare class UserRepository extends ModelRepository<UserEntity, any, any
|
|
|
24
33
|
constructor(client: AxiosInstance);
|
|
25
34
|
/**
|
|
26
35
|
* Signs in a user with the provided credentials.
|
|
27
|
-
* @param credentials - The user credentials.
|
|
36
|
+
* @param credentials - The user credentials (email, password, optional fcmToken).
|
|
28
37
|
* @returns A promise that resolves to the authentication response.
|
|
29
38
|
*/
|
|
30
|
-
signin(credentials:
|
|
39
|
+
signin(credentials: SigninCredentials): Promise<AuthResponse>;
|
|
31
40
|
/**
|
|
32
41
|
* Signs up a new user with the provided credentials.
|
|
33
|
-
* @param credentials - The user credentials.
|
|
42
|
+
* @param credentials - The user signup credentials.
|
|
43
|
+
* @returns A promise that resolves to the authentication response.
|
|
44
|
+
*/
|
|
45
|
+
signup(credentials: SignupCredentials): Promise<AuthResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Signs in a user with an existing token.
|
|
48
|
+
* Useful for restoring authentication state from localStorage.
|
|
49
|
+
* @param token - The authentication token.
|
|
50
|
+
* @param fcmToken - Optional FCM token for push notifications.
|
|
34
51
|
* @returns A promise that resolves to the authentication response.
|
|
35
52
|
*/
|
|
36
|
-
|
|
53
|
+
signinWithToken(token: string, fcmToken?: string | null): Promise<AuthResponse>;
|
|
37
54
|
/**
|
|
38
55
|
* Signs out the currently authenticated user.
|
|
56
|
+
* Deletes the token on the server and clears local auth state.
|
|
39
57
|
* @returns A promise that resolves when the user is signed out.
|
|
40
58
|
*/
|
|
41
59
|
signout(): Promise<void>;
|
|
42
60
|
/**
|
|
43
|
-
*
|
|
61
|
+
* Gets the currently authenticated user.
|
|
62
|
+
* @returns A promise that resolves to the authentication response with current user.
|
|
63
|
+
*/
|
|
64
|
+
me(): Promise<AuthResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Updates the authenticated user's profile.
|
|
44
67
|
* @param data - The updated user data.
|
|
45
68
|
* @returns A promise that resolves to the updated user entity.
|
|
46
69
|
*/
|
|
47
|
-
updateMe(data:
|
|
70
|
+
updateMe(data: UserUpdate): Promise<UserEntity>;
|
|
71
|
+
/**
|
|
72
|
+
* Sends a password reset email to the user.
|
|
73
|
+
* @param email - The user's email address.
|
|
74
|
+
* @returns A promise that resolves when the email is sent.
|
|
75
|
+
*/
|
|
76
|
+
sendResetPasswordEmail(email: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Resets the password using a token from the reset email.
|
|
79
|
+
* @param uid - The user ID.
|
|
80
|
+
* @param token - The reset token from the email.
|
|
81
|
+
* @returns A promise that resolves when the password is reset.
|
|
82
|
+
*/
|
|
83
|
+
resetPasswordWithToken(uid: string, token: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Gets all access tokens for the authenticated user.
|
|
86
|
+
* @returns A promise that resolves to an array of access tokens.
|
|
87
|
+
*/
|
|
88
|
+
tokens(): Promise<AccessToken[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Signs in with Google OAuth.
|
|
91
|
+
* @param options - The OAuth code and optional FCM token.
|
|
92
|
+
* @returns A promise that resolves to the authentication response.
|
|
93
|
+
*/
|
|
94
|
+
signinWithGoogle(options: SigninWithSocialOptions): Promise<AuthResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Signs in with GitHub OAuth.
|
|
97
|
+
* @param options - The OAuth code and optional FCM token.
|
|
98
|
+
* @returns A promise that resolves to the authentication response.
|
|
99
|
+
*/
|
|
100
|
+
signinWithGitHub(options: SigninWithSocialOptions): Promise<AuthResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Signs in with Apple OAuth.
|
|
103
|
+
* @param options - The OAuth code and optional FCM token.
|
|
104
|
+
* @returns A promise that resolves to the authentication response.
|
|
105
|
+
*/
|
|
106
|
+
signinWithApple(options: SigninWithSocialOptions): Promise<AuthResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Links a social account to the current user.
|
|
109
|
+
* @param options - The provider and OAuth code.
|
|
110
|
+
* @returns A promise that resolves to the updated user entity.
|
|
111
|
+
*/
|
|
112
|
+
linkSocialAccount(options: LinkSocialAccountOptions): Promise<UserEntity>;
|
|
113
|
+
/**
|
|
114
|
+
* Unlinks a social account from the current user.
|
|
115
|
+
* @param provider - The social provider to unlink.
|
|
116
|
+
* @returns A promise that resolves to the updated user entity.
|
|
117
|
+
*/
|
|
118
|
+
unlinkSocialAccount(provider: 'google' | 'github' | 'apple'): Promise<UserEntity>;
|
|
119
|
+
/**
|
|
120
|
+
* Transfers money from the authenticated user to another user.
|
|
121
|
+
* @param options - Transfer options including recipient and amount.
|
|
122
|
+
* @returns A promise that resolves to the transfer response with updated users.
|
|
123
|
+
*/
|
|
124
|
+
transferMoney(options: TransferMoneyOptions): Promise<TransferMoneyResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Starts passkey registration.
|
|
127
|
+
* @param options - Optional device name for the passkey.
|
|
128
|
+
* @returns A promise that resolves to the registration challenge data.
|
|
129
|
+
*/
|
|
130
|
+
startPasskeyRegistration(options?: StartPasskeyRegistrationOptions): Promise<Record<string, any>>;
|
|
131
|
+
/**
|
|
132
|
+
* Finishes passkey registration.
|
|
133
|
+
* @param options - The registration response from the authenticator.
|
|
134
|
+
* @returns A promise that resolves to the authentication response.
|
|
135
|
+
*/
|
|
136
|
+
finishPasskeyRegistration(options: FinishPasskeyRegistrationOptions): Promise<AuthResponse>;
|
|
137
|
+
/**
|
|
138
|
+
* Starts passkey authentication.
|
|
139
|
+
* @param options - Optional email to identify the user.
|
|
140
|
+
* @returns A promise that resolves to the authentication challenge data.
|
|
141
|
+
*/
|
|
142
|
+
startPasskeyAuthentication(options?: StartPasskeyAuthenticationOptions): Promise<Record<string, any>>;
|
|
143
|
+
/**
|
|
144
|
+
* Finishes passkey authentication.
|
|
145
|
+
* @param options - The authentication response from the authenticator.
|
|
146
|
+
* @returns A promise that resolves to the authentication response.
|
|
147
|
+
*/
|
|
148
|
+
finishPasskeyAuthentication(options: FinishPasskeyAuthenticationOptions): Promise<AuthResponse>;
|
|
149
|
+
/**
|
|
150
|
+
* Lists all passkeys for the authenticated user.
|
|
151
|
+
* @returns A promise that resolves to an array of passkeys.
|
|
152
|
+
*/
|
|
153
|
+
listPasskeys(): Promise<Passkey[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Deletes a passkey.
|
|
156
|
+
* @param passkeyId - The ID of the passkey to delete.
|
|
157
|
+
* @returns A promise that resolves when the passkey is deleted.
|
|
158
|
+
*/
|
|
159
|
+
deletePasskey(passkeyId: string): Promise<void>;
|
|
48
160
|
}
|
|
@@ -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,18 @@ 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';
|
|
12
|
+
export * from './core/entities/currency.js';
|
|
8
13
|
export * from './feeef/repositories/deposits.js';
|
|
14
|
+
export * from './feeef/repositories/transfers.js';
|
|
15
|
+
export * from './feeef/repositories/shipping_prices.js';
|
|
16
|
+
export * from './feeef/repositories/users.js';
|
|
17
|
+
export type { TransferEntity, TransferCreateInput } from './feeef/repositories/transfers.js';
|
|
18
|
+
export type { DepositEntity, DepositCreateInput } from './feeef/repositories/deposits.js';
|
|
9
19
|
export * from './core/embadded/address.js';
|
|
10
20
|
export * from './core/embadded/category.js';
|
|
11
21
|
export * from './core/embadded/contact.js';
|