@explorins/pers-sdk 1.6.3 → 1.6.6
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/README.md +63 -37
- package/dist/analytics/index.d.ts +0 -16
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics.cjs +5 -73
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +1 -72
- package/dist/analytics.js.map +1 -1
- package/dist/business/index.d.ts +0 -24
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +5 -273
- package/dist/business.cjs.map +1 -1
- package/dist/business.js +1 -272
- package/dist/business.js.map +1 -1
- package/dist/campaign/api/campaign-api.d.ts +3 -13
- package/dist/campaign/api/campaign-api.d.ts.map +1 -1
- package/dist/campaign/index.d.ts +0 -34
- package/dist/campaign/index.d.ts.map +1 -1
- package/dist/campaign.cjs +5 -470
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +1 -469
- package/dist/campaign.js.map +1 -1
- package/dist/chunks/analytics-service-CitlimKJ.cjs +49 -0
- package/dist/chunks/analytics-service-CitlimKJ.cjs.map +1 -0
- package/dist/chunks/analytics-service-CxyrOwel.js +46 -0
- package/dist/chunks/analytics-service-CxyrOwel.js.map +1 -0
- package/dist/chunks/{token-sdk-BW4kkJb3.js → base-token-service-BSXDwrcq.js} +138 -204
- package/dist/chunks/base-token-service-BSXDwrcq.js.map +1 -0
- package/dist/chunks/{token-sdk-CiAbOb6c.cjs → base-token-service-CYuqPPs0.cjs} +140 -207
- package/dist/chunks/base-token-service-CYuqPPs0.cjs.map +1 -0
- package/dist/chunks/business-service-Cq3-oksM.cjs +241 -0
- package/dist/chunks/business-service-Cq3-oksM.cjs.map +1 -0
- package/dist/chunks/business-service-DrC-TNGa.js +238 -0
- package/dist/chunks/business-service-DrC-TNGa.js.map +1 -0
- package/dist/chunks/campaign-service-CWK9I388.cjs +403 -0
- package/dist/chunks/campaign-service-CWK9I388.cjs.map +1 -0
- package/dist/chunks/campaign-service-Dd7gMjC9.js +400 -0
- package/dist/chunks/campaign-service-Dd7gMjC9.js.map +1 -0
- package/dist/chunks/donation-service-CyJS4DIZ.js +47 -0
- package/dist/chunks/donation-service-CyJS4DIZ.js.map +1 -0
- package/dist/chunks/donation-service-D-xFrONi.cjs +50 -0
- package/dist/chunks/donation-service-D-xFrONi.cjs.map +1 -0
- package/dist/chunks/{index-CJ9Jfa4A.js → explorer.utils-Ckll15ja.js} +108 -172
- package/dist/chunks/explorer.utils-Ckll15ja.js.map +1 -0
- package/dist/chunks/{index-CzEluQmf.cjs → explorer.utils-GpskbLl1.cjs} +106 -174
- package/dist/chunks/explorer.utils-GpskbLl1.cjs.map +1 -0
- package/dist/chunks/index-BtDNXaFq.js +13 -0
- package/dist/chunks/index-BtDNXaFq.js.map +1 -0
- package/dist/chunks/index-CMk3Aqkk.cjs +15 -0
- package/dist/chunks/index-CMk3Aqkk.cjs.map +1 -0
- package/dist/chunks/payment-service-B4qx0qiE.cjs +220 -0
- package/dist/chunks/payment-service-B4qx0qiE.cjs.map +1 -0
- package/dist/chunks/payment-service-DfCBFosx.js +217 -0
- package/dist/chunks/payment-service-DfCBFosx.js.map +1 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs +5850 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs.map +1 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js +5817 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js.map +1 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs +330 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs.map +1 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js +327 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js.map +1 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs +171 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs.map +1 -0
- package/dist/chunks/tenant-service-DELk412y.js +168 -0
- package/dist/chunks/tenant-service-DELk412y.js.map +1 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs +208 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs.map +1 -0
- package/dist/chunks/token-service-CpVwC5Eb.js +205 -0
- package/dist/chunks/token-service-CpVwC5Eb.js.map +1 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs +153 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs.map +1 -0
- package/dist/chunks/user-service-D6mTa_WZ.js +150 -0
- package/dist/chunks/user-service-D6mTa_WZ.js.map +1 -0
- package/dist/chunks/{index-BfOoX87y.cjs → web3-chain-service-BYkj61DN.cjs} +1 -33
- package/dist/chunks/web3-chain-service-BYkj61DN.cjs.map +1 -0
- package/dist/chunks/{index-CM21r58m.js → web3-chain-service-DN6tJmvK.js} +2 -31
- package/dist/chunks/web3-chain-service-DN6tJmvK.js.map +1 -0
- package/dist/core/auth/auth-provider.interface.d.ts +32 -69
- package/dist/core/auth/auth-provider.interface.d.ts.map +1 -1
- package/dist/core/auth/default-auth-provider.d.ts +15 -58
- package/dist/core/auth/default-auth-provider.d.ts.map +1 -1
- package/dist/core/auth/index.d.ts +10 -12
- package/dist/core/auth/index.d.ts.map +1 -1
- package/dist/core/auth/refresh-manager.d.ts +18 -0
- package/dist/core/auth/refresh-manager.d.ts.map +1 -0
- package/dist/core/auth/services/auth-service.d.ts +11 -6
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/auth/token-storage.d.ts +27 -47
- package/dist/core/auth/token-storage.d.ts.map +1 -1
- package/dist/core/errors/index.d.ts +1 -5
- package/dist/core/errors/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts +10 -126
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +8 -3
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core/utils/jwt.function.d.ts.map +1 -1
- package/dist/core.cjs +22 -17
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +13 -13
- package/dist/donation/index.d.ts +0 -15
- package/dist/donation/index.d.ts.map +1 -1
- package/dist/donation.cjs +5 -75
- package/dist/donation.cjs.map +1 -1
- package/dist/donation.js +1 -74
- package/dist/donation.js.map +1 -1
- package/dist/index.cjs +51 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/managers/analytics-manager.d.ts +290 -10
- package/dist/managers/analytics-manager.d.ts.map +1 -1
- package/dist/managers/auth-manager.d.ts +123 -23
- package/dist/managers/auth-manager.d.ts.map +1 -1
- package/dist/managers/business-manager.d.ts +273 -18
- package/dist/managers/business-manager.d.ts.map +1 -1
- package/dist/managers/campaign-manager.d.ts +585 -46
- package/dist/managers/campaign-manager.d.ts.map +1 -1
- package/dist/managers/donation-manager.d.ts +5 -5
- package/dist/managers/donation-manager.d.ts.map +1 -1
- package/dist/managers/file-manager.d.ts +430 -13
- package/dist/managers/file-manager.d.ts.map +1 -1
- package/dist/managers/purchase-manager.d.ts +340 -15
- package/dist/managers/purchase-manager.d.ts.map +1 -1
- package/dist/managers/redemption-manager.d.ts +450 -27
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/tenant-manager.d.ts +5 -5
- package/dist/managers/tenant-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +245 -21
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/managers/transaction-manager.d.ts +447 -18
- package/dist/managers/transaction-manager.d.ts.map +1 -1
- package/dist/managers/user-manager.d.ts +216 -14
- package/dist/managers/user-manager.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts +4 -4
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/package.json +9 -2
- package/dist/payment/index.d.ts +0 -21
- package/dist/payment/index.d.ts.map +1 -1
- package/dist/payment.cjs +5 -255
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +1 -254
- package/dist/payment.js.map +1 -1
- package/dist/pers-sdk.d.ts +141 -34
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/redemption/index.d.ts +0 -25
- package/dist/redemption/index.d.ts.map +1 -1
- package/dist/redemption.cjs +5 -365
- package/dist/redemption.cjs.map +1 -1
- package/dist/redemption.js +1 -364
- package/dist/redemption.js.map +1 -1
- package/dist/tenant/index.d.ts +0 -22
- package/dist/tenant/index.d.ts.map +1 -1
- package/dist/tenant.cjs +5 -203
- package/dist/tenant.cjs.map +1 -1
- package/dist/tenant.js +1 -202
- package/dist/tenant.js.map +1 -1
- package/dist/token.cjs +6 -6
- package/dist/token.js +2 -2
- package/dist/transaction/index.d.ts +0 -22
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction.cjs +0 -40
- package/dist/transaction.cjs.map +1 -1
- package/dist/transaction.js +1 -40
- package/dist/transaction.js.map +1 -1
- package/dist/user/index.d.ts +0 -25
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user.cjs +5 -185
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +1 -184
- package/dist/user.js.map +1 -1
- package/dist/web3/index.d.ts +0 -11
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3-chain/index.d.ts +0 -9
- package/dist/web3-chain/index.d.ts.map +1 -1
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -1
- package/dist/web3-chain.cjs +5 -5
- package/dist/web3-chain.js +2 -1
- package/dist/web3-chain.js.map +1 -1
- package/dist/web3.cjs +6 -10
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +1 -4
- package/dist/web3.js.map +1 -1
- package/package.json +9 -2
- package/dist/chunks/base-token-service-D0KANDgM.js +0 -139
- package/dist/chunks/base-token-service-D0KANDgM.js.map +0 -1
- package/dist/chunks/base-token-service-zNfPjHRx.cjs +0 -141
- package/dist/chunks/base-token-service-zNfPjHRx.cjs.map +0 -1
- package/dist/chunks/index-BfOoX87y.cjs.map +0 -1
- package/dist/chunks/index-CJ9Jfa4A.js.map +0 -1
- package/dist/chunks/index-CM21r58m.js.map +0 -1
- package/dist/chunks/index-CzEluQmf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs +0 -3378
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-Z6MKeFBX.js +0 -3353
- package/dist/chunks/pers-sdk-Z6MKeFBX.js.map +0 -1
- package/dist/chunks/token-sdk-BW4kkJb3.js.map +0 -1
- package/dist/chunks/token-sdk-CiAbOb6c.cjs.map +0 -1
- package/dist/core/auth/auth-constants.d.ts +0 -33
- package/dist/core/auth/auth-constants.d.ts.map +0 -1
- package/dist/core/auth/auth-errors.d.ts +0 -8
- package/dist/core/auth/auth-errors.d.ts.map +0 -1
- package/dist/core/auth/create-auth-provider.d.ts +0 -27
- package/dist/core/auth/create-auth-provider.d.ts.map +0 -1
- package/dist/core/auth/token-refresh.d.ts +0 -91
- package/dist/core/auth/token-refresh.d.ts.map +0 -1
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import { PersApiClient } from '../core/pers-api-client';
|
|
2
2
|
import type { RawUserData } from '../core';
|
|
3
|
-
import type { UserDTO, SessionAuthContextResponseDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
3
|
+
import type { UserDTO, SessionAuthContextResponseDTO, SessionAuthResponseDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
4
4
|
/**
|
|
5
5
|
* Authentication Manager - Clean, high-level interface for authentication operations
|
|
6
6
|
*
|
|
7
7
|
* Provides a simplified API for common authentication tasks while maintaining
|
|
8
8
|
* access to the underlying API client for advanced use cases.
|
|
9
|
+
*
|
|
10
|
+
* @group Managers
|
|
11
|
+
* @category Authentication
|
|
12
|
+
*
|
|
13
|
+
* @example Basic Usage
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Login with external JWT
|
|
16
|
+
* const authResult = await sdk.auth.loginWithToken(firebaseJWT, 'user');
|
|
17
|
+
*
|
|
18
|
+
* // Check authentication
|
|
19
|
+
* if (await sdk.auth.isAuthenticated()) {
|
|
20
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
21
|
+
* console.log('Welcome,', user.name);
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* // Logout
|
|
25
|
+
* await sdk.auth.clearAuth();
|
|
26
|
+
* ```
|
|
9
27
|
*/
|
|
10
28
|
export declare class AuthManager {
|
|
11
29
|
private apiClient;
|
|
@@ -13,68 +31,150 @@ export declare class AuthManager {
|
|
|
13
31
|
/**
|
|
14
32
|
* Login with JWT token
|
|
15
33
|
*
|
|
34
|
+
* Authenticates a user or admin using an external JWT token (Firebase, Auth0, etc.).
|
|
35
|
+
* Automatically stores authentication tokens for subsequent API calls.
|
|
36
|
+
*
|
|
16
37
|
* @param jwtToken - JWT token to authenticate with
|
|
17
|
-
* @param userType - Type of user ('user' | 'admin')
|
|
18
|
-
* @returns Promise resolving to authentication response
|
|
38
|
+
* @param userType - Type of user ('user' | 'admin'). Defaults to 'user'
|
|
39
|
+
* @returns Promise resolving to authentication response with user/admin data and tokens
|
|
40
|
+
*
|
|
41
|
+
* @example User Login
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const authResult = await sdk.auth.loginWithToken(firebaseJWT);
|
|
44
|
+
* console.log('User authenticated:', authResult.user.name);
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example Admin Login
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const authResult = await sdk.auth.loginWithToken(adminJWT, 'admin');
|
|
50
|
+
* console.log('Admin authenticated:', authResult.admin.email);
|
|
51
|
+
* ```
|
|
19
52
|
*/
|
|
20
53
|
loginWithToken(jwtToken: string, userType?: 'user' | 'admin'): Promise<SessionAuthContextResponseDTO>;
|
|
21
54
|
/**
|
|
22
55
|
* Login with raw user data
|
|
23
56
|
*
|
|
57
|
+
* Authenticates using raw user data instead of a JWT token. Useful for
|
|
58
|
+
* direct integration without external authentication providers.
|
|
59
|
+
*
|
|
24
60
|
* @param rawUserData - Raw user data for authentication
|
|
25
61
|
* @returns Promise resolving to authentication response
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const authResult = await sdk.auth.loginWithRawData({
|
|
66
|
+
* email: 'user@example.com',
|
|
67
|
+
* name: 'John Doe',
|
|
68
|
+
* externalId: 'custom-user-id'
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
26
71
|
*/
|
|
27
72
|
loginWithRawData(rawUserData: RawUserData): Promise<SessionAuthContextResponseDTO>;
|
|
28
73
|
/**
|
|
29
74
|
* Get current authenticated user
|
|
30
75
|
*
|
|
76
|
+
* Retrieves the currently authenticated user's profile information.
|
|
77
|
+
* Requires valid authentication tokens.
|
|
78
|
+
*
|
|
31
79
|
* @returns Promise resolving to current user data
|
|
32
|
-
|
|
33
|
-
getCurrentUser(): Promise<UserDTO>;
|
|
34
|
-
/**
|
|
35
|
-
* Refresh current user data
|
|
80
|
+
* @throws {PersApiError} When user is not authenticated or tokens are invalid
|
|
36
81
|
*
|
|
37
|
-
* @
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* try {
|
|
85
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
86
|
+
* console.log('Current user:', user.name, user.email);
|
|
87
|
+
* } catch (error) {
|
|
88
|
+
* console.log('User not authenticated');
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
38
91
|
*/
|
|
39
|
-
|
|
92
|
+
getCurrentUser(): Promise<UserDTO>;
|
|
40
93
|
/**
|
|
41
94
|
* Check if user is authenticated
|
|
42
95
|
*
|
|
96
|
+
* Performs an asynchronous check to verify if the user is currently authenticated
|
|
97
|
+
* by attempting to fetch user data. More reliable than {@link hasValidAuth} but slower.
|
|
98
|
+
*
|
|
43
99
|
* @returns Promise resolving to boolean indicating authentication status
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* if (await sdk.auth.isAuthenticated()) {
|
|
104
|
+
* // User is authenticated, proceed with authenticated operations
|
|
105
|
+
* const user = await sdk.auth.getCurrentUser();
|
|
106
|
+
* } else {
|
|
107
|
+
* // Redirect to login
|
|
108
|
+
* redirectToLogin();
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @see {@link hasValidAuth} for synchronous token validation
|
|
44
113
|
*/
|
|
45
114
|
isAuthenticated(): Promise<boolean>;
|
|
46
115
|
/**
|
|
47
116
|
* Refresh access token using stored refresh token
|
|
48
117
|
*
|
|
118
|
+
* Obtains new access tokens using the stored refresh token. This is typically
|
|
119
|
+
* called automatically by the SDK when tokens expire, but can be called manually
|
|
120
|
+
* if needed.
|
|
121
|
+
*
|
|
49
122
|
* @param refreshToken - Optional refresh token, uses stored token if not provided
|
|
50
123
|
* @returns Promise resolving to new auth tokens
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* try {
|
|
128
|
+
* const newTokens = await sdk.auth.refreshTokens();
|
|
129
|
+
* console.log('Tokens refreshed successfully');
|
|
130
|
+
* } catch (error) {
|
|
131
|
+
* console.log('Refresh failed, need to re-login');
|
|
132
|
+
* await sdk.auth.clearAuth();
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
51
135
|
*/
|
|
52
|
-
refreshTokens(refreshToken?: string): Promise<
|
|
136
|
+
refreshTokens(refreshToken?: string): Promise<SessionAuthResponseDTO>;
|
|
53
137
|
/**
|
|
54
138
|
* Clear stored authentication tokens
|
|
55
139
|
*
|
|
140
|
+
* Removes all stored authentication tokens and clears the authentication state.
|
|
141
|
+
* Use this for logout functionality.
|
|
142
|
+
*
|
|
56
143
|
* @returns Promise that resolves when tokens are cleared
|
|
144
|
+
*
|
|
145
|
+
* @example Logout
|
|
146
|
+
* ```typescript
|
|
147
|
+
* async function logout() {
|
|
148
|
+
* await sdk.auth.clearAuth();
|
|
149
|
+
* console.log('User logged out');
|
|
150
|
+
* // Redirect to login page
|
|
151
|
+
* window.location.href = '/login';
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
57
154
|
*/
|
|
58
155
|
clearAuth(): Promise<void>;
|
|
59
156
|
/**
|
|
60
157
|
* Check if SDK has valid authentication
|
|
61
158
|
*
|
|
159
|
+
* Performs a synchronous check of stored authentication tokens without making
|
|
160
|
+
* an API call. Faster than {@link isAuthenticated} but less reliable as it
|
|
161
|
+
* doesn't verify tokens with the server.
|
|
162
|
+
*
|
|
62
163
|
* @returns Boolean indicating if valid authentication exists
|
|
63
|
-
*/
|
|
64
|
-
hasValidAuth(): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Admin login with JWT token
|
|
67
164
|
*
|
|
68
|
-
* @
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* if (sdk.auth.hasValidAuth()) {
|
|
168
|
+
* // Tokens exist locally, but may still be expired
|
|
169
|
+
* console.log('Authentication tokens found');
|
|
170
|
+
* } else {
|
|
171
|
+
* // No tokens found
|
|
172
|
+
* console.log('No authentication tokens');
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
74
175
|
*
|
|
75
|
-
* @
|
|
76
|
-
* @returns Promise resolving to authentication context
|
|
176
|
+
* @see {@link isAuthenticated} for server-verified authentication check
|
|
77
177
|
*/
|
|
78
|
-
|
|
178
|
+
hasValidAuth(): Promise<boolean>;
|
|
79
179
|
}
|
|
80
180
|
//# sourceMappingURL=auth-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/managers/auth-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/managers/auth-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAEtI;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAE5C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,OAAgB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAUnH;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAKxF;;;;;;;;;;;;;;;;;;OAkBG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAMxC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IASzC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,aAAa,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAK3E;;;;;;;;;;;;;;;;;OAiBG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;CAKvC"}
|
|
@@ -1,83 +1,338 @@
|
|
|
1
1
|
import { PersApiClient } from '../core/pers-api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { BusinessService } from '../business';
|
|
3
3
|
import type { BusinessDTO, BusinessTypeDTO, BusinessUpdateRequestDTO, BusinessToggleActiveRequestDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
4
4
|
/**
|
|
5
5
|
* Business Manager - Clean, high-level interface for business operations
|
|
6
6
|
*
|
|
7
|
-
* Provides a simplified API for
|
|
8
|
-
*
|
|
7
|
+
* Provides a simplified API for business directory management including retrieving
|
|
8
|
+
* active businesses, managing business types, and administrative operations for
|
|
9
|
+
* business creation and updates. Maintains access to the full business SDK
|
|
10
|
+
* for advanced partnership and integration features.
|
|
11
|
+
*
|
|
12
|
+
* @group Managers
|
|
13
|
+
* @category Business Management
|
|
14
|
+
*
|
|
15
|
+
* @example Basic Business Operations
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Get all active businesses in the network
|
|
18
|
+
* const businesses = await sdk.business.getActiveBusinesses();
|
|
19
|
+
* console.log(`Found ${businesses.length} active businesses`);
|
|
20
|
+
*
|
|
21
|
+
* // Get specific business details
|
|
22
|
+
* const business = await sdk.business.getBusinessById('business-123');
|
|
23
|
+
* console.log('Business:', business.displayName);
|
|
24
|
+
*
|
|
25
|
+
* // Search business by account address
|
|
26
|
+
* const partnerBusiness = await sdk.business.getBusinessByAccount('0x123...');
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Business Type Management
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Get all business categories/types
|
|
32
|
+
* const types = await sdk.business.getBusinessTypes();
|
|
33
|
+
*
|
|
34
|
+
* // Filter businesses by type
|
|
35
|
+
* const restaurants = await sdk.business.getBusinessesByType('restaurant-type-id');
|
|
36
|
+
*
|
|
37
|
+
* console.log('Restaurant partners:', restaurants.length);
|
|
38
|
+
* restaurants.forEach(restaurant => {
|
|
39
|
+
* console.log(`- ${restaurant.displayName}`);
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Administrative Operations
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Admin: Create new business partner
|
|
46
|
+
* const newBusiness = await sdk.business.createBusiness('New Partner Hotel');
|
|
47
|
+
*
|
|
48
|
+
* // Admin: Update business information
|
|
49
|
+
* await sdk.business.updateBusiness('business-123', {
|
|
50
|
+
* displayName: 'Updated Business Name',
|
|
51
|
+
* description: 'New business description',
|
|
52
|
+
* contactEmail: 'contact@business.com'
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Admin: Toggle business status
|
|
56
|
+
* await sdk.business.toggleBusinessStatus('business-123', { isActive: false });
|
|
57
|
+
* ```
|
|
9
58
|
*/
|
|
10
59
|
export declare class BusinessManager {
|
|
11
60
|
private apiClient;
|
|
12
|
-
private
|
|
61
|
+
private businessApi;
|
|
62
|
+
private businessService;
|
|
13
63
|
constructor(apiClient: PersApiClient);
|
|
14
64
|
/**
|
|
15
65
|
* Get all active businesses
|
|
16
66
|
*
|
|
17
|
-
*
|
|
67
|
+
* Retrieves all currently active businesses in the loyalty network.
|
|
68
|
+
* Active businesses are available for partnerships, campaigns, and transactions.
|
|
69
|
+
*
|
|
70
|
+
* @returns Promise resolving to array of active business data
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const activeBusinesses = await sdk.business.getActiveBusinesses();
|
|
75
|
+
*
|
|
76
|
+
* console.log('Active Business Partners:');
|
|
77
|
+
* activeBusinesses.forEach(business => {
|
|
78
|
+
* console.log(`- ${business.displayName}`);
|
|
79
|
+
* console.log(` Type: ${business.businessType?.name || 'N/A'}`);
|
|
80
|
+
* console.log(` Account: ${business.accountAddress}`);
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* // Use for partnership displays or campaign targeting
|
|
84
|
+
* const hotelPartners = activeBusinesses.filter(b =>
|
|
85
|
+
* b.businessType?.name?.toLowerCase().includes('hotel')
|
|
86
|
+
* );
|
|
87
|
+
* ```
|
|
18
88
|
*/
|
|
19
89
|
getActiveBusinesses(): Promise<BusinessDTO[]>;
|
|
20
90
|
/**
|
|
21
91
|
* Get business by ID
|
|
22
92
|
*
|
|
23
|
-
*
|
|
93
|
+
* Retrieves detailed information for a specific business using its unique identifier.
|
|
94
|
+
* Includes business profile, contact information, and partnership status.
|
|
95
|
+
*
|
|
96
|
+
* @param businessId - Unique business identifier
|
|
24
97
|
* @returns Promise resolving to business data
|
|
98
|
+
* @throws {PersApiError} When business with specified ID is not found
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* try {
|
|
103
|
+
* const business = await sdk.business.getBusinessById('partner-hotel-123');
|
|
104
|
+
*
|
|
105
|
+
* console.log('Business Details:');
|
|
106
|
+
* console.log('Name:', business.displayName);
|
|
107
|
+
* console.log('Description:', business.description);
|
|
108
|
+
* console.log('Contact:', business.contactEmail);
|
|
109
|
+
* console.log('Active:', business.isActive);
|
|
110
|
+
* console.log('Account Address:', business.accountAddress);
|
|
111
|
+
*
|
|
112
|
+
* } catch (error) {
|
|
113
|
+
* console.log('Business not found:', error.message);
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
25
116
|
*/
|
|
26
117
|
getBusinessById(businessId: string): Promise<BusinessDTO>;
|
|
27
118
|
/**
|
|
28
119
|
* Get business by account address
|
|
29
120
|
*
|
|
30
|
-
*
|
|
121
|
+
* Retrieves business information using the blockchain account address.
|
|
122
|
+
* Useful for Web3 integrations and blockchain transaction verification.
|
|
123
|
+
*
|
|
124
|
+
* @param accountAddress - Blockchain account address of the business
|
|
31
125
|
* @returns Promise resolving to business data
|
|
126
|
+
* @throws {PersApiError} When business with specified account address is not found
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* // Get business associated with blockchain address
|
|
131
|
+
* const business = await sdk.business.getBusinessByAccount('0x742d35Cc6634C0532925a3b8D94B309e32ad75c6');
|
|
132
|
+
*
|
|
133
|
+
* console.log('Business for address:', business.displayName);
|
|
134
|
+
* console.log('Verified partner:', business.isActive);
|
|
135
|
+
*
|
|
136
|
+
* // Use for transaction verification
|
|
137
|
+
* if (business.isActive) {
|
|
138
|
+
* console.log('✅ Verified business partner');
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
32
141
|
*/
|
|
33
142
|
getBusinessByAccount(accountAddress: string): Promise<BusinessDTO>;
|
|
34
143
|
/**
|
|
35
144
|
* Get all business types
|
|
36
145
|
*
|
|
37
|
-
*
|
|
146
|
+
* Retrieves all available business type categories and their configurations.
|
|
147
|
+
* Business types help classify partners and determine available features.
|
|
148
|
+
*
|
|
149
|
+
* @returns Promise resolving to array of business type definitions
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const businessTypes = await sdk.business.getBusinessTypes();
|
|
154
|
+
*
|
|
155
|
+
* console.log('Available Business Categories:');
|
|
156
|
+
* businessTypes.forEach(type => {
|
|
157
|
+
* console.log(`- ${type.name}: ${type.description}`);
|
|
158
|
+
* });
|
|
159
|
+
*
|
|
160
|
+
* // Use for business registration forms
|
|
161
|
+
* const typeOptions = businessTypes.map(type => ({
|
|
162
|
+
* value: type.id,
|
|
163
|
+
* label: type.name
|
|
164
|
+
* }));
|
|
165
|
+
* ```
|
|
38
166
|
*/
|
|
39
167
|
getBusinessTypes(): Promise<BusinessTypeDTO[]>;
|
|
40
168
|
/**
|
|
41
169
|
* Get businesses by type
|
|
42
170
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
171
|
+
* Retrieves all businesses that belong to a specific business type category.
|
|
172
|
+
* Useful for creating category-specific partner directories or targeted campaigns.
|
|
173
|
+
*
|
|
174
|
+
* @param typeId - Business type identifier to filter by
|
|
175
|
+
* @returns Promise resolving to array of businesses in the specified type
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // Get all restaurant partners
|
|
180
|
+
* const restaurants = await sdk.business.getBusinessesByType('restaurant-type-id');
|
|
181
|
+
*
|
|
182
|
+
* console.log(`Found ${restaurants.length} restaurant partners:`);
|
|
183
|
+
* restaurants.forEach(restaurant => {
|
|
184
|
+
* console.log(`- ${restaurant.displayName}`);
|
|
185
|
+
* if (restaurant.description) {
|
|
186
|
+
* console.log(` ${restaurant.description}`);
|
|
187
|
+
* }
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* // Use for category-specific campaigns
|
|
191
|
+
* const restaurantCampaign = {
|
|
192
|
+
* targetBusinesses: restaurants.map(r => r.id),
|
|
193
|
+
* category: 'Dining Rewards'
|
|
194
|
+
* };
|
|
195
|
+
* ```
|
|
45
196
|
*/
|
|
46
197
|
getBusinessesByType(typeId: string): Promise<BusinessDTO[]>;
|
|
47
198
|
/**
|
|
48
199
|
* Admin: Get all businesses (including inactive)
|
|
49
200
|
*
|
|
201
|
+
* Retrieves all businesses in the system regardless of active status.
|
|
202
|
+
* This operation requires administrator privileges and is used for
|
|
203
|
+
* comprehensive business management and reporting.
|
|
204
|
+
*
|
|
50
205
|
* @returns Promise resolving to array of all businesses
|
|
206
|
+
* @throws {PersApiError} When not authenticated as administrator
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* // Admin operation - get complete business directory
|
|
211
|
+
* const allBusinesses = await sdk.business.getBusinesses();
|
|
212
|
+
*
|
|
213
|
+
* const activeCount = allBusinesses.filter(b => b.isActive).length;
|
|
214
|
+
* const inactiveCount = allBusinesses.length - activeCount;
|
|
215
|
+
*
|
|
216
|
+
* console.log(`Total businesses: ${allBusinesses.length}`);
|
|
217
|
+
* console.log(`Active: ${activeCount}, Inactive: ${inactiveCount}`);
|
|
218
|
+
*
|
|
219
|
+
* // Generate business status report
|
|
220
|
+
* const statusReport = allBusinesses.map(business => ({
|
|
221
|
+
* name: business.displayName,
|
|
222
|
+
* status: business.isActive ? 'Active' : 'Inactive',
|
|
223
|
+
* type: business.businessType?.name || 'Unspecified'
|
|
224
|
+
* }));
|
|
225
|
+
* ```
|
|
51
226
|
*/
|
|
52
227
|
getBusinesses(): Promise<BusinessDTO[]>;
|
|
53
228
|
/**
|
|
54
229
|
* Admin: Create new business
|
|
55
230
|
*
|
|
56
|
-
*
|
|
231
|
+
* Creates a new business partner in the loyalty network. This operation
|
|
232
|
+
* requires administrator privileges and establishes a new business entity
|
|
233
|
+
* with a blockchain account and initial configuration.
|
|
234
|
+
*
|
|
235
|
+
* @param displayName - Display name for the new business
|
|
57
236
|
* @returns Promise resolving to created business data
|
|
237
|
+
* @throws {PersApiError} When not authenticated as admin or validation fails
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* // Admin operation - onboard new business partner
|
|
242
|
+
* const newBusiness = await sdk.business.createBusiness('Grand Palace Hotel');
|
|
243
|
+
*
|
|
244
|
+
* console.log('New business created:');
|
|
245
|
+
* console.log('ID:', newBusiness.id);
|
|
246
|
+
* console.log('Name:', newBusiness.displayName);
|
|
247
|
+
* console.log('Account Address:', newBusiness.accountAddress);
|
|
248
|
+
* console.log('Status:', newBusiness.isActive ? 'Active' : 'Pending');
|
|
249
|
+
*
|
|
250
|
+
* // Follow up with additional configuration
|
|
251
|
+
* await sdk.business.updateBusiness(newBusiness.id, {
|
|
252
|
+
* description: 'Luxury hotel in downtown area',
|
|
253
|
+
* contactEmail: 'partnerships@grandpalace.com',
|
|
254
|
+
* businessTypeId: 'hotel-type-id'
|
|
255
|
+
* });
|
|
256
|
+
* ```
|
|
58
257
|
*/
|
|
59
258
|
createBusiness(displayName: string): Promise<BusinessDTO>;
|
|
60
259
|
/**
|
|
61
260
|
* Admin: Update business
|
|
62
261
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
262
|
+
* Updates an existing business's information and configuration. This operation
|
|
263
|
+
* requires administrator privileges and can modify business profile data,
|
|
264
|
+
* contact information, and operational settings.
|
|
265
|
+
*
|
|
266
|
+
* @param businessId - ID of the business to update
|
|
267
|
+
* @param businessData - Business update data (partial updates supported)
|
|
65
268
|
* @returns Promise resolving to updated business data
|
|
269
|
+
* @throws {PersApiError} When not authenticated as admin or business not found
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* // Admin operation - update business profile
|
|
274
|
+
* const updated = await sdk.business.updateBusiness('business-123', {
|
|
275
|
+
* displayName: 'Grand Palace Hotel & Spa',
|
|
276
|
+
* description: 'Luxury hotel with spa services and conference facilities',
|
|
277
|
+
* contactEmail: 'partnerships@grandpalacespa.com',
|
|
278
|
+
* businessTypeId: 'hotel-spa-type-id'
|
|
279
|
+
* });
|
|
280
|
+
*
|
|
281
|
+
* console.log('Business updated:', updated.displayName);
|
|
282
|
+
* ```
|
|
66
283
|
*/
|
|
67
284
|
updateBusiness(businessId: string, businessData: BusinessUpdateRequestDTO): Promise<BusinessDTO>;
|
|
68
285
|
/**
|
|
69
286
|
* Admin: Toggle business active status
|
|
70
287
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
288
|
+
* Toggles the active/inactive status of a business partner. Inactive businesses
|
|
289
|
+
* are not available for new campaigns or transactions but existing relationships
|
|
290
|
+
* are preserved. Requires administrator privileges.
|
|
291
|
+
*
|
|
292
|
+
* @param businessId - ID of the business to toggle
|
|
293
|
+
* @param toggleData - Toggle request data specifying the desired active state
|
|
73
294
|
* @returns Promise resolving to updated business data
|
|
295
|
+
* @throws {PersApiError} When not authenticated as admin or business not found
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* // Admin operation - deactivate problematic business
|
|
300
|
+
* const updated = await sdk.business.toggleBusinessStatus('business-123', {
|
|
301
|
+
* isActive: false,
|
|
302
|
+
* reason: 'Temporary suspension for policy review'
|
|
303
|
+
* });
|
|
304
|
+
*
|
|
305
|
+
* if (updated.isActive) {
|
|
306
|
+
* console.log('Business reactivated');
|
|
307
|
+
* } else {
|
|
308
|
+
* console.log('Business temporarily deactivated');
|
|
309
|
+
* }
|
|
310
|
+
* ```
|
|
74
311
|
*/
|
|
75
|
-
|
|
312
|
+
toggleBusinessActive(businessId: string, toggleData: BusinessToggleActiveRequestDTO): Promise<BusinessDTO>;
|
|
76
313
|
/**
|
|
77
314
|
* Get the full business SDK for advanced operations
|
|
78
315
|
*
|
|
79
|
-
*
|
|
316
|
+
* Provides access to the complete BusinessSDK instance for advanced partnership
|
|
317
|
+
* operations, integration management, and operations not covered by the
|
|
318
|
+
* high-level manager methods.
|
|
319
|
+
*
|
|
320
|
+
* @returns BusinessSDK instance with full API access
|
|
321
|
+
*
|
|
322
|
+
* @example Advanced Operations
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const businessSDK = sdk.business.getBusinessSDK();
|
|
325
|
+
*
|
|
326
|
+
* // Access partnership management
|
|
327
|
+
* const partnerships = await businessSDK.getPartnershipAgreements();
|
|
328
|
+
*
|
|
329
|
+
* // Access integration features
|
|
330
|
+
* const integrationStatus = await businessSDK.getIntegrationStatus('business-123');
|
|
331
|
+
*
|
|
332
|
+
* // Access business API directly
|
|
333
|
+
* const businessApi = businessSDK.api;
|
|
334
|
+
* ```
|
|
80
335
|
*/
|
|
81
|
-
|
|
336
|
+
getBusinessService(): BusinessService;
|
|
82
337
|
}
|
|
83
338
|
//# sourceMappingURL=business-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business-manager.d.ts","sourceRoot":"","sources":["../../src/managers/business-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"business-manager.d.ts","sourceRoot":"","sources":["../../src/managers/business-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAe,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,wBAAwB,EACxB,8BAA8B,EAC/B,MAAM,iDAAiD,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,eAAe;IAId,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAkB;gBAErB,SAAS,EAAE,aAAa;IAK5C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,mBAAmB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAInD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI/D;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIxE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,gBAAgB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAIjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAI7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI/D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAItG;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,8BAA8B,GAAG,OAAO,CAAC,WAAW,CAAC;IAIhH;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBAAkB;CAInB"}
|