@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.
Files changed (171) hide show
  1. package/README.md +113 -59
  2. package/dist/analytics/index.d.ts +0 -2
  3. package/dist/analytics/index.d.ts.map +1 -1
  4. package/dist/analytics/models/index.d.ts +1 -10
  5. package/dist/analytics/models/index.d.ts.map +1 -1
  6. package/dist/analytics.cjs +44 -29
  7. package/dist/analytics.cjs.map +1 -1
  8. package/dist/analytics.js +45 -2
  9. package/dist/analytics.js.map +1 -1
  10. package/dist/business/index.d.ts +0 -1
  11. package/dist/business/index.d.ts.map +1 -1
  12. package/dist/business.cjs +7 -774
  13. package/dist/business.cjs.map +1 -1
  14. package/dist/business.js +3 -751
  15. package/dist/business.js.map +1 -1
  16. package/dist/campaign/index.d.ts +0 -1
  17. package/dist/campaign/index.d.ts.map +1 -1
  18. package/dist/campaign.cjs +429 -29
  19. package/dist/campaign.cjs.map +1 -1
  20. package/dist/campaign.js +431 -3
  21. package/dist/campaign.js.map +1 -1
  22. package/dist/chunks/business-membership-service-8KC_qRj7.cjs +756 -0
  23. package/dist/chunks/business-membership-service-8KC_qRj7.cjs.map +1 -0
  24. package/dist/chunks/business-membership-service-D6vaVQTR.js +751 -0
  25. package/dist/chunks/business-membership-service-D6vaVQTR.js.map +1 -0
  26. package/dist/chunks/{web3-chain-service-BeBjALg2.cjs → index-B-g2JPVK.cjs} +1 -220
  27. package/dist/chunks/index-B-g2JPVK.cjs.map +1 -0
  28. package/dist/chunks/{web3-chain-service-DKHCnHQX.js → index-CKm_V5XE.js} +2 -219
  29. package/dist/chunks/index-CKm_V5XE.js.map +1 -0
  30. package/dist/chunks/payment-service-Bkw7ZXev.cjs +214 -0
  31. package/dist/chunks/payment-service-Bkw7ZXev.cjs.map +1 -0
  32. package/dist/chunks/payment-service-IvM6rryM.js +211 -0
  33. package/dist/chunks/payment-service-IvM6rryM.js.map +1 -0
  34. package/dist/chunks/{pers-sdk-JIExM712.js → pers-sdk-DYnIZvcx.js} +12 -291
  35. package/dist/chunks/pers-sdk-DYnIZvcx.js.map +1 -0
  36. package/dist/chunks/{pers-sdk-h-uoLpBx.cjs → pers-sdk-Dr9W8stD.cjs} +38 -318
  37. package/dist/chunks/pers-sdk-Dr9W8stD.cjs.map +1 -0
  38. package/dist/chunks/redemption-service-D-hBqh42.js +339 -0
  39. package/dist/chunks/redemption-service-D-hBqh42.js.map +1 -0
  40. package/dist/chunks/redemption-service-rMB6T2W5.cjs +342 -0
  41. package/dist/chunks/redemption-service-rMB6T2W5.cjs.map +1 -0
  42. package/dist/chunks/tenant-service-CsRA3O2V.js +163 -0
  43. package/dist/chunks/tenant-service-CsRA3O2V.js.map +1 -0
  44. package/dist/chunks/tenant-service-fj-pkXTw.cjs +166 -0
  45. package/dist/chunks/tenant-service-fj-pkXTw.cjs.map +1 -0
  46. package/dist/chunks/{transaction-request.builder-DrqTWcyC.cjs → transaction-request.builder-BwWmfHXm.cjs} +6 -6
  47. package/dist/chunks/{transaction-request.builder-DrqTWcyC.cjs.map → transaction-request.builder-BwWmfHXm.cjs.map} +1 -1
  48. package/dist/chunks/{transaction-request.builder-DltmruUC.js → transaction-request.builder-C1FPWmYN.js} +6 -6
  49. package/dist/chunks/{transaction-request.builder-DltmruUC.js.map → transaction-request.builder-C1FPWmYN.js.map} +1 -1
  50. package/dist/chunks/web3-chain-service-D68-0WaW.cjs +224 -0
  51. package/dist/chunks/web3-chain-service-D68-0WaW.cjs.map +1 -0
  52. package/dist/chunks/web3-chain-service-DuvxmKSj.js +221 -0
  53. package/dist/chunks/web3-chain-service-DuvxmKSj.js.map +1 -0
  54. package/dist/chunks/{explorer.utils-Cx3wrqAj.cjs → web3-manager-C_cFaMCm.cjs} +411 -144
  55. package/dist/chunks/web3-manager-C_cFaMCm.cjs.map +1 -0
  56. package/dist/chunks/{explorer.utils-BkS3k8hX.js → web3-manager-OExwBWB7.js} +412 -146
  57. package/dist/chunks/web3-manager-OExwBWB7.js.map +1 -0
  58. package/dist/core.cjs +18 -21
  59. package/dist/core.cjs.map +1 -1
  60. package/dist/core.js +10 -12
  61. package/dist/core.js.map +1 -1
  62. package/dist/donation/index.d.ts +0 -1
  63. package/dist/donation/index.d.ts.map +1 -1
  64. package/dist/donation.cjs +48 -29
  65. package/dist/donation.cjs.map +1 -1
  66. package/dist/donation.js +50 -3
  67. package/dist/donation.js.map +1 -1
  68. package/dist/index.cjs +43 -69
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.d.ts +1 -3
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +13 -15
  73. package/dist/index.js.map +1 -1
  74. package/dist/managers/analytics-manager.d.ts +1 -1
  75. package/dist/managers/index.d.ts +0 -1
  76. package/dist/managers/index.d.ts.map +1 -1
  77. package/dist/managers/web3-manager.d.ts +1 -1
  78. package/dist/managers/web3-manager.d.ts.map +1 -1
  79. package/dist/node.cjs +10 -13
  80. package/dist/node.cjs.map +1 -1
  81. package/dist/node.js +10 -13
  82. package/dist/node.js.map +1 -1
  83. package/dist/package.json +4 -10
  84. package/dist/payment/index.d.ts +0 -1
  85. package/dist/payment/index.d.ts.map +1 -1
  86. package/dist/payment.cjs +5 -232
  87. package/dist/payment.cjs.map +1 -1
  88. package/dist/payment.js +3 -210
  89. package/dist/payment.js.map +1 -1
  90. package/dist/pers-sdk.d.ts +1 -13
  91. package/dist/pers-sdk.d.ts.map +1 -1
  92. package/dist/redemption/index.d.ts +0 -1
  93. package/dist/redemption/index.d.ts.map +1 -1
  94. package/dist/redemption/services/redemption-service.d.ts +1 -2
  95. package/dist/redemption/services/redemption-service.d.ts.map +1 -1
  96. package/dist/redemption.cjs +5 -360
  97. package/dist/redemption.cjs.map +1 -1
  98. package/dist/redemption.js +3 -338
  99. package/dist/redemption.js.map +1 -1
  100. package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts +15 -21
  101. package/dist/shared/interfaces/pers-shared-lib.interfaces.d.ts.map +1 -1
  102. package/dist/tenant/index.d.ts +0 -1
  103. package/dist/tenant/index.d.ts.map +1 -1
  104. package/dist/tenant.cjs +5 -184
  105. package/dist/tenant.cjs.map +1 -1
  106. package/dist/tenant.js +3 -162
  107. package/dist/tenant.js.map +1 -1
  108. package/dist/token/index.d.ts +0 -1
  109. package/dist/token/index.d.ts.map +1 -1
  110. package/dist/token.cjs +1 -25
  111. package/dist/token.cjs.map +1 -1
  112. package/dist/token.js +1 -1
  113. package/dist/transaction/models/transaction-request.builder.d.ts +4 -4
  114. package/dist/transaction/models/transaction-request.builder.d.ts.map +1 -1
  115. package/dist/transaction.cjs +1 -1
  116. package/dist/transaction.js +1 -1
  117. package/dist/user/index.d.ts +0 -1
  118. package/dist/user/index.d.ts.map +1 -1
  119. package/dist/user-status/index.d.ts +0 -1
  120. package/dist/user-status/index.d.ts.map +1 -1
  121. package/dist/user-status.cjs +0 -25
  122. package/dist/user-status.cjs.map +1 -1
  123. package/dist/user-status.js +0 -1
  124. package/dist/user-status.js.map +1 -1
  125. package/dist/user.cjs +209 -29
  126. package/dist/user.cjs.map +1 -1
  127. package/dist/user.js +211 -3
  128. package/dist/user.js.map +1 -1
  129. package/dist/web3/index.d.ts +1 -0
  130. package/dist/web3/index.d.ts.map +1 -1
  131. package/dist/web3-chain/index.d.ts +0 -1
  132. package/dist/web3-chain/index.d.ts.map +1 -1
  133. package/dist/web3-chain.cjs +14 -29
  134. package/dist/web3-chain.cjs.map +1 -1
  135. package/dist/web3-chain.js +16 -3
  136. package/dist/web3-chain.js.map +1 -1
  137. package/dist/web3-manager.cjs +13 -0
  138. package/dist/web3-manager.cjs.map +1 -0
  139. package/dist/web3-manager.js +7 -0
  140. package/dist/web3-manager.js.map +1 -0
  141. package/dist/web3.cjs +10 -6
  142. package/dist/web3.cjs.map +1 -1
  143. package/dist/web3.js +4 -1
  144. package/dist/web3.js.map +1 -1
  145. package/package.json +4 -10
  146. package/dist/chunks/analytics-service-CitlimKJ.cjs +0 -49
  147. package/dist/chunks/analytics-service-CitlimKJ.cjs.map +0 -1
  148. package/dist/chunks/analytics-service-CxyrOwel.js +0 -46
  149. package/dist/chunks/analytics-service-CxyrOwel.js.map +0 -1
  150. package/dist/chunks/campaign-service-CdEz0jpP.cjs +0 -435
  151. package/dist/chunks/campaign-service-CdEz0jpP.cjs.map +0 -1
  152. package/dist/chunks/campaign-service-DrTAqFZM.js +0 -432
  153. package/dist/chunks/campaign-service-DrTAqFZM.js.map +0 -1
  154. package/dist/chunks/donation-service--6cnTvWq.cjs +0 -54
  155. package/dist/chunks/donation-service--6cnTvWq.cjs.map +0 -1
  156. package/dist/chunks/donation-service-xiXZ2Eto.js +0 -51
  157. package/dist/chunks/donation-service-xiXZ2Eto.js.map +0 -1
  158. package/dist/chunks/explorer.utils-BkS3k8hX.js.map +0 -1
  159. package/dist/chunks/explorer.utils-Cx3wrqAj.cjs.map +0 -1
  160. package/dist/chunks/index-BtDNXaFq.js +0 -13
  161. package/dist/chunks/index-BtDNXaFq.js.map +0 -1
  162. package/dist/chunks/index-CMk3Aqkk.cjs +0 -15
  163. package/dist/chunks/index-CMk3Aqkk.cjs.map +0 -1
  164. package/dist/chunks/pers-sdk-JIExM712.js.map +0 -1
  165. package/dist/chunks/pers-sdk-h-uoLpBx.cjs.map +0 -1
  166. package/dist/chunks/user-service-BGP3SZpk.js +0 -212
  167. package/dist/chunks/user-service-BGP3SZpk.js.map +0 -1
  168. package/dist/chunks/user-service-gITOx4qj.cjs +0 -215
  169. package/dist/chunks/user-service-gITOx4qj.cjs.map +0 -1
  170. package/dist/chunks/web3-chain-service-BeBjALg2.cjs.map +0 -1
  171. package/dist/chunks/web3-chain-service-DKHCnHQX.js.map +0 -1
@@ -0,0 +1,339 @@
1
+ import '@explorins/pers-shared';
2
+ import { b as buildPaginationParams, n as normalizeToPaginated } from './pagination-utils-9vQ-Npkr.js';
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 as R, RedemptionService as a };
339
+ //# sourceMappingURL=redemption-service-D-hBqh42.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redemption-service-D-hBqh42.js","sources":["../../src/redemption/api/redemption-api.ts","../../src/redemption/services/redemption-service.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;AAaA;;;;;;;;;;;AAWG;MACU,aAAa,CAAA;AACxB,IAAA,WAAA,CAAoB,SAAwB,EAAA;QAAxB,IAAA,CAAA,SAAS,GAAT,SAAS;QAEZ,IAAA,CAAA,QAAQ,GAAG,cAAc;QACzB,IAAA,CAAA,SAAS,GAAG,oBAAoB;IAHF;;;;AAS/C;;;;;;;;;;;;;;AAcG;IACH,MAAM,cAAc,CAAC,OAAyE,EAAA;AAC5F,QAAA,MAAM,MAAM,GAAG,qBAAqB,CAAC,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,CAAC,YAAoB,EAAE,mBAA8C,EAAA;QAClG,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,YAAY,EAAE,mBAAmB,CAAC;IACxF;AAEA;;AAEG;AACH,IAAA,MAAM,yBAAyB,CAAC,YAAoB,EAAE,qBAA6B,EAAA;QACjF,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,YAAY,EAAE,qBAAqB,CAAC;IAC1F;AACD;;;;"}
@@ -0,0 +1,342 @@
1
+ 'use strict';
2
+
3
+ require('@explorins/pers-shared');
4
+ var paginationUtils = require('./pagination-utils-B2jRHMSO.cjs');
5
+
6
+ /**
7
+ * Platform-Agnostic Redemption API Client (UPDATED - RESTful Design)
8
+ *
9
+ * Updated to work with the new RESTful controller structure:
10
+ * - /redemptions (main redemption management)
11
+ * - /redemption-types (redemption type management)
12
+ * - /redemption-tokens (token unit management)
13
+ * - /redemption-redeems (redemption execution and history)
14
+ *
15
+ * Handles redemption operations using the PERS backend with intelligent access detection.
16
+ * Uses @explorins/pers-shared DTOs for consistency with backend.
17
+ */
18
+ class RedemptionApi {
19
+ constructor(apiClient) {
20
+ this.apiClient = apiClient;
21
+ this.basePath = '/redemptions';
22
+ this.typesPath = '/redemptions/types';
23
+ }
24
+ // ==========================================
25
+ // PUBLIC OPERATIONS (Project Key)
26
+ // ==========================================
27
+ /**
28
+ * UNIFIED: Get redemptions with intelligent access control
29
+ *
30
+ * Intelligent endpoint that adapts based on authentication:
31
+ * - Public users: Get active redemptions only
32
+ * - Admin users: Get all redemptions with optional filtering
33
+ *
34
+ * @param options.active - Filter by active status (undefined = all for admins/active for public)
35
+ * @param options.adminAccess - Force admin access (requires admin auth)
36
+ * @param options.page - Page number (default: 1)
37
+ * @param options.limit - Items per page (default: 50)
38
+ * @param options.sortBy - Sort field
39
+ * @param options.sortOrder - Sort order (asc/desc)
40
+ * @returns Paginated response with redemptions
41
+ */
42
+ async getRedemptions(options) {
43
+ const params = paginationUtils.buildPaginationParams(options);
44
+ if (options?.active !== undefined) {
45
+ params.append('active', String(options.active));
46
+ }
47
+ const response = await this.apiClient.get(`${this.basePath}?${params.toString()}`);
48
+ return paginationUtils.normalizeToPaginated(response);
49
+ }
50
+ /**
51
+ * PUBLIC: Get redemption types
52
+ *
53
+ * Updated: /redemption/type → /redemption-types
54
+ * @param options Pagination options (page, limit, sortBy, sortOrder)
55
+ * @returns Paginated response with redemption types
56
+ */
57
+ async getRedemptionTypes(options) {
58
+ const params = paginationUtils.buildPaginationParams(options);
59
+ const response = await this.apiClient.get(`${this.typesPath}?${params.toString()}`);
60
+ return paginationUtils.normalizeToPaginated(response);
61
+ }
62
+ /**
63
+ * PUBLIC: Get redemption by ID
64
+ *
65
+ * Updated: /redemption/:id → /redemptions/:id
66
+ */
67
+ async getRedemptionById(id) {
68
+ return this.apiClient.get(`${this.basePath}/${id}`);
69
+ }
70
+ /**
71
+ * PUBLIC: Get available supply for redemption
72
+ *
73
+ * Updated: /redemption/:id/available-supply → /redemptions/:id/supply
74
+ */
75
+ async getRedemptionAvailableSupply(id) {
76
+ const result = await this.apiClient.get(`${this.basePath}/${id}/supply`);
77
+ return result.available;
78
+ }
79
+ // ==========================================
80
+ // REDEMPTION EXECUTION (UNIFIED ENDPOINT)
81
+ // ==========================================
82
+ /**
83
+ * Execute redemption (unified endpoint)
84
+ *
85
+ * NEW: POST /redemption-redeems - Role-based processing
86
+ * - USER: Direct user redemption processing
87
+ * - ADMIN: Can process redemptions for any account type
88
+ * - BUSINESS: Process redemptions for customers
89
+ */
90
+ async redeemRedemption(redemptionId) {
91
+ const body = {
92
+ redemptionId: redemptionId,
93
+ };
94
+ return this.apiClient.post(this.basePath + '/redeems', body);
95
+ }
96
+ // ==========================================
97
+ // REDEMPTION REDEEMS QUERIES (NEW ENDPOINTS)
98
+ // ==========================================
99
+ /**
100
+ * UNIFIED: Get redemption redeems with filtering and intelligent access
101
+ *
102
+ * Role-based access with unified filtering:
103
+ * - Users: See only their own redeems (userId/businessId filters ignored)
104
+ * - Admins: Can filter by userId, businessId, or redemptionId
105
+ *
106
+ * @param filters.redemptionId - Filter by specific redemption
107
+ * @param filters.userId - Admin only: Filter by user ID
108
+ * @param filters.businessId - Admin only: Filter by business ID
109
+ * @param filters.myRedeems - Force user's own redeems (uses /me endpoint)
110
+ * @param filters.page - Page number (default: 1)
111
+ * @param filters.limit - Items per page (default: 50)
112
+ * @param filters.sortBy - Sort field
113
+ * @param filters.sortOrder - Sort order (asc/desc)
114
+ * @returns Paginated response with redemption redeems
115
+ */
116
+ async getRedemptionRedeems(filters) {
117
+ let url = `${this.basePath}/redeems`;
118
+ const params = paginationUtils.buildPaginationParams(filters);
119
+ // Use convenience endpoint for user's own redeems
120
+ if (filters?.myRedeems) {
121
+ url = `${this.basePath}/redeems/me`;
122
+ if (filters?.redemptionId) {
123
+ params.append('redemptionId', filters.redemptionId);
124
+ }
125
+ const response = await this.apiClient.get(`${url}?${params.toString()}`);
126
+ return paginationUtils.normalizeToPaginated(response);
127
+ }
128
+ // Use admin endpoint with filtering
129
+ if (filters?.redemptionId)
130
+ params.append('redemptionId', filters.redemptionId);
131
+ if (filters?.userId)
132
+ params.append('userId', filters.userId);
133
+ if (filters?.businessId)
134
+ params.append('businessId', filters.businessId);
135
+ const response = await this.apiClient.get(`${url}?${params.toString()}`);
136
+ return paginationUtils.normalizeToPaginated(response);
137
+ }
138
+ /**
139
+ * UNIFIED: Get specific redemption redeem by ID
140
+ */
141
+ async getRedemptionRedeemById(id) {
142
+ return this.apiClient.get(`${this.basePath}/redeems/${id}`);
143
+ }
144
+ // ==========================================
145
+ // USER OPERATIONS (JWT + Project Key)
146
+ // ==========================================
147
+ /**
148
+ * UNIFIED: Get user redemption history
149
+ *
150
+ * Uses convenience endpoint /redemption-redeems/me with optional filtering
151
+ * @param redemptionId - Optional filter by specific redemption
152
+ * @param options - Pagination options (page, limit, sortBy, sortOrder)
153
+ * @returns Paginated response with user's redemption redeems
154
+ */
155
+ async getUserRedeems(redemptionId, options) {
156
+ return this.getRedemptionRedeems({ myRedeems: true, redemptionId, ...options });
157
+ }
158
+ // ==========================================
159
+ // ADMIN OPERATIONS (Tenant Admin JWT)
160
+ // ==========================================
161
+ /**
162
+ * ADMIN: Create redemption
163
+ *
164
+ * Updated: /redemption/admin → /redemptions
165
+ */
166
+ async createRedemption(redemption) {
167
+ return this.apiClient.post(`${this.basePath}`, redemption);
168
+ }
169
+ /**
170
+ * ADMIN: Update redemption
171
+ *
172
+ * Updated: /redemption/admin/:id → /redemptions/:id
173
+ */
174
+ async updateRedemption(id, redemptionCreateRequest) {
175
+ return this.apiClient.put(`${this.basePath}/${id}`, redemptionCreateRequest);
176
+ }
177
+ /**
178
+ * UNIFIED: Toggle redemption active status
179
+ *
180
+ * Updated: /redemption/admin/:id/toggle-active → /redemptions/:id/status
181
+ * Following standard /status pattern used across domains
182
+ */
183
+ async toggleRedemptionActive(redemptionId) {
184
+ return this.apiClient.put(`${this.basePath}/${redemptionId}/status`, {});
185
+ }
186
+ /**
187
+ * ADMIN: Delete redemption
188
+ *
189
+ * Updated: /redemption/admin/:id → /redemptions/:id
190
+ */
191
+ async deleteRedemption(id) {
192
+ return this.apiClient.delete(`${this.basePath}/${id}`);
193
+ }
194
+ /**
195
+ * ADMIN: Create redemption type
196
+ *
197
+ * Updated: /redemption/admin/type → /redemption-types
198
+ */
199
+ async createRedemptionType(redemptionType) {
200
+ return this.apiClient.post(this.typesPath, redemptionType);
201
+ }
202
+ // ==========================================
203
+ // TOKEN UNIT MANAGEMENT (Admin)
204
+ // ==========================================
205
+ /**
206
+ * ADMIN: Create redemption token unit
207
+ *
208
+ * Updated: /redemption/admin/:id/token-units → /redemption-tokens/:id/
209
+ */
210
+ async createRedemptionTokenUnit(redemptionId, redemptionTokenUnit) {
211
+ return this.apiClient.post(`${this.basePath}/${redemptionId}/tokens`, redemptionTokenUnit);
212
+ }
213
+ /**
214
+ * ADMIN: Update redemption token unit
215
+ *
216
+ * Updated: /redemption/admin/:id/token-units/:tokenUnitId → /redemption-tokens/:id/:tokenUnitId
217
+ */
218
+ async updateRedemptionTokenUnit(redemptionId, tokenUnitId, redemptionTokenUnit) {
219
+ return this.apiClient.put(`${this.basePath}/${redemptionId}/tokens/${tokenUnitId}`, redemptionTokenUnit);
220
+ }
221
+ /**
222
+ * ADMIN: Delete redemption token unit
223
+ *
224
+ * Updated: /redemption/admin/:id/token-units/:tokenUnitId → /redemption-tokens/:id/:tokenUnitId
225
+ */
226
+ async deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId) {
227
+ return this.apiClient.delete(`${this.basePath}/${redemptionId}/tokens/${redemptionTokenUnitId}`);
228
+ }
229
+ // ==========================================
230
+ // CONVENIENCE METHODS (Legacy Support)
231
+ // ==========================================
232
+ /**
233
+ * Convenience: Get active redemptions (public access)
234
+ *
235
+ * @deprecated Use getRedemptions({ active: true }) instead for paginated results
236
+ */
237
+ async getActiveRedemptions() {
238
+ const result = await this.getRedemptions({ active: true });
239
+ return [...result.data];
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Platform-Agnostic Redemption Service
245
+ *
246
+ * Contains redemption business logic and operations that work across platforms.
247
+ * No framework dependencies - pure TypeScript business logic.
248
+ *
249
+ * Focuses only on actual backend capabilities.
250
+ */
251
+ class RedemptionService {
252
+ constructor(redemptionApi) {
253
+ this.redemptionApi = redemptionApi;
254
+ }
255
+ // ==========================================
256
+ // PUBLIC OPERATIONS
257
+ // ==========================================
258
+ /**
259
+ * UNIFIED: Get redemptions with intelligent access control and pagination
260
+ * @param options.active - Filter by active status
261
+ * @param options.adminAccess - Force admin access
262
+ */
263
+ async getRedemptions(options) {
264
+ return this.redemptionApi.getRedemptions(options);
265
+ }
266
+ /**
267
+ * Convenience: Get active redemptions (public)
268
+ */
269
+ async getActiveRedemptions() {
270
+ return this.redemptionApi.getActiveRedemptions();
271
+ }
272
+ /**
273
+ * Get all redemption types with pagination
274
+ */
275
+ async getRedemptionTypes(options) {
276
+ return this.redemptionApi.getRedemptionTypes(options);
277
+ }
278
+ // ==========================================
279
+ // AUTHENTICATED OPERATIONS
280
+ // ==========================================
281
+ /**
282
+ * AUTH: Redeem a redemption
283
+ */
284
+ async redeemRedemption(redemptionId) {
285
+ return this.redemptionApi.redeemRedemption(redemptionId);
286
+ }
287
+ /**
288
+ * UNIFIED: Get redemption redeems with filtering and pagination
289
+ */
290
+ async getRedemptionRedeems(filters) {
291
+ return this.redemptionApi.getRedemptionRedeems(filters);
292
+ }
293
+ /**
294
+ * Convenience: Get user redemptions with pagination
295
+ */
296
+ async getUserRedeems(options) {
297
+ return this.redemptionApi.getUserRedeems(undefined, options);
298
+ }
299
+ // ==========================================
300
+ // ADMIN OPERATIONS
301
+ // ==========================================
302
+ /**
303
+ * Convenience: Get redemptions as admin
304
+ */
305
+ async getRedemptionsAsAdmin(active, options) {
306
+ return this.redemptionApi.getRedemptions({ active, adminAccess: true, ...options });
307
+ }
308
+ /**
309
+ * ADMIN: Create redemption
310
+ */
311
+ async createRedemption(redemption) {
312
+ return this.redemptionApi.createRedemption(redemption);
313
+ }
314
+ /**
315
+ * ADMIN: Update redemption
316
+ */
317
+ async updateRedemption(id, redemptionCreateRequest) {
318
+ return this.redemptionApi.updateRedemption(id, redemptionCreateRequest); // ✅ CORRECTED: Fixed parameter
319
+ }
320
+ /**
321
+ * ADMIN: Toggle redemption active status
322
+ */
323
+ async toggleRedemptionActive(redemptionId) {
324
+ return this.redemptionApi.toggleRedemptionActive(redemptionId);
325
+ }
326
+ /**
327
+ * ADMIN: Create redemption token unit
328
+ */
329
+ async createRedemptionTokenUnit(redemptionId, redemptionTokenUnit) {
330
+ return this.redemptionApi.createRedemptionTokenUnit(redemptionId, redemptionTokenUnit);
331
+ }
332
+ /**
333
+ * ADMIN: Delete redemption token unit
334
+ */
335
+ async deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId) {
336
+ return this.redemptionApi.deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId);
337
+ }
338
+ }
339
+
340
+ exports.RedemptionApi = RedemptionApi;
341
+ exports.RedemptionService = RedemptionService;
342
+ //# sourceMappingURL=redemption-service-rMB6T2W5.cjs.map