@explorins/pers-sdk 2.0.7 → 2.0.11
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 +113 -59
- package/dist/analytics/index.d.ts +0 -2
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics/models/index.d.ts +1 -10
- package/dist/analytics/models/index.d.ts.map +1 -1
- package/dist/analytics.cjs +44 -29
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +45 -2
- package/dist/analytics.js.map +1 -1
- package/dist/business/index.d.ts +0 -1
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +7 -774
- package/dist/business.cjs.map +1 -1
- package/dist/business.js +3 -751
- package/dist/business.js.map +1 -1
- package/dist/campaign/index.d.ts +0 -1
- package/dist/campaign/index.d.ts.map +1 -1
- package/dist/campaign.cjs +429 -29
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +431 -3
- package/dist/campaign.js.map +1 -1
- package/dist/chunks/business-membership-service-8KC_qRj7.cjs +756 -0
- package/dist/chunks/business-membership-service-8KC_qRj7.cjs.map +1 -0
- package/dist/chunks/business-membership-service-D6vaVQTR.js +751 -0
- package/dist/chunks/business-membership-service-D6vaVQTR.js.map +1 -0
- package/dist/chunks/{web3-chain-service-BeBjALg2.cjs → index-B-g2JPVK.cjs} +1 -220
- package/dist/chunks/index-B-g2JPVK.cjs.map +1 -0
- package/dist/chunks/{web3-chain-service-DKHCnHQX.js → index-CKm_V5XE.js} +2 -219
- package/dist/chunks/index-CKm_V5XE.js.map +1 -0
- package/dist/chunks/payment-service-Bkw7ZXev.cjs +214 -0
- package/dist/chunks/payment-service-Bkw7ZXev.cjs.map +1 -0
- package/dist/chunks/payment-service-IvM6rryM.js +211 -0
- package/dist/chunks/payment-service-IvM6rryM.js.map +1 -0
- package/dist/chunks/{pers-sdk-JIExM712.js → pers-sdk-DYnIZvcx.js} +12 -291
- package/dist/chunks/pers-sdk-DYnIZvcx.js.map +1 -0
- package/dist/chunks/{pers-sdk-h-uoLpBx.cjs → pers-sdk-Dr9W8stD.cjs} +38 -318
- package/dist/chunks/pers-sdk-Dr9W8stD.cjs.map +1 -0
- package/dist/chunks/redemption-service-D-hBqh42.js +339 -0
- package/dist/chunks/redemption-service-D-hBqh42.js.map +1 -0
- package/dist/chunks/redemption-service-rMB6T2W5.cjs +342 -0
- package/dist/chunks/redemption-service-rMB6T2W5.cjs.map +1 -0
- package/dist/chunks/tenant-service-CsRA3O2V.js +163 -0
- package/dist/chunks/tenant-service-CsRA3O2V.js.map +1 -0
- package/dist/chunks/tenant-service-fj-pkXTw.cjs +166 -0
- package/dist/chunks/tenant-service-fj-pkXTw.cjs.map +1 -0
- package/dist/chunks/{transaction-request.builder-DrqTWcyC.cjs → transaction-request.builder-BwWmfHXm.cjs} +6 -6
- package/dist/chunks/{transaction-request.builder-DrqTWcyC.cjs.map → transaction-request.builder-BwWmfHXm.cjs.map} +1 -1
- package/dist/chunks/{transaction-request.builder-DltmruUC.js → transaction-request.builder-C1FPWmYN.js} +6 -6
- package/dist/chunks/{transaction-request.builder-DltmruUC.js.map → transaction-request.builder-C1FPWmYN.js.map} +1 -1
- package/dist/chunks/web3-chain-service-D68-0WaW.cjs +224 -0
- package/dist/chunks/web3-chain-service-D68-0WaW.cjs.map +1 -0
- package/dist/chunks/web3-chain-service-DuvxmKSj.js +221 -0
- package/dist/chunks/web3-chain-service-DuvxmKSj.js.map +1 -0
- package/dist/chunks/{explorer.utils-Cx3wrqAj.cjs → web3-manager-C_cFaMCm.cjs} +411 -144
- package/dist/chunks/web3-manager-C_cFaMCm.cjs.map +1 -0
- package/dist/chunks/{explorer.utils-BkS3k8hX.js → web3-manager-OExwBWB7.js} +412 -146
- package/dist/chunks/web3-manager-OExwBWB7.js.map +1 -0
- package/dist/core.cjs +18 -21
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +10 -12
- package/dist/core.js.map +1 -1
- package/dist/donation/index.d.ts +0 -1
- package/dist/donation/index.d.ts.map +1 -1
- package/dist/donation.cjs +48 -29
- package/dist/donation.cjs.map +1 -1
- package/dist/donation.js +50 -3
- package/dist/donation.js.map +1 -1
- package/dist/index.cjs +43 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -15
- package/dist/index.js.map +1 -1
- package/dist/managers/analytics-manager.d.ts +1 -1
- package/dist/managers/index.d.ts +0 -1
- package/dist/managers/index.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts +1 -1
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/node.cjs +10 -13
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +10 -13
- package/dist/node.js.map +1 -1
- package/dist/package.json +4 -10
- package/dist/payment/index.d.ts +0 -1
- package/dist/payment/index.d.ts.map +1 -1
- package/dist/payment.cjs +5 -232
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +3 -210
- package/dist/payment.js.map +1 -1
- package/dist/pers-sdk.d.ts +1 -13
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/redemption/index.d.ts +0 -1
- package/dist/redemption/index.d.ts.map +1 -1
- package/dist/redemption/services/redemption-service.d.ts +1 -2
- package/dist/redemption/services/redemption-service.d.ts.map +1 -1
- package/dist/redemption.cjs +5 -360
- package/dist/redemption.cjs.map +1 -1
- package/dist/redemption.js +3 -338
- package/dist/redemption.js.map +1 -1
- package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts +15 -21
- package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts.map +1 -1
- package/dist/tenant/index.d.ts +0 -1
- package/dist/tenant/index.d.ts.map +1 -1
- package/dist/tenant.cjs +5 -184
- package/dist/tenant.cjs.map +1 -1
- package/dist/tenant.js +3 -162
- package/dist/tenant.js.map +1 -1
- package/dist/token/index.d.ts +0 -1
- package/dist/token/index.d.ts.map +1 -1
- package/dist/token.cjs +1 -25
- package/dist/token.cjs.map +1 -1
- package/dist/token.js +1 -1
- package/dist/transaction/models/transaction-request.builder.d.ts +4 -4
- package/dist/transaction/models/transaction-request.builder.d.ts.map +1 -1
- package/dist/transaction.cjs +1 -1
- package/dist/transaction.js +1 -1
- package/dist/user/index.d.ts +0 -1
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user-status/index.d.ts +0 -1
- package/dist/user-status/index.d.ts.map +1 -1
- package/dist/user-status.cjs +0 -25
- package/dist/user-status.cjs.map +1 -1
- package/dist/user-status.js +0 -1
- package/dist/user-status.js.map +1 -1
- package/dist/user.cjs +209 -29
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +211 -3
- package/dist/user.js.map +1 -1
- package/dist/web3/index.d.ts +1 -0
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3-chain/index.d.ts +0 -1
- package/dist/web3-chain/index.d.ts.map +1 -1
- package/dist/web3-chain.cjs +14 -29
- package/dist/web3-chain.cjs.map +1 -1
- package/dist/web3-chain.js +16 -3
- package/dist/web3-chain.js.map +1 -1
- package/dist/web3-manager.cjs +13 -0
- package/dist/web3-manager.cjs.map +1 -0
- package/dist/web3-manager.js +7 -0
- package/dist/web3-manager.js.map +1 -0
- package/dist/web3.cjs +10 -6
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +4 -1
- package/dist/web3.js.map +1 -1
- package/package.json +4 -10
- package/dist/chunks/analytics-service-CitlimKJ.cjs +0 -49
- package/dist/chunks/analytics-service-CitlimKJ.cjs.map +0 -1
- package/dist/chunks/analytics-service-CxyrOwel.js +0 -46
- package/dist/chunks/analytics-service-CxyrOwel.js.map +0 -1
- package/dist/chunks/campaign-service-CdEz0jpP.cjs +0 -435
- package/dist/chunks/campaign-service-CdEz0jpP.cjs.map +0 -1
- package/dist/chunks/campaign-service-DrTAqFZM.js +0 -432
- package/dist/chunks/campaign-service-DrTAqFZM.js.map +0 -1
- package/dist/chunks/donation-service--6cnTvWq.cjs +0 -54
- package/dist/chunks/donation-service--6cnTvWq.cjs.map +0 -1
- package/dist/chunks/donation-service-xiXZ2Eto.js +0 -51
- package/dist/chunks/donation-service-xiXZ2Eto.js.map +0 -1
- package/dist/chunks/explorer.utils-BkS3k8hX.js.map +0 -1
- package/dist/chunks/explorer.utils-Cx3wrqAj.cjs.map +0 -1
- package/dist/chunks/index-BtDNXaFq.js +0 -13
- package/dist/chunks/index-BtDNXaFq.js.map +0 -1
- package/dist/chunks/index-CMk3Aqkk.cjs +0 -15
- package/dist/chunks/index-CMk3Aqkk.cjs.map +0 -1
- package/dist/chunks/pers-sdk-JIExM712.js.map +0 -1
- package/dist/chunks/pers-sdk-h-uoLpBx.cjs.map +0 -1
- package/dist/chunks/user-service-BGP3SZpk.js +0 -212
- package/dist/chunks/user-service-BGP3SZpk.js.map +0 -1
- package/dist/chunks/user-service-gITOx4qj.cjs +0 -215
- package/dist/chunks/user-service-gITOx4qj.cjs.map +0 -1
- package/dist/chunks/web3-chain-service-BeBjALg2.cjs.map +0 -1
- package/dist/chunks/web3-chain-service-DKHCnHQX.js.map +0 -1
package/dist/redemption.js
CHANGED
|
@@ -1,339 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Platform-Agnostic Redemption API Client (UPDATED - RESTful Design)
|
|
6
|
-
*
|
|
7
|
-
* Updated to work with the new RESTful controller structure:
|
|
8
|
-
* - /redemptions (main redemption management)
|
|
9
|
-
* - /redemption-types (redemption type management)
|
|
10
|
-
* - /redemption-tokens (token unit management)
|
|
11
|
-
* - /redemption-redeems (redemption execution and history)
|
|
12
|
-
*
|
|
13
|
-
* Handles redemption operations using the PERS backend with intelligent access detection.
|
|
14
|
-
* Uses @explorins/pers-shared DTOs for consistency with backend.
|
|
15
|
-
*/
|
|
16
|
-
class RedemptionApi {
|
|
17
|
-
constructor(apiClient) {
|
|
18
|
-
this.apiClient = apiClient;
|
|
19
|
-
this.basePath = '/redemptions';
|
|
20
|
-
this.typesPath = '/redemptions/types';
|
|
21
|
-
}
|
|
22
|
-
// ==========================================
|
|
23
|
-
// PUBLIC OPERATIONS (Project Key)
|
|
24
|
-
// ==========================================
|
|
25
|
-
/**
|
|
26
|
-
* UNIFIED: Get redemptions with intelligent access control
|
|
27
|
-
*
|
|
28
|
-
* Intelligent endpoint that adapts based on authentication:
|
|
29
|
-
* - Public users: Get active redemptions only
|
|
30
|
-
* - Admin users: Get all redemptions with optional filtering
|
|
31
|
-
*
|
|
32
|
-
* @param options.active - Filter by active status (undefined = all for admins/active for public)
|
|
33
|
-
* @param options.adminAccess - Force admin access (requires admin auth)
|
|
34
|
-
* @param options.page - Page number (default: 1)
|
|
35
|
-
* @param options.limit - Items per page (default: 50)
|
|
36
|
-
* @param options.sortBy - Sort field
|
|
37
|
-
* @param options.sortOrder - Sort order (asc/desc)
|
|
38
|
-
* @returns Paginated response with redemptions
|
|
39
|
-
*/
|
|
40
|
-
async getRedemptions(options) {
|
|
41
|
-
const params = buildPaginationParams(options);
|
|
42
|
-
if (options?.active !== undefined) {
|
|
43
|
-
params.append('active', String(options.active));
|
|
44
|
-
}
|
|
45
|
-
const response = await this.apiClient.get(`${this.basePath}?${params.toString()}`);
|
|
46
|
-
return normalizeToPaginated(response);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* PUBLIC: Get redemption types
|
|
50
|
-
*
|
|
51
|
-
* Updated: /redemption/type → /redemption-types
|
|
52
|
-
* @param options Pagination options (page, limit, sortBy, sortOrder)
|
|
53
|
-
* @returns Paginated response with redemption types
|
|
54
|
-
*/
|
|
55
|
-
async getRedemptionTypes(options) {
|
|
56
|
-
const params = buildPaginationParams(options);
|
|
57
|
-
const response = await this.apiClient.get(`${this.typesPath}?${params.toString()}`);
|
|
58
|
-
return normalizeToPaginated(response);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* PUBLIC: Get redemption by ID
|
|
62
|
-
*
|
|
63
|
-
* Updated: /redemption/:id → /redemptions/:id
|
|
64
|
-
*/
|
|
65
|
-
async getRedemptionById(id) {
|
|
66
|
-
return this.apiClient.get(`${this.basePath}/${id}`);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* PUBLIC: Get available supply for redemption
|
|
70
|
-
*
|
|
71
|
-
* Updated: /redemption/:id/available-supply → /redemptions/:id/supply
|
|
72
|
-
*/
|
|
73
|
-
async getRedemptionAvailableSupply(id) {
|
|
74
|
-
const result = await this.apiClient.get(`${this.basePath}/${id}/supply`);
|
|
75
|
-
return result.available;
|
|
76
|
-
}
|
|
77
|
-
// ==========================================
|
|
78
|
-
// REDEMPTION EXECUTION (UNIFIED ENDPOINT)
|
|
79
|
-
// ==========================================
|
|
80
|
-
/**
|
|
81
|
-
* Execute redemption (unified endpoint)
|
|
82
|
-
*
|
|
83
|
-
* NEW: POST /redemption-redeems - Role-based processing
|
|
84
|
-
* - USER: Direct user redemption processing
|
|
85
|
-
* - ADMIN: Can process redemptions for any account type
|
|
86
|
-
* - BUSINESS: Process redemptions for customers
|
|
87
|
-
*/
|
|
88
|
-
async redeemRedemption(redemptionId) {
|
|
89
|
-
const body = {
|
|
90
|
-
redemptionId: redemptionId,
|
|
91
|
-
};
|
|
92
|
-
return this.apiClient.post(this.basePath + '/redeems', body);
|
|
93
|
-
}
|
|
94
|
-
// ==========================================
|
|
95
|
-
// REDEMPTION REDEEMS QUERIES (NEW ENDPOINTS)
|
|
96
|
-
// ==========================================
|
|
97
|
-
/**
|
|
98
|
-
* UNIFIED: Get redemption redeems with filtering and intelligent access
|
|
99
|
-
*
|
|
100
|
-
* Role-based access with unified filtering:
|
|
101
|
-
* - Users: See only their own redeems (userId/businessId filters ignored)
|
|
102
|
-
* - Admins: Can filter by userId, businessId, or redemptionId
|
|
103
|
-
*
|
|
104
|
-
* @param filters.redemptionId - Filter by specific redemption
|
|
105
|
-
* @param filters.userId - Admin only: Filter by user ID
|
|
106
|
-
* @param filters.businessId - Admin only: Filter by business ID
|
|
107
|
-
* @param filters.myRedeems - Force user's own redeems (uses /me endpoint)
|
|
108
|
-
* @param filters.page - Page number (default: 1)
|
|
109
|
-
* @param filters.limit - Items per page (default: 50)
|
|
110
|
-
* @param filters.sortBy - Sort field
|
|
111
|
-
* @param filters.sortOrder - Sort order (asc/desc)
|
|
112
|
-
* @returns Paginated response with redemption redeems
|
|
113
|
-
*/
|
|
114
|
-
async getRedemptionRedeems(filters) {
|
|
115
|
-
let url = `${this.basePath}/redeems`;
|
|
116
|
-
const params = buildPaginationParams(filters);
|
|
117
|
-
// Use convenience endpoint for user's own redeems
|
|
118
|
-
if (filters?.myRedeems) {
|
|
119
|
-
url = `${this.basePath}/redeems/me`;
|
|
120
|
-
if (filters?.redemptionId) {
|
|
121
|
-
params.append('redemptionId', filters.redemptionId);
|
|
122
|
-
}
|
|
123
|
-
const response = await this.apiClient.get(`${url}?${params.toString()}`);
|
|
124
|
-
return normalizeToPaginated(response);
|
|
125
|
-
}
|
|
126
|
-
// Use admin endpoint with filtering
|
|
127
|
-
if (filters?.redemptionId)
|
|
128
|
-
params.append('redemptionId', filters.redemptionId);
|
|
129
|
-
if (filters?.userId)
|
|
130
|
-
params.append('userId', filters.userId);
|
|
131
|
-
if (filters?.businessId)
|
|
132
|
-
params.append('businessId', filters.businessId);
|
|
133
|
-
const response = await this.apiClient.get(`${url}?${params.toString()}`);
|
|
134
|
-
return normalizeToPaginated(response);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* UNIFIED: Get specific redemption redeem by ID
|
|
138
|
-
*/
|
|
139
|
-
async getRedemptionRedeemById(id) {
|
|
140
|
-
return this.apiClient.get(`${this.basePath}/redeems/${id}`);
|
|
141
|
-
}
|
|
142
|
-
// ==========================================
|
|
143
|
-
// USER OPERATIONS (JWT + Project Key)
|
|
144
|
-
// ==========================================
|
|
145
|
-
/**
|
|
146
|
-
* UNIFIED: Get user redemption history
|
|
147
|
-
*
|
|
148
|
-
* Uses convenience endpoint /redemption-redeems/me with optional filtering
|
|
149
|
-
* @param redemptionId - Optional filter by specific redemption
|
|
150
|
-
* @param options - Pagination options (page, limit, sortBy, sortOrder)
|
|
151
|
-
* @returns Paginated response with user's redemption redeems
|
|
152
|
-
*/
|
|
153
|
-
async getUserRedeems(redemptionId, options) {
|
|
154
|
-
return this.getRedemptionRedeems({ myRedeems: true, redemptionId, ...options });
|
|
155
|
-
}
|
|
156
|
-
// ==========================================
|
|
157
|
-
// ADMIN OPERATIONS (Tenant Admin JWT)
|
|
158
|
-
// ==========================================
|
|
159
|
-
/**
|
|
160
|
-
* ADMIN: Create redemption
|
|
161
|
-
*
|
|
162
|
-
* Updated: /redemption/admin → /redemptions
|
|
163
|
-
*/
|
|
164
|
-
async createRedemption(redemption) {
|
|
165
|
-
return this.apiClient.post(`${this.basePath}`, redemption);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* ADMIN: Update redemption
|
|
169
|
-
*
|
|
170
|
-
* Updated: /redemption/admin/:id → /redemptions/:id
|
|
171
|
-
*/
|
|
172
|
-
async updateRedemption(id, redemptionCreateRequest) {
|
|
173
|
-
return this.apiClient.put(`${this.basePath}/${id}`, redemptionCreateRequest);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* UNIFIED: Toggle redemption active status
|
|
177
|
-
*
|
|
178
|
-
* Updated: /redemption/admin/:id/toggle-active → /redemptions/:id/status
|
|
179
|
-
* Following standard /status pattern used across domains
|
|
180
|
-
*/
|
|
181
|
-
async toggleRedemptionActive(redemptionId) {
|
|
182
|
-
return this.apiClient.put(`${this.basePath}/${redemptionId}/status`, {});
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* ADMIN: Delete redemption
|
|
186
|
-
*
|
|
187
|
-
* Updated: /redemption/admin/:id → /redemptions/:id
|
|
188
|
-
*/
|
|
189
|
-
async deleteRedemption(id) {
|
|
190
|
-
return this.apiClient.delete(`${this.basePath}/${id}`);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* ADMIN: Create redemption type
|
|
194
|
-
*
|
|
195
|
-
* Updated: /redemption/admin/type → /redemption-types
|
|
196
|
-
*/
|
|
197
|
-
async createRedemptionType(redemptionType) {
|
|
198
|
-
return this.apiClient.post(this.typesPath, redemptionType);
|
|
199
|
-
}
|
|
200
|
-
// ==========================================
|
|
201
|
-
// TOKEN UNIT MANAGEMENT (Admin)
|
|
202
|
-
// ==========================================
|
|
203
|
-
/**
|
|
204
|
-
* ADMIN: Create redemption token unit
|
|
205
|
-
*
|
|
206
|
-
* Updated: /redemption/admin/:id/token-units → /redemption-tokens/:id/
|
|
207
|
-
*/
|
|
208
|
-
async createRedemptionTokenUnit(redemptionId, redemptionTokenUnit) {
|
|
209
|
-
return this.apiClient.post(`${this.basePath}/${redemptionId}/tokens`, redemptionTokenUnit);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* ADMIN: Update redemption token unit
|
|
213
|
-
*
|
|
214
|
-
* Updated: /redemption/admin/:id/token-units/:tokenUnitId → /redemption-tokens/:id/:tokenUnitId
|
|
215
|
-
*/
|
|
216
|
-
async updateRedemptionTokenUnit(redemptionId, tokenUnitId, redemptionTokenUnit) {
|
|
217
|
-
return this.apiClient.put(`${this.basePath}/${redemptionId}/tokens/${tokenUnitId}`, redemptionTokenUnit);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* ADMIN: Delete redemption token unit
|
|
221
|
-
*
|
|
222
|
-
* Updated: /redemption/admin/:id/token-units/:tokenUnitId → /redemption-tokens/:id/:tokenUnitId
|
|
223
|
-
*/
|
|
224
|
-
async deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId) {
|
|
225
|
-
return this.apiClient.delete(`${this.basePath}/${redemptionId}/tokens/${redemptionTokenUnitId}`);
|
|
226
|
-
}
|
|
227
|
-
// ==========================================
|
|
228
|
-
// CONVENIENCE METHODS (Legacy Support)
|
|
229
|
-
// ==========================================
|
|
230
|
-
/**
|
|
231
|
-
* Convenience: Get active redemptions (public access)
|
|
232
|
-
*
|
|
233
|
-
* @deprecated Use getRedemptions({ active: true }) instead for paginated results
|
|
234
|
-
*/
|
|
235
|
-
async getActiveRedemptions() {
|
|
236
|
-
const result = await this.getRedemptions({ active: true });
|
|
237
|
-
return [...result.data];
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Platform-Agnostic Redemption Service
|
|
243
|
-
*
|
|
244
|
-
* Contains redemption business logic and operations that work across platforms.
|
|
245
|
-
* No framework dependencies - pure TypeScript business logic.
|
|
246
|
-
*
|
|
247
|
-
* Focuses only on actual backend capabilities.
|
|
248
|
-
*/
|
|
249
|
-
class RedemptionService {
|
|
250
|
-
constructor(redemptionApi) {
|
|
251
|
-
this.redemptionApi = redemptionApi;
|
|
252
|
-
}
|
|
253
|
-
// ==========================================
|
|
254
|
-
// PUBLIC OPERATIONS
|
|
255
|
-
// ==========================================
|
|
256
|
-
/**
|
|
257
|
-
* UNIFIED: Get redemptions with intelligent access control and pagination
|
|
258
|
-
* @param options.active - Filter by active status
|
|
259
|
-
* @param options.adminAccess - Force admin access
|
|
260
|
-
*/
|
|
261
|
-
async getRedemptions(options) {
|
|
262
|
-
return this.redemptionApi.getRedemptions(options);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Convenience: Get active redemptions (public)
|
|
266
|
-
*/
|
|
267
|
-
async getActiveRedemptions() {
|
|
268
|
-
return this.redemptionApi.getActiveRedemptions();
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Get all redemption types with pagination
|
|
272
|
-
*/
|
|
273
|
-
async getRedemptionTypes(options) {
|
|
274
|
-
return this.redemptionApi.getRedemptionTypes(options);
|
|
275
|
-
}
|
|
276
|
-
// ==========================================
|
|
277
|
-
// AUTHENTICATED OPERATIONS
|
|
278
|
-
// ==========================================
|
|
279
|
-
/**
|
|
280
|
-
* AUTH: Redeem a redemption
|
|
281
|
-
*/
|
|
282
|
-
async redeemRedemption(redemptionId) {
|
|
283
|
-
return this.redemptionApi.redeemRedemption(redemptionId);
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* UNIFIED: Get redemption redeems with filtering and pagination
|
|
287
|
-
*/
|
|
288
|
-
async getRedemptionRedeems(filters) {
|
|
289
|
-
return this.redemptionApi.getRedemptionRedeems(filters);
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Convenience: Get user redemptions with pagination
|
|
293
|
-
*/
|
|
294
|
-
async getUserRedeems(options) {
|
|
295
|
-
return this.redemptionApi.getUserRedeems(undefined, options);
|
|
296
|
-
}
|
|
297
|
-
// ==========================================
|
|
298
|
-
// ADMIN OPERATIONS
|
|
299
|
-
// ==========================================
|
|
300
|
-
/**
|
|
301
|
-
* Convenience: Get redemptions as admin
|
|
302
|
-
*/
|
|
303
|
-
async getRedemptionsAsAdmin(active, options) {
|
|
304
|
-
return this.redemptionApi.getRedemptions({ active, adminAccess: true, ...options });
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* ADMIN: Create redemption
|
|
308
|
-
*/
|
|
309
|
-
async createRedemption(redemption) {
|
|
310
|
-
return this.redemptionApi.createRedemption(redemption);
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* ADMIN: Update redemption
|
|
314
|
-
*/
|
|
315
|
-
async updateRedemption(id, redemptionCreateRequest) {
|
|
316
|
-
return this.redemptionApi.updateRedemption(id, redemptionCreateRequest); // ✅ CORRECTED: Fixed parameter
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* ADMIN: Toggle redemption active status
|
|
320
|
-
*/
|
|
321
|
-
async toggleRedemptionActive(redemptionId) {
|
|
322
|
-
return this.redemptionApi.toggleRedemptionActive(redemptionId);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* ADMIN: Create redemption token unit
|
|
326
|
-
*/
|
|
327
|
-
async createRedemptionTokenUnit(redemptionId, redemptionTokenUnit) {
|
|
328
|
-
return this.redemptionApi.createRedemptionTokenUnit(redemptionId, redemptionTokenUnit);
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* ADMIN: Delete redemption token unit
|
|
332
|
-
*/
|
|
333
|
-
async deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId) {
|
|
334
|
-
return this.redemptionApi.deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export { RedemptionApi, RedemptionService };
|
|
1
|
+
export { R as RedemptionApi, a as RedemptionService } from './chunks/redemption-service-D-hBqh42.js';
|
|
2
|
+
import '@explorins/pers-shared';
|
|
3
|
+
import './chunks/pagination-utils-9vQ-Npkr.js';
|
|
339
4
|
//# sourceMappingURL=redemption.js.map
|
package/dist/redemption.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redemption.js","sources":[
|
|
1
|
+
{"version":3,"file":"redemption.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PERS Shared Library - Complete Re-export
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Wildcard export of all @explorins/pers-shared types and utilities.
|
|
5
|
+
* The SDK acts as a single source of truth for consuming applications.
|
|
6
|
+
*
|
|
7
|
+
* Benefits:
|
|
8
|
+
* - Zero maintenance: No need to manually track each export
|
|
9
|
+
* - Future-proof: New pers-shared types automatically available
|
|
10
|
+
* - Tree-shaking works: pers-shared is external, bundler optimizes at app level
|
|
11
|
+
* - Proper browser resolution: Package.json export conditions handle browser.js
|
|
12
|
+
*
|
|
13
|
+
* Consuming apps should import from @explorins/pers-sdk, not pers-shared directly:
|
|
14
|
+
*
|
|
15
|
+
* ✅ import { TransactionDTO, UserDTO } from '@explorins/pers-sdk';
|
|
16
|
+
* ❌ import { TransactionDTO } from '@explorins/pers-shared/browser';
|
|
7
17
|
*/
|
|
8
|
-
export
|
|
9
|
-
export { type SessionAuthContextResponseDTO, AccountOwnerType, type SessionAuthRequestDTO, type SessionAuthResponseDTO } from '@explorins/pers-shared';
|
|
10
|
-
export type { ApiKeyDTO, ApiKeyCreatedDTO, ApiKeyRequestDTO, ApiKeyVerificationDTO, IntegrationApiKeyType } from '@explorins/pers-shared';
|
|
11
|
-
export { ApiKeyType } from '@explorins/pers-shared';
|
|
12
|
-
export { type BusinessDTO, type BusinessTypeDTO, type BusinessUpdateRequestDTO, type BusinessCreateRequestDTO, type BusinessToggleActiveRequestDTO, type BusinessApiKeyDTO, type BusinessTokenBalancesDTO, type BusinessTypeCreateRequestDTO } from '@explorins/pers-shared';
|
|
13
|
-
export { type BusinessMembershipDTO, type AddBusinessMemberRequestDTO, type CreateBusinessMembershipRequestDTO, type UpdateBusinessMembershipRequestDTO, MembershipRole, MEMBERSHIP_ROLE_HIERARCHY, hasMinimumRole } from '@explorins/pers-shared';
|
|
14
|
-
export { type CampaignDTO, type CampaignCreateRequestDTO, type CampaignClaimDTO, type CampaignClaimRequestDTO, type CampaignTriggerDTO, type CampaignBusinessEngagementCreateRequestDTO, type TokenUnitCreateRequestDTO, type TokenUnitDTO, type CampaignTriggerType } from '@explorins/pers-shared';
|
|
15
|
-
export { type DonationTypeDTO } from '@explorins/pers-shared';
|
|
16
|
-
export { type UserDTO, type PurchaseDTO, type PurchaseTokenDTO, type PurchaseTypeDTO, type PaymentIntentDTO, type PurchaseCreateRequestDTO, type PurchaseCreateResponseDTO, type PaymentIntentCreateDTO, type PurchaseCurrency } from '@explorins/pers-shared';
|
|
17
|
-
export { type RedemptionDTO, type RedemptionCreateRequestDTO, type RedemptionRedeemRequestDTO, type RedemptionTypeDTO, type RedemptionTypeCreateRequestDTO, type RedemptionRedeemDTO, type RedemptionRedeemRequestResponseDTO } from '@explorins/pers-shared';
|
|
18
|
-
export { type TenantClientConfigDTO, type TenantDTO, type TenantPublicDTO } from '@explorins/pers-shared';
|
|
19
|
-
export { type TokenMetadataDTO, type TokenDTO, type TokenCreateRequestDTO, type TokenUpdateRequestDTO, type TokenStorageData, type TokenTypeDTO } from '@explorins/pers-shared';
|
|
20
|
-
export { NativeTokenTypes } from '@explorins/pers-shared';
|
|
21
|
-
export type { NativeTokenType } from '@explorins/pers-shared';
|
|
22
|
-
export { type TransactionDTO, type TransactionRequestDTO, type TransactionRequestResponseDTO, type AccountSelectorDTO, type TransactionSubmissionRequestDTO } from '@explorins/pers-shared';
|
|
23
|
-
export { type UserCreateRequestDTO, type UserStatusTypeDTO } from '@explorins/pers-shared';
|
|
24
|
-
export type { BusinessLogicError, ValidationError as SharedValidationError, DomainRuleError, TechnicalError, InfrastructureError, SecurityError, RateLimitError, TimeoutError, UnknownError, AuthenticationRequiredError, AuthorizationFailedError, InvalidTokenError, TokenExpiredError, TokenRevokedException, FirebaseAuthenticationError } from '@explorins/pers-shared';
|
|
18
|
+
export * from '@explorins/pers-shared';
|
|
25
19
|
//# sourceMappingURL=pers-shared-lib.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pers-shared-lib.interfaces.d.ts","sourceRoot":"","sources":["../../../src/shared/interfaces/pers-shared-lib.interfaces.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pers-shared-lib.interfaces.d.ts","sourceRoot":"","sources":["../../../src/shared/interfaces/pers-shared-lib.interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,cAAc,wBAAwB,CAAC"}
|
package/dist/tenant/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tenant/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tenant/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/tenant.cjs
CHANGED
|
@@ -1,190 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
3
|
+
var tenantService = require('./chunks/tenant-service-fj-pkXTw.cjs');
|
|
4
|
+
require('@explorins/pers-shared');
|
|
5
|
+
require('./chunks/pagination-utils-B2jRHMSO.cjs');
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* Platform-Agnostic Tenant API Client
|
|
8
|
-
*
|
|
9
|
-
* Handles tenant and admin operations using the PERS backend.
|
|
10
|
-
* Updated to match new RESTful tenant controller endpoints.
|
|
11
|
-
*
|
|
12
|
-
* Note: Special header handling (bypass-auth-interceptor) should be handled by PersApiClient internally
|
|
13
|
-
* or through endpoint-specific configuration.
|
|
14
|
-
*/
|
|
15
|
-
class TenantApi {
|
|
16
|
-
constructor(apiClient) {
|
|
17
|
-
this.apiClient = apiClient;
|
|
18
|
-
this.basePath = '/tenants';
|
|
19
|
-
this.adminPath = '/admins';
|
|
20
|
-
}
|
|
21
|
-
// ==========================================
|
|
22
|
-
// PUBLIC OPERATIONS
|
|
23
|
-
// ==========================================
|
|
24
|
-
/**
|
|
25
|
-
* API KEY: Get current tenant public information
|
|
26
|
-
* UPDATED: Uses /tenants/me endpoint with API key authentication
|
|
27
|
-
*
|
|
28
|
-
* Requires: X-API-Key header (handled by PersApiClient)
|
|
29
|
-
* Returns: Enhanced public tenant information for the authenticated project
|
|
30
|
-
*/
|
|
31
|
-
async getRemoteTenant() {
|
|
32
|
-
// Remove cache busting - not needed for authenticated endpoint
|
|
33
|
-
const timestamp = Date.now().toString();
|
|
34
|
-
const url = `${this.basePath}/me?date=${timestamp}`;
|
|
35
|
-
return this.apiClient.get(url);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* API KEY: Get remote login token
|
|
39
|
-
* UPDATED: Requires API key authentication
|
|
40
|
-
*/
|
|
41
|
-
async getRemoteLoginToken() {
|
|
42
|
-
return this.apiClient.get(`${this.basePath}/login-token`);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* API KEY: Get remote client configuration
|
|
46
|
-
* UPDATED: Requires API key authentication
|
|
47
|
-
*/
|
|
48
|
-
async getRemoteClientConfig() {
|
|
49
|
-
return this.apiClient.get(`${this.basePath}/client-config`);
|
|
50
|
-
}
|
|
51
|
-
// ==========================================
|
|
52
|
-
// PUBLIC UNAUTHENTICATED OPERATIONS
|
|
53
|
-
// ==========================================
|
|
54
|
-
/**
|
|
55
|
-
* PUBLIC: Get tenant public information by ID (no auth required)
|
|
56
|
-
* NEW: For cases where you need public tenant info without API key
|
|
57
|
-
*
|
|
58
|
-
* @param tenantId - The tenant ID to retrieve public information for
|
|
59
|
-
*/
|
|
60
|
-
async getPublicTenantById(tenantId) {
|
|
61
|
-
const url = `${this.basePath}/${tenantId}`;
|
|
62
|
-
return this.apiClient.get(url);
|
|
63
|
-
}
|
|
64
|
-
// ==========================================
|
|
65
|
-
// ADMIN OPERATIONS
|
|
66
|
-
// ==========================================
|
|
67
|
-
/**
|
|
68
|
-
* ADMIN: Update tenant information
|
|
69
|
-
* UPDATED: Uses PUT /tenants (admin endpoint)
|
|
70
|
-
*/
|
|
71
|
-
async updateRemoteTenant(tenantData) {
|
|
72
|
-
return this.apiClient.put(`${this.basePath}`, tenantData);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* ADMIN: Get all tenant admins
|
|
76
|
-
*
|
|
77
|
-
* @param options Pagination options (page, limit, sortBy, sortOrder)
|
|
78
|
-
* @returns Paginated response with tenant admins
|
|
79
|
-
*/
|
|
80
|
-
async getAdmins(options) {
|
|
81
|
-
const params = paginationUtils.buildPaginationParams(options);
|
|
82
|
-
const response = await this.apiClient.get(`${this.adminPath}?${params.toString()}`);
|
|
83
|
-
return paginationUtils.normalizeToPaginated(response);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* ADMIN: Create new admin
|
|
87
|
-
*/
|
|
88
|
-
async postAdmin(adminData) {
|
|
89
|
-
return this.apiClient.post(`${this.adminPath}`, adminData);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* ADMIN: Update admin (toggle tenant association)
|
|
93
|
-
*/
|
|
94
|
-
async putAdmin(adminId, adminData) {
|
|
95
|
-
return this.apiClient.put(`${this.adminPath}/${adminId}/tenant`, adminData);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
7
|
|
|
99
|
-
/**
|
|
100
|
-
* Platform-Agnostic Tenant Service
|
|
101
|
-
*
|
|
102
|
-
* Contains tenant business logic and operations that work across platforms.
|
|
103
|
-
* No framework dependencies - pure TypeScript business logic.
|
|
104
|
-
* Matches framework TenantApiService capabilities exactly.
|
|
105
|
-
*/
|
|
106
|
-
class TenantService {
|
|
107
|
-
constructor(tenantApi) {
|
|
108
|
-
this.tenantApi = tenantApi;
|
|
109
|
-
}
|
|
110
|
-
// ==========================================
|
|
111
|
-
// PUBLIC OPERATIONS
|
|
112
|
-
// ==========================================
|
|
113
|
-
/**
|
|
114
|
-
* PUBLIC: Get tenant public information
|
|
115
|
-
*/
|
|
116
|
-
async getRemoteTenant() {
|
|
117
|
-
return this.tenantApi.getRemoteTenant();
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* PUBLIC: Get remote login token
|
|
121
|
-
*/
|
|
122
|
-
async getRemoteLoginToken() {
|
|
123
|
-
return this.tenantApi.getRemoteLoginToken();
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* PUBLIC: Get remote client configuration
|
|
127
|
-
*/
|
|
128
|
-
async getRemoteClientConfig() {
|
|
129
|
-
return this.tenantApi.getRemoteClientConfig();
|
|
130
|
-
}
|
|
131
|
-
// ==========================================
|
|
132
|
-
// ADMIN OPERATIONS
|
|
133
|
-
// ==========================================
|
|
134
|
-
/**
|
|
135
|
-
* ADMIN: Update tenant information
|
|
136
|
-
* ✅ FIXED: Uses TenantPublicDTO directly like framework
|
|
137
|
-
*/
|
|
138
|
-
async updateRemoteTenant(tenantData) {
|
|
139
|
-
return this.tenantApi.updateRemoteTenant(tenantData);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* ADMIN: Get all tenant admins with pagination
|
|
143
|
-
* @param options - Pagination options
|
|
144
|
-
*/
|
|
145
|
-
async getAdmins(options) {
|
|
146
|
-
return this.tenantApi.getAdmins(options);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* ADMIN: Create new admin
|
|
150
|
-
* ✅ FIXED: Renamed to match framework postAdmin method
|
|
151
|
-
*/
|
|
152
|
-
async postAdmin(adminData) {
|
|
153
|
-
return this.tenantApi.postAdmin(adminData);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* ADMIN: Update admin (toggle tenant association)
|
|
157
|
-
* ✅ FIXED: Renamed to match framework putAdmin method
|
|
158
|
-
*/
|
|
159
|
-
async putAdmin(adminId, adminData) {
|
|
160
|
-
return this.tenantApi.putAdmin(adminId, adminData);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
8
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
get: function () { return persShared.AccountOwnerType; }
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(exports, "ApiKeyType", {
|
|
169
|
-
enumerable: true,
|
|
170
|
-
get: function () { return persShared.ApiKeyType; }
|
|
171
|
-
});
|
|
172
|
-
Object.defineProperty(exports, "MEMBERSHIP_ROLE_HIERARCHY", {
|
|
173
|
-
enumerable: true,
|
|
174
|
-
get: function () { return persShared.MEMBERSHIP_ROLE_HIERARCHY; }
|
|
175
|
-
});
|
|
176
|
-
Object.defineProperty(exports, "MembershipRole", {
|
|
177
|
-
enumerable: true,
|
|
178
|
-
get: function () { return persShared.MembershipRole; }
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(exports, "NativeTokenTypes", {
|
|
181
|
-
enumerable: true,
|
|
182
|
-
get: function () { return persShared.NativeTokenTypes; }
|
|
183
|
-
});
|
|
184
|
-
Object.defineProperty(exports, "hasMinimumRole", {
|
|
185
|
-
enumerable: true,
|
|
186
|
-
get: function () { return persShared.hasMinimumRole; }
|
|
187
|
-
});
|
|
188
|
-
exports.TenantApi = TenantApi;
|
|
189
|
-
exports.TenantService = TenantService;
|
|
9
|
+
exports.TenantApi = tenantService.TenantApi;
|
|
10
|
+
exports.TenantService = tenantService.TenantService;
|
|
190
11
|
//# sourceMappingURL=tenant.cjs.map
|
package/dist/tenant.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant.cjs","sources":[
|
|
1
|
+
{"version":3,"file":"tenant.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|