@explorins/pers-sdk 1.6.4 → 1.6.9
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 +86 -342
- 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 -3
- 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 -447
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +1 -446
- 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-Bd6BZHgt.js +5672 -0
- package/dist/chunks/pers-sdk-Bd6BZHgt.js.map +1 -0
- package/dist/chunks/pers-sdk-CmyPEhy7.cjs +5705 -0
- package/dist/chunks/pers-sdk-CmyPEhy7.cjs.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-D75TcHkh.cjs} +28 -53
- package/dist/chunks/web3-chain-service-D75TcHkh.cjs.map +1 -0
- package/dist/chunks/{index-CM21r58m.js → web3-chain-service-Dp5Z8p9I.js} +28 -51
- package/dist/chunks/web3-chain-service-Dp5Z8p9I.js.map +1 -0
- package/dist/core/auth/api/auth-api.d.ts +11 -14
- package/dist/core/auth/api/auth-api.d.ts.map +1 -1
- package/dist/core/auth/auth-provider.interface.d.ts +36 -68
- package/dist/core/auth/auth-provider.interface.d.ts.map +1 -1
- package/dist/core/auth/default-auth-provider.d.ts +13 -59
- package/dist/core/auth/default-auth-provider.d.ts.map +1 -1
- package/dist/core/auth/index.d.ts +8 -14
- package/dist/core/auth/index.d.ts.map +1 -1
- package/dist/core/auth/refresh-manager.d.ts +15 -0
- package/dist/core/auth/refresh-manager.d.ts.map +1 -0
- package/dist/core/auth/services/auth-service.d.ts +15 -21
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/auth/token-storage.d.ts +26 -48
- package/dist/core/auth/token-storage.d.ts.map +1 -1
- package/dist/core/environment.d.ts +2 -4
- package/dist/core/environment.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 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts +14 -156
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +13 -12
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core/utils/jwt.function.d.ts +9 -0
- package/dist/core/utils/jwt.function.d.ts.map +1 -1
- package/dist/core.cjs +22 -18
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +13 -14
- package/dist/core.js.map +1 -1
- 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 +50 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -15
- 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 +10 -4
- 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 -6
- package/dist/web3-chain.cjs.map +1 -1
- package/dist/web3-chain.js +2 -2
- 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 +10 -4
- 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,41 +1,173 @@
|
|
|
1
1
|
import { PersApiClient } from '../core/pers-api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { UserService } from '../user';
|
|
3
|
+
import { UserPublicProfileDTO } from '../user/models';
|
|
3
4
|
import type { UserDTO, UserCreateRequestDTO } from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
4
5
|
/**
|
|
5
6
|
* User Manager - Clean, high-level interface for user operations
|
|
6
7
|
*
|
|
7
|
-
* Provides a simplified API for common user management tasks
|
|
8
|
-
*
|
|
8
|
+
* Provides a simplified API for common user management tasks including profile
|
|
9
|
+
* management, user lookup, and administrative operations. Maintains access to
|
|
10
|
+
* the full user SDK for advanced use cases.
|
|
11
|
+
*
|
|
12
|
+
* @group Managers
|
|
13
|
+
* @category User Management
|
|
14
|
+
*
|
|
15
|
+
* @example Basic User Operations
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Get current user
|
|
18
|
+
* const user = await sdk.users.getCurrentUser();
|
|
19
|
+
*
|
|
20
|
+
* // Update current user profile
|
|
21
|
+
* const updated = await sdk.users.updateCurrentUser({
|
|
22
|
+
* name: 'New Name',
|
|
23
|
+
* email: 'new@email.com'
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Get user by ID
|
|
27
|
+
* const specificUser = await sdk.users.getUserById('user-123');
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Public User Data
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Get all users' public profiles
|
|
33
|
+
* const publicProfiles = await sdk.users.getAllUsersPublic();
|
|
34
|
+
*
|
|
35
|
+
* // Get users with filter
|
|
36
|
+
* const filteredUsers = await sdk.users.getAllUsersPublic({
|
|
37
|
+
* key: 'city',
|
|
38
|
+
* value: 'New York'
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example Administrative Operations
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Admin: Get all users (full data)
|
|
45
|
+
* const allUsers = await sdk.users.getAllUsers();
|
|
46
|
+
*
|
|
47
|
+
* // Admin: Update any user
|
|
48
|
+
* const updated = await sdk.users.updateUser('user-123', {
|
|
49
|
+
* name: 'Updated Name'
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Admin: Toggle user status
|
|
53
|
+
* await sdk.users.toggleUserStatus(user);
|
|
54
|
+
* ```
|
|
9
55
|
*/
|
|
10
56
|
export declare class UserManager {
|
|
11
57
|
private apiClient;
|
|
12
|
-
private
|
|
58
|
+
private userService;
|
|
13
59
|
constructor(apiClient: PersApiClient);
|
|
14
60
|
/**
|
|
15
61
|
* Get current user profile
|
|
16
62
|
*
|
|
17
|
-
*
|
|
63
|
+
* Retrieves the complete profile of the currently authenticated user.
|
|
64
|
+
* Requires valid authentication tokens.
|
|
65
|
+
*
|
|
66
|
+
* @returns Promise resolving to current user data with full profile information
|
|
67
|
+
* @throws {PersApiError} When user is not authenticated
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* try {
|
|
72
|
+
* const user = await sdk.users.getCurrentUser();
|
|
73
|
+
* console.log('Current user:', user.name, user.email);
|
|
74
|
+
* console.log('User ID:', user.id);
|
|
75
|
+
* console.log('Registration date:', user.createdAt);
|
|
76
|
+
* } catch (error) {
|
|
77
|
+
* console.log('User not authenticated');
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
18
80
|
*/
|
|
19
81
|
getCurrentUser(): Promise<UserDTO>;
|
|
20
82
|
/**
|
|
21
83
|
* Update current user profile
|
|
22
84
|
*
|
|
23
|
-
*
|
|
85
|
+
* Updates the profile information for the currently authenticated user.
|
|
86
|
+
* Only the provided fields will be updated; omitted fields remain unchanged.
|
|
87
|
+
*
|
|
88
|
+
* @param userData - User data to update (partial update supported)
|
|
24
89
|
* @returns Promise resolving to updated user data
|
|
90
|
+
* @throws {PersApiError} When user is not authenticated or validation fails
|
|
91
|
+
*
|
|
92
|
+
* @example Basic Profile Update
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const updated = await sdk.users.updateCurrentUser({
|
|
95
|
+
* name: 'John Smith',
|
|
96
|
+
* email: 'john.smith@example.com'
|
|
97
|
+
* });
|
|
98
|
+
* console.log('Profile updated:', updated.name);
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @example Partial Update
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // Only update the name, keep other fields unchanged
|
|
104
|
+
* const updated = await sdk.users.updateCurrentUser({
|
|
105
|
+
* name: 'New Display Name'
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
25
108
|
*/
|
|
26
109
|
updateCurrentUser(userData: UserCreateRequestDTO): Promise<UserDTO>;
|
|
27
110
|
/**
|
|
28
111
|
* Get user by unique identifier
|
|
29
112
|
*
|
|
30
|
-
*
|
|
113
|
+
* Retrieves a user's profile using their unique identifier. This method
|
|
114
|
+
* requires appropriate permissions (admin or specific access rights).
|
|
115
|
+
*
|
|
116
|
+
* @param identifier - Unique identifier for the user (user ID, email, etc.)
|
|
31
117
|
* @returns Promise resolving to user data
|
|
118
|
+
* @throws {PersApiError} When user not found or insufficient permissions
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* try {
|
|
123
|
+
* const user = await sdk.users.getUserById('user-123');
|
|
124
|
+
* console.log('Found user:', user.name);
|
|
125
|
+
* } catch (error) {
|
|
126
|
+
* if (error.statusCode === 404) {
|
|
127
|
+
* console.log('User not found');
|
|
128
|
+
* } else if (error.statusCode === 403) {
|
|
129
|
+
* console.log('Access denied');
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
32
133
|
*/
|
|
33
134
|
getUserById(identifier: string): Promise<UserDTO>;
|
|
34
135
|
/**
|
|
35
136
|
* Get all users public profiles with optional filtering
|
|
36
137
|
*
|
|
37
|
-
*
|
|
138
|
+
* Retrieves public profile information for all users. This data is limited
|
|
139
|
+
* to publicly viewable fields only (name, profile picture, etc.).
|
|
140
|
+
*
|
|
141
|
+
* @param filter - Optional filter criteria to narrow results
|
|
142
|
+
* @param filter.key - Field name to filter by
|
|
143
|
+
* @param filter.value - Value to match for the specified field
|
|
38
144
|
* @returns Promise resolving to array of user public profiles
|
|
145
|
+
*
|
|
146
|
+
* @example Get All Public Profiles
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const publicProfiles = await sdk.users.getAllUsersPublic();
|
|
149
|
+
* console.log(`Found ${publicProfiles.length} users`);
|
|
150
|
+
*
|
|
151
|
+
* publicProfiles.forEach(profile => {
|
|
152
|
+
* console.log('User:', profile.name);
|
|
153
|
+
* // Note: Only public fields are available
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @example Filtered Search
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // Get users from a specific city
|
|
160
|
+
* const cityUsers = await sdk.users.getAllUsersPublic({
|
|
161
|
+
* key: 'city',
|
|
162
|
+
* value: 'San Francisco'
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* // Get users with specific role
|
|
166
|
+
* const roleUsers = await sdk.users.getAllUsersPublic({
|
|
167
|
+
* key: 'role',
|
|
168
|
+
* value: 'premium'
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
39
171
|
*/
|
|
40
172
|
getAllUsersPublic(filter?: {
|
|
41
173
|
key: string;
|
|
@@ -44,29 +176,99 @@ export declare class UserManager {
|
|
|
44
176
|
/**
|
|
45
177
|
* Admin: Get all users
|
|
46
178
|
*
|
|
47
|
-
*
|
|
179
|
+
* Retrieves complete user data for all users in the system. This method
|
|
180
|
+
* requires administrator privileges and returns full user profiles including
|
|
181
|
+
* private information.
|
|
182
|
+
*
|
|
183
|
+
* @returns Promise resolving to array of all users with complete data
|
|
184
|
+
* @throws {PersApiError} When not authenticated as admin
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* // Admin operation - requires admin authentication
|
|
189
|
+
* try {
|
|
190
|
+
* const allUsers = await sdk.users.getAllUsers();
|
|
191
|
+
* console.log(`Total users: ${allUsers.length}`);
|
|
192
|
+
*
|
|
193
|
+
* allUsers.forEach(user => {
|
|
194
|
+
* console.log(`${user.name} - ${user.email} - Active: ${user.isActive}`);
|
|
195
|
+
* });
|
|
196
|
+
* } catch (error) {
|
|
197
|
+
* console.log('Admin access required');
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
48
200
|
*/
|
|
49
201
|
getAllUsers(): Promise<UserDTO[]>;
|
|
50
202
|
/**
|
|
51
203
|
* Admin: Update user data
|
|
52
204
|
*
|
|
205
|
+
* Updates profile information for any user in the system. This method
|
|
206
|
+
* requires administrator privileges and can modify any user's profile.
|
|
207
|
+
*
|
|
53
208
|
* @param userId - ID of user to update
|
|
54
|
-
* @param userData - User data to update
|
|
209
|
+
* @param userData - User data to update (partial update supported)
|
|
55
210
|
* @returns Promise resolving to updated user data
|
|
211
|
+
* @throws {PersApiError} When not authenticated as admin or user not found
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* // Admin operation - update any user's profile
|
|
216
|
+
* try {
|
|
217
|
+
* const updated = await sdk.users.updateUser('user-123', {
|
|
218
|
+
* name: 'Updated Name',
|
|
219
|
+
* isActive: true
|
|
220
|
+
* });
|
|
221
|
+
* console.log('User updated:', updated.name);
|
|
222
|
+
* } catch (error) {
|
|
223
|
+
* console.log('Failed to update user:', error.message);
|
|
224
|
+
* }
|
|
225
|
+
* ```
|
|
56
226
|
*/
|
|
57
227
|
updateUser(userId: string, userData: UserCreateRequestDTO): Promise<UserDTO>;
|
|
58
228
|
/**
|
|
59
229
|
* Admin: Toggle user active status
|
|
60
230
|
*
|
|
61
|
-
*
|
|
231
|
+
* Toggles the active/inactive status of a user account. This is typically
|
|
232
|
+
* used for account suspension or reactivation. Requires administrator privileges.
|
|
233
|
+
*
|
|
234
|
+
* @param user - User object to toggle status for
|
|
62
235
|
* @returns Promise resolving to updated user data
|
|
236
|
+
* @throws {PersApiError} When not authenticated as admin
|
|
237
|
+
*
|
|
238
|
+
* @example Suspend User
|
|
239
|
+
* ```typescript
|
|
240
|
+
* // Admin operation - toggle user status
|
|
241
|
+
* try {
|
|
242
|
+
* const user = await sdk.users.getUserById('problematic-user-123');
|
|
243
|
+
* const updated = await sdk.users.toggleUserStatus(user);
|
|
244
|
+
*
|
|
245
|
+
* if (updated.isActive) {
|
|
246
|
+
* console.log('User account reactivated');
|
|
247
|
+
* } else {
|
|
248
|
+
* console.log('User account suspended');
|
|
249
|
+
* }
|
|
250
|
+
* } catch (error) {
|
|
251
|
+
* console.log('Failed to update user status');
|
|
252
|
+
* }
|
|
253
|
+
* ```
|
|
63
254
|
*/
|
|
64
255
|
toggleUserStatus(user: UserDTO): Promise<UserDTO>;
|
|
65
256
|
/**
|
|
66
|
-
* Get the
|
|
257
|
+
* Get the user service for advanced operations
|
|
258
|
+
*
|
|
259
|
+
* Provides access to the complete UserService instance for advanced operations
|
|
260
|
+
* not covered by the high-level manager methods.
|
|
261
|
+
*
|
|
262
|
+
* @returns UserService instance with full API access
|
|
263
|
+
*
|
|
264
|
+
* @example Advanced Operations
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const userService = sdk.users.getUserService();
|
|
67
267
|
*
|
|
68
|
-
*
|
|
268
|
+
* // Access advanced user operations
|
|
269
|
+
* const advancedResult = await userService.someAdvancedMethod();
|
|
270
|
+
* ```
|
|
69
271
|
*/
|
|
70
|
-
|
|
272
|
+
getUserService(): UserService;
|
|
71
273
|
}
|
|
72
274
|
//# sourceMappingURL=user-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-manager.d.ts","sourceRoot":"","sources":["../../src/managers/user-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"user-manager.d.ts","sourceRoot":"","sources":["../../src/managers/user-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAW,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,qBAAa,WAAW;IAGV,OAAO,CAAC,SAAS;IAF7B,OAAO,CAAC,WAAW,CAAc;gBAEb,SAAS,EAAE,aAAa;IAK5C;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,iBAAiB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACG,iBAAiB,CAAC,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAIjG;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvD;;;;;;;;;;;;;;;OAeG;IACH,cAAc,IAAI,WAAW;CAI9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PersApiClient } from '../core/pers-api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { Web3ApplicationService } from '../web3';
|
|
3
3
|
import type { TokenBalanceRequest, TokenCollectionRequest, TokenBalance, TokenCollection, TokenMetadata } from '../web3/application/web3-application.service';
|
|
4
4
|
import type { ChainData } from '../web3-chain';
|
|
5
5
|
/**
|
|
@@ -10,8 +10,8 @@ import type { ChainData } from '../web3-chain';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class Web3Manager {
|
|
12
12
|
private apiClient;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
13
|
+
private web3ApplicationService;
|
|
14
|
+
private web3ChainService;
|
|
15
15
|
constructor(apiClient: PersApiClient);
|
|
16
16
|
/**
|
|
17
17
|
* Get token balance for a specific token
|
|
@@ -71,6 +71,6 @@ export declare class Web3Manager {
|
|
|
71
71
|
*
|
|
72
72
|
* @returns Web3SDK instance
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
getWeb3ApplicationService(): Web3ApplicationService;
|
|
75
75
|
}
|
|
76
76
|
//# sourceMappingURL=web3-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web3-manager.d.ts","sourceRoot":"","sources":["../../src/managers/web3-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"web3-manager.d.ts","sourceRoot":"","sources":["../../src/managers/web3-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAyE,MAAM,SAAS,CAAC;AAExH,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,aAAa,EACd,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,WAAW;IAIV,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,sBAAsB,CAAyB;IACvD,OAAO,CAAC,gBAAgB,CAAmB;gBAEvB,SAAS,EAAE,aAAa;IAW5C;;;;;OAKG;IACG,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAI1E;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAInF;;;;;OAKG;IACG,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IAInF;;;;;;OAMG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInE;;;;;;OAMG;IACG,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAI/F;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAIlE;;;;;;;OAOG;IACG,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,GAAG,IAAI,GACrB,OAAO,CAAC,MAAM,CAAC;IASlB;;;;OAIG;IACH,yBAAyB,IAAI,sBAAsB;CAGpD"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@explorins/pers-sdk",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.9",
|
|
4
4
|
"description": "Platform-agnostic SDK for PERS (Phygital Experience Rewards System) - Core business logic and API integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -110,15 +110,19 @@
|
|
|
110
110
|
"build": "rollup -c",
|
|
111
111
|
"build:watch": "rollup -c --watch",
|
|
112
112
|
"clean": "rimraf dist",
|
|
113
|
+
"docs": "typedoc",
|
|
114
|
+
"docs:dev": "typedoc --watch",
|
|
115
|
+
"docs:json": "typedoc --json docs/api.json",
|
|
116
|
+
"docs:serve": "npx http-server docs -p 8080",
|
|
113
117
|
"test": "jest",
|
|
114
118
|
"test:watch": "jest --watch",
|
|
115
119
|
"lint": "eslint src/**/*.ts",
|
|
116
120
|
"prepublishOnly": "npm run clean && npm run build",
|
|
117
|
-
"publish-version": "npm run clean && npm run build && npm version patch && npm publish"
|
|
121
|
+
"publish-version": "npm run clean && npm run build && npm version patch && npm publish",
|
|
122
|
+
"publish-with-docs": "npm run clean && npm run build && npm run docs && npm version patch && npm publish"
|
|
118
123
|
},
|
|
119
124
|
"dependencies": {
|
|
120
|
-
"@explorins/web3-ts": "^0.3.75"
|
|
121
|
-
"jwt-decode": "^4.0.0"
|
|
125
|
+
"@explorins/web3-ts": "^0.3.75"
|
|
122
126
|
},
|
|
123
127
|
"devDependencies": {
|
|
124
128
|
"@explorins/pers-shared": "^2.1.40",
|
|
@@ -131,6 +135,8 @@
|
|
|
131
135
|
"rimraf": "^5.0.5",
|
|
132
136
|
"rollup": "^4.50.0",
|
|
133
137
|
"rollup-plugin-copy": "^3.5.0",
|
|
138
|
+
"typedoc": "^0.25.13",
|
|
139
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
134
140
|
"typescript": "^5.4.5"
|
|
135
141
|
},
|
|
136
142
|
"peerDependencies": {
|
package/dist/payment/index.d.ts
CHANGED
|
@@ -12,25 +12,4 @@ export { PaymentService } from './services/payment-service';
|
|
|
12
12
|
export * from './models';
|
|
13
13
|
export * from '../shared/interfaces/pers-shared-lib.interfaces';
|
|
14
14
|
export * from './models';
|
|
15
|
-
import { PersApiClient } from '../core/pers-api-client';
|
|
16
|
-
import { PaymentApi } from './api/payment-api';
|
|
17
|
-
import { PurchaseCurrency } from './models';
|
|
18
|
-
import { PaymentService } from './services/payment-service';
|
|
19
|
-
/**
|
|
20
|
-
* Create a complete Payment SDK instance
|
|
21
|
-
*
|
|
22
|
-
* @param apiClient - Configured PERS API client
|
|
23
|
-
* @returns Payment SDK with flattened structure for better DX
|
|
24
|
-
*/
|
|
25
|
-
export declare function createPaymentSDK(apiClient: PersApiClient): {
|
|
26
|
-
getActivePurchaseTokens: (active?: boolean) => Promise<import("@explorins/pers-shared").PurchaseTokenDTO[]>;
|
|
27
|
-
createPaymentIntent: (amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string) => Promise<import("@explorins/pers-shared").PaymentIntentDTO>;
|
|
28
|
-
updatePaymentIntent: (paymentIntentId: string, amount: number, currency: PurchaseCurrency, receiptEmail: string, description: string) => Promise<import("@explorins/pers-shared").PaymentIntentDTO>;
|
|
29
|
-
cancelPaymentIntent: (paymentIntentId: string) => Promise<import("@explorins/pers-shared").PaymentIntentDTO>;
|
|
30
|
-
createPurchase: (paymentIntentId: string, amount: number, purchaseTokenId?: string, donationTypeId?: number, donationAccountAddress?: string) => Promise<import("@explorins/pers-shared").PurchaseDTO>;
|
|
31
|
-
getAllUserPurchases: () => Promise<import("@explorins/pers-shared").PurchaseDTO[]>;
|
|
32
|
-
api: PaymentApi;
|
|
33
|
-
service: PaymentService;
|
|
34
|
-
};
|
|
35
|
-
export type PaymentSDK = ReturnType<typeof createPaymentSDK>;
|
|
36
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,cAAc,UAAU,CAAC;AACzB,cAAc,iDAAiD,CAAC;AAGhE,cAAc,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,cAAc,UAAU,CAAC;AACzB,cAAc,iDAAiD,CAAC;AAGhE,cAAc,UAAU,CAAC"}
|
package/dist/payment.cjs
CHANGED
|
@@ -1,264 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var paymentService = require('./chunks/payment-service-B4qx0qiE.cjs');
|
|
3
4
|
var persShared = require('@explorins/pers-shared');
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Platform-Agnostic Purchase API Client (RESTful Architecture)
|
|
7
|
-
*
|
|
8
|
-
* Handles purchase and payment operations using the PERS backend's new RESTful endpoints.
|
|
9
|
-
* Uses @explorins/pers-shared DTOs for consistency with backend.
|
|
10
|
-
*
|
|
11
|
-
* Migration Status: Updated to match /purchases controller (replaces /purchase endpoints)
|
|
12
|
-
*
|
|
13
|
-
* Available Access Levels:
|
|
14
|
-
* - PUBLIC: Project key authentication for catalog browsing and payment operations
|
|
15
|
-
* - USER: Requires user authentication JWT (purchase creation, history access)
|
|
16
|
-
* - ADMIN: Requires tenant admin privileges (not implemented in this client)
|
|
17
|
-
*
|
|
18
|
-
* Note: This SDK focuses on backend purchase operations only.
|
|
19
|
-
* Payment provider integrations (Stripe, etc.) should remain in infrastructure layer.
|
|
20
|
-
*/
|
|
21
|
-
class PurchaseApi {
|
|
22
|
-
constructor(apiClient) {
|
|
23
|
-
this.apiClient = apiClient;
|
|
24
|
-
this.basePath = '/purchases';
|
|
25
|
-
}
|
|
26
|
-
// ==========================================
|
|
27
|
-
// PUBLIC OPERATIONS (Project Key)
|
|
28
|
-
// ==========================================
|
|
29
|
-
/**
|
|
30
|
-
* PUBLIC: Get purchase tokens (Intelligent Access)
|
|
31
|
-
*
|
|
32
|
-
* RESTful endpoint: GET /purchases/tokens
|
|
33
|
-
* Replaces: GET /purchase/token
|
|
34
|
-
*
|
|
35
|
-
* INTELLIGENT ACCESS:
|
|
36
|
-
* - PUBLIC (Project Key): Returns active tokens only (active parameter ignored)
|
|
37
|
-
* - ADMIN (Tenant Admin JWT): Returns filtered results based on active parameter
|
|
38
|
-
*/
|
|
39
|
-
async getPurchaseTokens(active) {
|
|
40
|
-
let url = `${this.basePath}/tokens`;
|
|
41
|
-
if (active !== undefined) {
|
|
42
|
-
url += `?active=${active}`;
|
|
43
|
-
}
|
|
44
|
-
return this.apiClient.get(url);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* PUBLIC: Get donation types
|
|
48
|
-
*
|
|
49
|
-
* RESTful endpoint: GET /purchases/donation-types
|
|
50
|
-
* Replaces: GET /purchase/donation/type
|
|
51
|
-
*/
|
|
52
|
-
async getDonationTypes() {
|
|
53
|
-
return this.apiClient.get(`${this.basePath}/donation-types`);
|
|
54
|
-
}
|
|
55
|
-
// ==========================================
|
|
56
|
-
// PAYMENT OPERATIONS (FINANCIAL - CRITICAL)
|
|
57
|
-
// ==========================================
|
|
58
|
-
/**
|
|
59
|
-
* PUBLIC: Create payment intent (FINANCIAL OPERATION)
|
|
60
|
-
*
|
|
61
|
-
* RESTful endpoint: POST /purchases/payment-intents
|
|
62
|
-
* Replaces: POST /purchase/payment-intent
|
|
63
|
-
*
|
|
64
|
-
* CRITICAL: Handles real money operations - tenant context required
|
|
65
|
-
*/
|
|
66
|
-
async createPaymentIntent(amount, currency, receiptEmail, description) {
|
|
67
|
-
const body = {
|
|
68
|
-
amount,
|
|
69
|
-
currency,
|
|
70
|
-
receiptEmail,
|
|
71
|
-
description
|
|
72
|
-
};
|
|
73
|
-
return this.apiClient.post(`${this.basePath}/payment-intents`, body);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* PUBLIC: Update payment intent (FINANCIAL OPERATION)
|
|
77
|
-
*
|
|
78
|
-
* RESTful endpoint: PUT /purchases/payment-intents/{paymentIntentId}
|
|
79
|
-
* Replaces: PUT /purchase/payment-intent/{paymentIntentId}
|
|
80
|
-
*
|
|
81
|
-
* CRITICAL: Handles real money operations - tenant context required
|
|
82
|
-
*/
|
|
83
|
-
async updatePaymentIntent(paymentIntentId, amount, currency, receiptEmail, description) {
|
|
84
|
-
const body = {
|
|
85
|
-
amount,
|
|
86
|
-
currency,
|
|
87
|
-
receiptEmail,
|
|
88
|
-
description
|
|
89
|
-
};
|
|
90
|
-
return this.apiClient.put(`${this.basePath}/payment-intents/${paymentIntentId}`, body);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* PUBLIC: Cancel payment intent (FINANCIAL OPERATION)
|
|
94
|
-
*
|
|
95
|
-
* RESTful endpoint: DELETE /purchases/payment-intents/{paymentIntentId}
|
|
96
|
-
* Replaces: DELETE /purchase/payment-intent/{paymentIntentId}
|
|
97
|
-
*
|
|
98
|
-
* CRITICAL: Handles real money operations - tenant context required
|
|
99
|
-
*/
|
|
100
|
-
async cancelPaymentIntent(paymentIntentId) {
|
|
101
|
-
return this.apiClient.delete(`${this.basePath}/payment-intents/${paymentIntentId}`);
|
|
102
|
-
}
|
|
103
|
-
// ==========================================
|
|
104
|
-
// USER OPERATIONS (JWT + Project Key)
|
|
105
|
-
// ==========================================
|
|
106
|
-
/**
|
|
107
|
-
* USER: Create purchase (BUSINESS CRITICAL - FINANCIAL TRANSACTION)
|
|
108
|
-
*
|
|
109
|
-
* RESTful endpoint: POST /purchases
|
|
110
|
-
* Replaces: POST /purchase/auth
|
|
111
|
-
*
|
|
112
|
-
* USER-ONLY: Requires user authentication JWT for purchase creation
|
|
113
|
-
* CRITICAL: Real financial transaction with Stripe integration
|
|
114
|
-
*/
|
|
115
|
-
async createUserPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress) {
|
|
116
|
-
const body = {
|
|
117
|
-
quantity: amount,
|
|
118
|
-
purchaseTokenId: purchaseTokenId || '',
|
|
119
|
-
donationTypeId,
|
|
120
|
-
donationAccountAddress,
|
|
121
|
-
paymentIntentId
|
|
122
|
-
};
|
|
123
|
-
return this.apiClient.post(`${this.basePath}`, body);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* USER: Get user purchase history
|
|
127
|
-
*
|
|
128
|
-
* RESTful endpoint: GET /purchases/me/history
|
|
129
|
-
* Replaces: GET /purchase/auth
|
|
130
|
-
*
|
|
131
|
-
* USER-ONLY: Get authenticated user's purchase history
|
|
132
|
-
* FINANCIAL RECORDS: User attribution critical for compliance
|
|
133
|
-
*/
|
|
134
|
-
async getUserPurchaseHistory() {
|
|
135
|
-
return this.apiClient.get(`${this.basePath}/me/history`);
|
|
136
|
-
}
|
|
137
|
-
// ==========================================
|
|
138
|
-
// CONVENIENCE METHODS (Backward Compatibility)
|
|
139
|
-
// ==========================================
|
|
140
|
-
/**
|
|
141
|
-
* @deprecated Use getPurchaseTokens() instead
|
|
142
|
-
* Backward compatibility alias for getActivePurchaseTokens
|
|
143
|
-
*/
|
|
144
|
-
async getActivePurchaseTokens(active = true) {
|
|
145
|
-
return this.getPurchaseTokens(active);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated Use createUserPurchase() instead
|
|
149
|
-
* Backward compatibility alias for createPurchase
|
|
150
|
-
*/
|
|
151
|
-
async createPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress) {
|
|
152
|
-
return this.createUserPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated Use getUserPurchaseHistory() instead
|
|
156
|
-
* Backward compatibility alias for getAllUserPurchases
|
|
157
|
-
*/
|
|
158
|
-
async getAllUserPurchases() {
|
|
159
|
-
return this.getUserPurchaseHistory();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
6
|
|
|
163
|
-
/**
|
|
164
|
-
* Platform-Agnostic Payment Service
|
|
165
|
-
*
|
|
166
|
-
* Contains payment business logic and operations that work across platforms.
|
|
167
|
-
* No framework dependencies - pure TypeScript business logic.
|
|
168
|
-
*
|
|
169
|
-
* Focuses only on actual backend capabilities.
|
|
170
|
-
* Payment provider logic (Stripe, etc.) should remain in infrastructure layer.
|
|
171
|
-
*/
|
|
172
|
-
class PaymentService {
|
|
173
|
-
constructor(paymentApi) {
|
|
174
|
-
this.paymentApi = paymentApi;
|
|
175
|
-
}
|
|
176
|
-
// ==========================================
|
|
177
|
-
// PUBLIC OPERATIONS
|
|
178
|
-
// ==========================================
|
|
179
|
-
/**
|
|
180
|
-
* PUBLIC: Get active purchase tokens
|
|
181
|
-
*/
|
|
182
|
-
async getActivePurchaseTokens(active = true) {
|
|
183
|
-
return this.paymentApi.getActivePurchaseTokens(active);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* PUBLIC: Create payment intent
|
|
187
|
-
*/
|
|
188
|
-
async createPaymentIntent(amount, currency, receiptEmail, description) {
|
|
189
|
-
return this.paymentApi.createPaymentIntent(amount, currency, receiptEmail, description);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* PUBLIC: Update payment intent
|
|
193
|
-
*/
|
|
194
|
-
async updatePaymentIntent(paymentIntentId, amount, currency, receiptEmail, description) {
|
|
195
|
-
return this.paymentApi.updatePaymentIntent(paymentIntentId, amount, currency, receiptEmail, description);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* PUBLIC: Cancel payment intent
|
|
199
|
-
*/
|
|
200
|
-
async cancelPaymentIntent(paymentIntentId) {
|
|
201
|
-
return this.paymentApi.cancelPaymentIntent(paymentIntentId);
|
|
202
|
-
}
|
|
203
|
-
// ==========================================
|
|
204
|
-
// AUTHENTICATED OPERATIONS
|
|
205
|
-
// ==========================================
|
|
206
|
-
/**
|
|
207
|
-
* AUTH: Create purchase
|
|
208
|
-
*/
|
|
209
|
-
async createPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress) {
|
|
210
|
-
return this.paymentApi.createPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* AUTH: Get all user purchases
|
|
214
|
-
*/
|
|
215
|
-
async getAllUserPurchases() {
|
|
216
|
-
return this.paymentApi.getAllUserPurchases();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @explorins/pers-sdk-payment
|
|
222
|
-
*
|
|
223
|
-
* Platform-agnostic Payment Domain SDK for PERS ecosystem
|
|
224
|
-
* Handles payment intents, purchases, and purchase tokens
|
|
225
|
-
*
|
|
226
|
-
* Note: Payment provider integrations (Stripe, etc.) are kept separate
|
|
227
|
-
* in the infrastructure layer to maintain platform-agnostic principles.
|
|
228
|
-
*/
|
|
229
|
-
// API Layer
|
|
230
|
-
/**
|
|
231
|
-
* Create a complete Payment SDK instance
|
|
232
|
-
*
|
|
233
|
-
* @param apiClient - Configured PERS API client
|
|
234
|
-
* @returns Payment SDK with flattened structure for better DX
|
|
235
|
-
*/
|
|
236
|
-
function createPaymentSDK(apiClient) {
|
|
237
|
-
const paymentApi = new PurchaseApi(apiClient);
|
|
238
|
-
const paymentService = new PaymentService(paymentApi);
|
|
239
|
-
return {
|
|
240
|
-
// Direct access to service methods (primary interface)
|
|
241
|
-
// Public methods
|
|
242
|
-
getActivePurchaseTokens: (active) => paymentService.getActivePurchaseTokens(active),
|
|
243
|
-
// ✅ FIXED: Proper type instead of any
|
|
244
|
-
createPaymentIntent: (amount, currency, receiptEmail, description) => paymentService.createPaymentIntent(amount, currency, receiptEmail, description),
|
|
245
|
-
// ✅ FIXED: Proper type instead of any
|
|
246
|
-
updatePaymentIntent: (paymentIntentId, amount, currency, receiptEmail, description) => paymentService.updatePaymentIntent(paymentIntentId, amount, currency, receiptEmail, description),
|
|
247
|
-
cancelPaymentIntent: (paymentIntentId) => paymentService.cancelPaymentIntent(paymentIntentId),
|
|
248
|
-
// Auth methods
|
|
249
|
-
createPurchase: (paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress) => paymentService.createPurchase(paymentIntentId, amount, purchaseTokenId, donationTypeId, donationAccountAddress),
|
|
250
|
-
getAllUserPurchases: () => paymentService.getAllUserPurchases(),
|
|
251
|
-
// Advanced access for edge cases
|
|
252
|
-
api: paymentApi,
|
|
253
|
-
service: paymentService
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
7
|
|
|
8
|
+
exports.PaymentApi = paymentService.PurchaseApi;
|
|
9
|
+
exports.PaymentService = paymentService.PaymentService;
|
|
257
10
|
Object.defineProperty(exports, "AccountOwnerType", {
|
|
258
|
-
|
|
259
|
-
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return persShared.AccountOwnerType; }
|
|
260
13
|
});
|
|
261
|
-
exports.PaymentApi = PurchaseApi;
|
|
262
|
-
exports.PaymentService = PaymentService;
|
|
263
|
-
exports.createPaymentSDK = createPaymentSDK;
|
|
264
14
|
//# sourceMappingURL=payment.cjs.map
|