@explorins/pers-sdk 1.6.4 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -37
- package/dist/analytics/index.d.ts +0 -16
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics.cjs +5 -73
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +1 -72
- package/dist/analytics.js.map +1 -1
- package/dist/business/index.d.ts +0 -24
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +5 -273
- package/dist/business.cjs.map +1 -1
- package/dist/business.js +1 -272
- package/dist/business.js.map +1 -1
- package/dist/campaign/api/campaign-api.d.ts +3 -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-CajYwGkL.cjs +5850 -0
- package/dist/chunks/pers-sdk-CajYwGkL.cjs.map +1 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js +5817 -0
- package/dist/chunks/pers-sdk-eO4XUi8w.js.map +1 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs +330 -0
- package/dist/chunks/redemption-service-7qbeQxEM.cjs.map +1 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js +327 -0
- package/dist/chunks/redemption-service-BT0J5Iy7.js.map +1 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs +171 -0
- package/dist/chunks/tenant-service-Ba7xrWED.cjs.map +1 -0
- package/dist/chunks/tenant-service-DELk412y.js +168 -0
- package/dist/chunks/tenant-service-DELk412y.js.map +1 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs +208 -0
- package/dist/chunks/token-service-BWScn8Qa.cjs.map +1 -0
- package/dist/chunks/token-service-CpVwC5Eb.js +205 -0
- package/dist/chunks/token-service-CpVwC5Eb.js.map +1 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs +153 -0
- package/dist/chunks/user-service-D1Rn4U8u.cjs.map +1 -0
- package/dist/chunks/user-service-D6mTa_WZ.js +150 -0
- package/dist/chunks/user-service-D6mTa_WZ.js.map +1 -0
- package/dist/chunks/{index-BfOoX87y.cjs → web3-chain-service-BYkj61DN.cjs} +1 -33
- package/dist/chunks/web3-chain-service-BYkj61DN.cjs.map +1 -0
- package/dist/chunks/{index-CM21r58m.js → web3-chain-service-DN6tJmvK.js} +2 -31
- package/dist/chunks/web3-chain-service-DN6tJmvK.js.map +1 -0
- package/dist/core/auth/auth-provider.interface.d.ts +32 -69
- package/dist/core/auth/auth-provider.interface.d.ts.map +1 -1
- package/dist/core/auth/default-auth-provider.d.ts +15 -58
- package/dist/core/auth/default-auth-provider.d.ts.map +1 -1
- package/dist/core/auth/index.d.ts +10 -12
- package/dist/core/auth/index.d.ts.map +1 -1
- package/dist/core/auth/refresh-manager.d.ts +18 -0
- package/dist/core/auth/refresh-manager.d.ts.map +1 -0
- package/dist/core/auth/services/auth-service.d.ts +11 -6
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/auth/token-storage.d.ts +27 -47
- package/dist/core/auth/token-storage.d.ts.map +1 -1
- package/dist/core/errors/index.d.ts +1 -5
- package/dist/core/errors/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts +10 -126
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +8 -3
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core/utils/jwt.function.d.ts.map +1 -1
- package/dist/core.cjs +22 -17
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +13 -13
- package/dist/donation/index.d.ts +0 -15
- package/dist/donation/index.d.ts.map +1 -1
- package/dist/donation.cjs +5 -75
- package/dist/donation.cjs.map +1 -1
- package/dist/donation.js +1 -74
- package/dist/donation.js.map +1 -1
- package/dist/index.cjs +51 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/managers/analytics-manager.d.ts +290 -10
- package/dist/managers/analytics-manager.d.ts.map +1 -1
- package/dist/managers/auth-manager.d.ts +123 -23
- package/dist/managers/auth-manager.d.ts.map +1 -1
- package/dist/managers/business-manager.d.ts +273 -18
- package/dist/managers/business-manager.d.ts.map +1 -1
- package/dist/managers/campaign-manager.d.ts +585 -46
- package/dist/managers/campaign-manager.d.ts.map +1 -1
- package/dist/managers/donation-manager.d.ts +5 -5
- package/dist/managers/donation-manager.d.ts.map +1 -1
- package/dist/managers/file-manager.d.ts +430 -13
- package/dist/managers/file-manager.d.ts.map +1 -1
- package/dist/managers/purchase-manager.d.ts +340 -15
- package/dist/managers/purchase-manager.d.ts.map +1 -1
- package/dist/managers/redemption-manager.d.ts +450 -27
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/tenant-manager.d.ts +5 -5
- package/dist/managers/tenant-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +245 -21
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/managers/transaction-manager.d.ts +447 -18
- package/dist/managers/transaction-manager.d.ts.map +1 -1
- package/dist/managers/user-manager.d.ts +216 -14
- package/dist/managers/user-manager.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts +4 -4
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/package.json +9 -2
- package/dist/payment/index.d.ts +0 -21
- package/dist/payment/index.d.ts.map +1 -1
- package/dist/payment.cjs +5 -255
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +1 -254
- package/dist/payment.js.map +1 -1
- package/dist/pers-sdk.d.ts +141 -34
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/redemption/index.d.ts +0 -25
- package/dist/redemption/index.d.ts.map +1 -1
- package/dist/redemption.cjs +5 -365
- package/dist/redemption.cjs.map +1 -1
- package/dist/redemption.js +1 -364
- package/dist/redemption.js.map +1 -1
- package/dist/tenant/index.d.ts +0 -22
- package/dist/tenant/index.d.ts.map +1 -1
- package/dist/tenant.cjs +5 -203
- package/dist/tenant.cjs.map +1 -1
- package/dist/tenant.js +1 -202
- package/dist/tenant.js.map +1 -1
- package/dist/token.cjs +6 -6
- package/dist/token.js +2 -2
- package/dist/transaction/index.d.ts +0 -22
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction.cjs +0 -40
- package/dist/transaction.cjs.map +1 -1
- package/dist/transaction.js +1 -40
- package/dist/transaction.js.map +1 -1
- package/dist/user/index.d.ts +0 -25
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user.cjs +5 -185
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +1 -184
- package/dist/user.js.map +1 -1
- package/dist/web3/index.d.ts +0 -11
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3-chain/index.d.ts +0 -9
- package/dist/web3-chain/index.d.ts.map +1 -1
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -1
- package/dist/web3-chain.cjs +5 -5
- package/dist/web3-chain.js +2 -1
- package/dist/web3-chain.js.map +1 -1
- package/dist/web3.cjs +6 -10
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +1 -4
- package/dist/web3.js.map +1 -1
- package/package.json +9 -2
- package/dist/chunks/base-token-service-D0KANDgM.js +0 -139
- package/dist/chunks/base-token-service-D0KANDgM.js.map +0 -1
- package/dist/chunks/base-token-service-zNfPjHRx.cjs +0 -141
- package/dist/chunks/base-token-service-zNfPjHRx.cjs.map +0 -1
- package/dist/chunks/index-BfOoX87y.cjs.map +0 -1
- package/dist/chunks/index-CJ9Jfa4A.js.map +0 -1
- package/dist/chunks/index-CM21r58m.js.map +0 -1
- package/dist/chunks/index-CzEluQmf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs +0 -3378
- package/dist/chunks/pers-sdk-DbPwFKrf.cjs.map +0 -1
- package/dist/chunks/pers-sdk-Z6MKeFBX.js +0 -3353
- package/dist/chunks/pers-sdk-Z6MKeFBX.js.map +0 -1
- package/dist/chunks/token-sdk-BW4kkJb3.js.map +0 -1
- package/dist/chunks/token-sdk-CiAbOb6c.cjs.map +0 -1
- package/dist/core/auth/auth-constants.d.ts +0 -33
- package/dist/core/auth/auth-constants.d.ts.map +0 -1
- package/dist/core/auth/auth-errors.d.ts +0 -8
- package/dist/core/auth/auth-errors.d.ts.map +0 -1
- package/dist/core/auth/create-auth-provider.d.ts +0 -27
- package/dist/core/auth/create-auth-provider.d.ts.map +0 -1
- package/dist/core/auth/token-refresh.d.ts +0 -91
- package/dist/core/auth/token-refresh.d.ts.map +0 -1
package/dist/redemption.cjs
CHANGED
|
@@ -1,374 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var redemptionService = require('./chunks/redemption-service-7qbeQxEM.cjs');
|
|
3
4
|
var persShared = require('@explorins/pers-shared');
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Platform-Agnostic Redemption API Client (UPDATED - RESTful Design)
|
|
7
|
-
*
|
|
8
|
-
* Updated to work with the new RESTful controller structure:
|
|
9
|
-
* - /redemptions (main redemption management)
|
|
10
|
-
* - /redemption-types (redemption type management)
|
|
11
|
-
* - /redemption-tokens (token unit management)
|
|
12
|
-
* - /redemption-redeems (redemption execution and history)
|
|
13
|
-
*
|
|
14
|
-
* Handles redemption operations using the PERS backend with intelligent access detection.
|
|
15
|
-
* Uses @explorins/pers-shared DTOs for consistency with backend.
|
|
16
|
-
*/
|
|
17
|
-
class RedemptionApi {
|
|
18
|
-
constructor(apiClient) {
|
|
19
|
-
this.apiClient = apiClient;
|
|
20
|
-
this.basePath = '/redemptions';
|
|
21
|
-
this.typesPath = '/redemptions/types';
|
|
22
|
-
}
|
|
23
|
-
// ==========================================
|
|
24
|
-
// PUBLIC OPERATIONS (Project Key)
|
|
25
|
-
// ==========================================
|
|
26
|
-
/**
|
|
27
|
-
* UNIFIED: Get redemptions with intelligent access control
|
|
28
|
-
*
|
|
29
|
-
* Intelligent endpoint that adapts based on authentication:
|
|
30
|
-
* - Public users: Get active redemptions only
|
|
31
|
-
* - Admin users: Get all redemptions with optional filtering
|
|
32
|
-
*
|
|
33
|
-
* @param options.active - Filter by active status (undefined = all for admins/active for public)
|
|
34
|
-
* @param options.adminAccess - Force admin access (requires admin auth)
|
|
35
|
-
*/
|
|
36
|
-
async getRedemptions(options) {
|
|
37
|
-
let url = `${this.basePath}`;
|
|
38
|
-
if (options?.active !== undefined) {
|
|
39
|
-
url += `?active=${options.active}`;
|
|
40
|
-
}
|
|
41
|
-
return this.apiClient.get(url);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* PUBLIC: Get redemption types
|
|
45
|
-
*
|
|
46
|
-
* Updated: /redemption/type → /redemption-types
|
|
47
|
-
*/
|
|
48
|
-
async getRedemptionTypes() {
|
|
49
|
-
return this.apiClient.get(this.typesPath);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* PUBLIC: Get redemption by ID
|
|
53
|
-
*
|
|
54
|
-
* Updated: /redemption/:id → /redemptions/:id
|
|
55
|
-
*/
|
|
56
|
-
async getRedemptionById(id) {
|
|
57
|
-
return this.apiClient.get(`${this.basePath}/${id}`);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* PUBLIC: Get available supply for redemption
|
|
61
|
-
*
|
|
62
|
-
* Updated: /redemption/:id/available-supply → /redemptions/:id/supply
|
|
63
|
-
*/
|
|
64
|
-
async getRedemptionAvailableSupply(id) {
|
|
65
|
-
const result = await this.apiClient.get(`${this.basePath}/${id}/supply`);
|
|
66
|
-
return result.available;
|
|
67
|
-
}
|
|
68
|
-
// ==========================================
|
|
69
|
-
// REDEMPTION EXECUTION (UNIFIED ENDPOINT)
|
|
70
|
-
// ==========================================
|
|
71
|
-
/**
|
|
72
|
-
* Execute redemption (unified endpoint)
|
|
73
|
-
*
|
|
74
|
-
* NEW: POST /redemption-redeems - Role-based processing
|
|
75
|
-
* - USER: Direct user redemption processing
|
|
76
|
-
* - ADMIN: Can process redemptions for any account type
|
|
77
|
-
* - BUSINESS: Process redemptions for customers
|
|
78
|
-
*/
|
|
79
|
-
async redeemRedemption(redemptionId) {
|
|
80
|
-
const body = {
|
|
81
|
-
redemptionId: redemptionId,
|
|
82
|
-
};
|
|
83
|
-
return this.apiClient.post(this.basePath + '/redeems', body);
|
|
84
|
-
}
|
|
85
|
-
// ==========================================
|
|
86
|
-
// REDEMPTION REDEEMS QUERIES (NEW ENDPOINTS)
|
|
87
|
-
// ==========================================
|
|
88
|
-
/**
|
|
89
|
-
* UNIFIED: Get redemption redeems with filtering and intelligent access
|
|
90
|
-
*
|
|
91
|
-
* Role-based access with unified filtering:
|
|
92
|
-
* - Users: See only their own redeems (userId/businessId filters ignored)
|
|
93
|
-
* - Admins: Can filter by userId, businessId, or redemptionId
|
|
94
|
-
*
|
|
95
|
-
* @param filters.redemptionId - Filter by specific redemption
|
|
96
|
-
* @param filters.userId - Admin only: Filter by user ID
|
|
97
|
-
* @param filters.businessId - Admin only: Filter by business ID
|
|
98
|
-
* @param filters.myRedeems - Force user's own redeems (uses /me endpoint)
|
|
99
|
-
*/
|
|
100
|
-
async getRedemptionRedeems(filters) {
|
|
101
|
-
let url = `${this.basePath}/redeems`;
|
|
102
|
-
// Use convenience endpoint for user's own redeems
|
|
103
|
-
if (filters?.myRedeems) {
|
|
104
|
-
url = `${this.basePath}/redeems/me`;
|
|
105
|
-
if (filters.redemptionId) {
|
|
106
|
-
url += `?redemptionId=${filters.redemptionId}`;
|
|
107
|
-
}
|
|
108
|
-
return this.apiClient.get(url);
|
|
109
|
-
}
|
|
110
|
-
// Use admin endpoint with filtering
|
|
111
|
-
const params = new URLSearchParams();
|
|
112
|
-
if (filters?.redemptionId)
|
|
113
|
-
params.append('redemptionId', filters.redemptionId);
|
|
114
|
-
if (filters?.userId)
|
|
115
|
-
params.append('userId', filters.userId);
|
|
116
|
-
if (filters?.businessId)
|
|
117
|
-
params.append('businessId', filters.businessId);
|
|
118
|
-
const queryString = params.toString();
|
|
119
|
-
if (queryString) {
|
|
120
|
-
url += `?${queryString}`;
|
|
121
|
-
}
|
|
122
|
-
return this.apiClient.get(url);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* UNIFIED: Get specific redemption redeem by ID
|
|
126
|
-
*/
|
|
127
|
-
async getRedemptionRedeemById(id) {
|
|
128
|
-
return this.apiClient.get(`${this.basePath}/redeems/${id}`);
|
|
129
|
-
}
|
|
130
|
-
// ==========================================
|
|
131
|
-
// USER OPERATIONS (JWT + Project Key)
|
|
132
|
-
// ==========================================
|
|
133
|
-
/**
|
|
134
|
-
* UNIFIED: Get user redemption history
|
|
135
|
-
*
|
|
136
|
-
* Uses convenience endpoint /redemption-redeems/me with optional filtering
|
|
137
|
-
* @param redemptionId - Optional filter by specific redemption
|
|
138
|
-
*/
|
|
139
|
-
async getUserRedeems(redemptionId) {
|
|
140
|
-
return this.getRedemptionRedeems({ myRedeems: true, redemptionId });
|
|
141
|
-
}
|
|
142
|
-
// ==========================================
|
|
143
|
-
// ADMIN OPERATIONS (Tenant Admin JWT)
|
|
144
|
-
// ==========================================
|
|
145
|
-
/**
|
|
146
|
-
* ADMIN: Get redemptions with filtering (using intelligent endpoint)
|
|
147
|
-
*
|
|
148
|
-
* Updated: /redemption/admin → /redemptions (intelligent access detection)
|
|
149
|
-
* The unified endpoint will detect admin privileges and allow filtering
|
|
150
|
-
*/
|
|
151
|
-
async getRedemptionsAsAdmin(active) {
|
|
152
|
-
return this.getRedemptions({ active, adminAccess: true });
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* ADMIN: Create redemption
|
|
156
|
-
*
|
|
157
|
-
* Updated: /redemption/admin → /redemptions
|
|
158
|
-
*/
|
|
159
|
-
async createRedemption(redemption) {
|
|
160
|
-
return this.apiClient.post(`${this.basePath}`, redemption);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* ADMIN: Update redemption
|
|
164
|
-
*
|
|
165
|
-
* Updated: /redemption/admin/:id → /redemptions/:id
|
|
166
|
-
*/
|
|
167
|
-
async updateRedemption(id, redemptionCreateRequest) {
|
|
168
|
-
return this.apiClient.put(`${this.basePath}/${id}`, redemptionCreateRequest);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* UNIFIED: Toggle redemption active status
|
|
172
|
-
*
|
|
173
|
-
* Updated: /redemption/admin/:id/toggle-active → /redemptions/:id/status
|
|
174
|
-
* Following standard /status pattern used across domains
|
|
175
|
-
*/
|
|
176
|
-
async toggleRedemptionActive(redemptionId) {
|
|
177
|
-
return this.apiClient.put(`${this.basePath}/${redemptionId}/status`, {});
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* ADMIN: Delete redemption
|
|
181
|
-
*
|
|
182
|
-
* Updated: /redemption/admin/:id → /redemptions/:id
|
|
183
|
-
*/
|
|
184
|
-
async deleteRedemption(id) {
|
|
185
|
-
return this.apiClient.delete(`${this.basePath}/${id}`);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* ADMIN: Create redemption type
|
|
189
|
-
*
|
|
190
|
-
* Updated: /redemption/admin/type → /redemption-types
|
|
191
|
-
*/
|
|
192
|
-
async createRedemptionType(redemptionType) {
|
|
193
|
-
return this.apiClient.post(this.typesPath, redemptionType);
|
|
194
|
-
}
|
|
195
|
-
// ==========================================
|
|
196
|
-
// TOKEN UNIT MANAGEMENT (Admin)
|
|
197
|
-
// ==========================================
|
|
198
|
-
/**
|
|
199
|
-
* ADMIN: Create redemption token unit
|
|
200
|
-
*
|
|
201
|
-
* Updated: /redemption/admin/:id/token-units → /redemption-tokens/:id/
|
|
202
|
-
*/
|
|
203
|
-
async createRedemptionTokenUnit(redemptionId, redemptionTokenUnit) {
|
|
204
|
-
return this.apiClient.post(`${this.basePath}/${redemptionId}/tokens`, redemptionTokenUnit);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* ADMIN: Update redemption token unit
|
|
208
|
-
*
|
|
209
|
-
* Updated: /redemption/admin/:id/token-units/:tokenUnitId → /redemption-tokens/:id/:tokenUnitId
|
|
210
|
-
*/
|
|
211
|
-
async updateRedemptionTokenUnit(redemptionId, tokenUnitId, redemptionTokenUnit) {
|
|
212
|
-
return this.apiClient.put(`${this.basePath}/${redemptionId}/tokens/${tokenUnitId}`, redemptionTokenUnit);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* ADMIN: Delete redemption token unit
|
|
216
|
-
*
|
|
217
|
-
* Updated: /redemption/admin/:id/token-units/:tokenUnitId → /redemption-tokens/:id/:tokenUnitId
|
|
218
|
-
*/
|
|
219
|
-
async deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId) {
|
|
220
|
-
return this.apiClient.delete(`${this.basePath}/${redemptionId}/tokens/${redemptionTokenUnitId}`);
|
|
221
|
-
}
|
|
222
|
-
// ==========================================
|
|
223
|
-
// CONVENIENCE METHODS (Legacy Support)
|
|
224
|
-
// ==========================================
|
|
225
|
-
/**
|
|
226
|
-
* Convenience: Get active redemptions (public access)
|
|
227
|
-
*/
|
|
228
|
-
async getActiveRedemptions() {
|
|
229
|
-
return this.getRedemptions({ active: true });
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
6
|
|
|
233
|
-
/**
|
|
234
|
-
* Platform-Agnostic Redemption Service
|
|
235
|
-
*
|
|
236
|
-
* Contains redemption business logic and operations that work across platforms.
|
|
237
|
-
* No framework dependencies - pure TypeScript business logic.
|
|
238
|
-
*
|
|
239
|
-
* Focuses only on actual backend capabilities.
|
|
240
|
-
*/
|
|
241
|
-
class RedemptionService {
|
|
242
|
-
constructor(redemptionApi) {
|
|
243
|
-
this.redemptionApi = redemptionApi;
|
|
244
|
-
}
|
|
245
|
-
// ==========================================
|
|
246
|
-
// PUBLIC OPERATIONS
|
|
247
|
-
// ==========================================
|
|
248
|
-
/**
|
|
249
|
-
* UNIFIED: Get redemptions with intelligent access control
|
|
250
|
-
* @param options.active - Filter by active status
|
|
251
|
-
* @param options.adminAccess - Force admin access
|
|
252
|
-
*/
|
|
253
|
-
async getRedemptions(options) {
|
|
254
|
-
return this.redemptionApi.getRedemptions(options);
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Convenience: Get active redemptions (public)
|
|
258
|
-
*/
|
|
259
|
-
async getActiveRedemptions() {
|
|
260
|
-
return this.redemptionApi.getActiveRedemptions();
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* PUBLIC: Get redemption types
|
|
264
|
-
*/
|
|
265
|
-
async getRedemptionTypes() {
|
|
266
|
-
return this.redemptionApi.getRedemptionTypes();
|
|
267
|
-
}
|
|
268
|
-
// ==========================================
|
|
269
|
-
// AUTHENTICATED OPERATIONS
|
|
270
|
-
// ==========================================
|
|
271
|
-
/**
|
|
272
|
-
* AUTH: Redeem a redemption
|
|
273
|
-
*/
|
|
274
|
-
async redeemRedemption(redemptionId) {
|
|
275
|
-
return this.redemptionApi.redeemRedemption(redemptionId);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* UNIFIED: Get redemption redeems with filtering
|
|
279
|
-
*/
|
|
280
|
-
async getRedemptionRedeems(filters) {
|
|
281
|
-
return this.redemptionApi.getRedemptionRedeems(filters);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Convenience: Get user redemptions
|
|
285
|
-
*/
|
|
286
|
-
async getUserRedeems() {
|
|
287
|
-
return this.redemptionApi.getUserRedeems();
|
|
288
|
-
}
|
|
289
|
-
// ==========================================
|
|
290
|
-
// ADMIN OPERATIONS
|
|
291
|
-
// ==========================================
|
|
292
|
-
/**
|
|
293
|
-
* Convenience: Get redemptions as admin
|
|
294
|
-
*/
|
|
295
|
-
async getRedemptionsAsAdmin(active) {
|
|
296
|
-
return this.redemptionApi.getRedemptionsAsAdmin(active);
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* ADMIN: Create redemption
|
|
300
|
-
*/
|
|
301
|
-
async createRedemption(redemption) {
|
|
302
|
-
return this.redemptionApi.createRedemption(redemption);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* ADMIN: Update redemption
|
|
306
|
-
*/
|
|
307
|
-
async updateRedemption(id, redemptionCreateRequest) {
|
|
308
|
-
return this.redemptionApi.updateRedemption(id, redemptionCreateRequest); // ✅ CORRECTED: Fixed parameter
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* ADMIN: Toggle redemption active status
|
|
312
|
-
*/
|
|
313
|
-
async toggleRedemptionActive(redemptionId) {
|
|
314
|
-
return this.redemptionApi.toggleRedemptionActive(redemptionId);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* ADMIN: Create redemption token unit
|
|
318
|
-
*/
|
|
319
|
-
async createRedemptionTokenUnit(redemptionId, redemptionTokenUnit) {
|
|
320
|
-
return this.redemptionApi.createRedemptionTokenUnit(redemptionId, redemptionTokenUnit);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* ADMIN: Delete redemption token unit
|
|
324
|
-
*/
|
|
325
|
-
async deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId) {
|
|
326
|
-
return this.redemptionApi.deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* @explorins/pers-sdk-redemption
|
|
332
|
-
*
|
|
333
|
-
* Platform-agnostic Redemption Domain SDK for PERS ecosystem
|
|
334
|
-
* Handles redemption operations across different authorization levels
|
|
335
|
-
*/
|
|
336
|
-
// API Layer
|
|
337
|
-
/**
|
|
338
|
-
* Create a complete Redemption SDK instance
|
|
339
|
-
*
|
|
340
|
-
* @param apiClient - Configured PERS API client
|
|
341
|
-
* @returns Redemption SDK with flattened structure for better DX
|
|
342
|
-
*/
|
|
343
|
-
function createRedemptionSDK(apiClient) {
|
|
344
|
-
const redemptionApi = new RedemptionApi(apiClient);
|
|
345
|
-
const redemptionService = new RedemptionService(redemptionApi);
|
|
346
|
-
return {
|
|
347
|
-
// Direct access to service methods (primary interface)
|
|
348
|
-
// Public methods
|
|
349
|
-
getActiveRedemptions: () => redemptionService.getActiveRedemptions(),
|
|
350
|
-
getRedemptionTypes: () => redemptionService.getRedemptionTypes(),
|
|
351
|
-
// Auth methods
|
|
352
|
-
redeemRedemption: (redemptionId) => redemptionService.redeemRedemption(redemptionId),
|
|
353
|
-
getUserRedeems: () => redemptionService.getUserRedeems(),
|
|
354
|
-
// Admin methods
|
|
355
|
-
getRedemptionsAsAdmin: (active) => redemptionService.getRedemptionsAsAdmin(active),
|
|
356
|
-
createRedemption: (redemption) => redemptionService.createRedemption(redemption),
|
|
357
|
-
updateRedemption: (id, redemptionCreateRequest) => redemptionService.updateRedemption(id, redemptionCreateRequest),
|
|
358
|
-
toggleRedemptionActive: (redemptionId) => redemptionService.toggleRedemptionActive(redemptionId),
|
|
359
|
-
createRedemptionTokenUnit: (redemptionId, redemptionTokenUnit) => redemptionService.createRedemptionTokenUnit(redemptionId, redemptionTokenUnit),
|
|
360
|
-
deleteRedemptionTokenUnit: (redemptionId, redemptionTokenUnitId) => redemptionService.deleteRedemptionTokenUnit(redemptionId, redemptionTokenUnitId),
|
|
361
|
-
// Advanced access for edge cases
|
|
362
|
-
api: redemptionApi,
|
|
363
|
-
service: redemptionService
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
7
|
|
|
8
|
+
exports.RedemptionApi = redemptionService.RedemptionApi;
|
|
9
|
+
exports.RedemptionService = redemptionService.RedemptionService;
|
|
367
10
|
Object.defineProperty(exports, "AccountOwnerType", {
|
|
368
|
-
|
|
369
|
-
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return persShared.AccountOwnerType; }
|
|
370
13
|
});
|
|
371
|
-
exports.RedemptionApi = RedemptionApi;
|
|
372
|
-
exports.RedemptionService = RedemptionService;
|
|
373
|
-
exports.createRedemptionSDK = createRedemptionSDK;
|
|
374
14
|
//# sourceMappingURL=redemption.cjs.map
|
package/dist/redemption.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redemption.cjs","sources":[
|
|
1
|
+
{"version":3,"file":"redemption.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|