@explorins/pers-sdk 2.1.37 → 2.1.39
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/dist/business/api/business-api.d.ts +4 -0
- package/dist/business/api/business-api.d.ts.map +1 -1
- package/dist/business/index.d.ts +1 -1
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +1 -1
- package/dist/business.js +1 -1
- package/dist/chunks/{base-token-service-BGuuZX4b.js → base-token-service-N1gwRD8N.js} +2 -2
- package/dist/chunks/{base-token-service-BGuuZX4b.js.map → base-token-service-N1gwRD8N.js.map} +1 -1
- package/dist/chunks/{base-token-service-DSye0WD2.cjs → base-token-service-W7TU23qU.cjs} +2 -2
- package/dist/chunks/{base-token-service-DSye0WD2.cjs.map → base-token-service-W7TU23qU.cjs.map} +1 -1
- package/dist/chunks/{business-membership-service-B9ItWZ2_.cjs → business-membership-service-Dkb780NX.cjs} +21 -1
- package/dist/chunks/business-membership-service-Dkb780NX.cjs.map +1 -0
- package/dist/chunks/{business-membership-service-CPcE-AW0.js → business-membership-service-NLoqoFpG.js} +21 -1
- package/dist/chunks/business-membership-service-NLoqoFpG.js.map +1 -0
- package/dist/chunks/{pers-sdk-Dds2lB27.js → pers-sdk-CNIfzWYX.js} +155 -75
- package/dist/chunks/pers-sdk-CNIfzWYX.js.map +1 -0
- package/dist/chunks/{pers-sdk-DemghJ3a.cjs → pers-sdk-Cwlrl8jb.cjs} +155 -75
- package/dist/chunks/pers-sdk-Cwlrl8jb.cjs.map +1 -0
- package/dist/chunks/{redemption-service-Dc_0Kzd0.cjs → redemption-service-KamEndzB.cjs} +7 -1
- package/dist/chunks/{redemption-service-Dc_0Kzd0.cjs.map → redemption-service-KamEndzB.cjs.map} +1 -1
- package/dist/chunks/{redemption-service-DWhZgrZT.js → redemption-service-w0GMdF0m.js} +7 -1
- package/dist/chunks/{redemption-service-DWhZgrZT.js.map → redemption-service-w0GMdF0m.js.map} +1 -1
- package/dist/chunks/{token-service-qRSYG9uT.js → token-service-BcuDj292.js} +79 -14
- package/dist/chunks/token-service-BcuDj292.js.map +1 -0
- package/dist/chunks/{token-service-BJqu5Xap.cjs → token-service-CnnrCOsg.cjs} +79 -14
- package/dist/chunks/token-service-CnnrCOsg.cjs.map +1 -0
- package/dist/core/auth/refresh-manager.d.ts +12 -2
- package/dist/core/auth/refresh-manager.d.ts.map +1 -1
- package/dist/core/auth/services/auth-service.d.ts +4 -1
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/index.cjs +5 -5
- package/dist/index.js +5 -5
- package/dist/managers/redemption-manager.d.ts +13 -0
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +63 -39
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/node.cjs +4 -4
- package/dist/node.js +4 -4
- package/dist/package.json +2 -2
- package/dist/redemption/services/redemption-service.d.ts +4 -0
- package/dist/redemption/services/redemption-service.d.ts.map +1 -1
- package/dist/redemption.cjs +1 -1
- package/dist/redemption.js +1 -1
- package/dist/token/api/token-api.d.ts +50 -12
- package/dist/token/api/token-api.d.ts.map +1 -1
- package/dist/token/index.d.ts +1 -1
- package/dist/token/index.d.ts.map +1 -1
- package/dist/token/services/token-service.d.ts +40 -9
- package/dist/token/services/token-service.d.ts.map +1 -1
- package/dist/token.cjs +2 -2
- package/dist/token.js +2 -2
- package/dist/trigger-source/api/trigger-source-api.d.ts +9 -10
- package/dist/trigger-source/api/trigger-source-api.d.ts.map +1 -1
- package/dist/trigger-source/index.d.ts +1 -0
- package/dist/trigger-source/index.d.ts.map +1 -1
- package/dist/trigger-source/models/index.d.ts +5 -13
- package/dist/trigger-source/models/index.d.ts.map +1 -1
- package/dist/trigger-source/services/trigger-source-service.d.ts +3 -11
- package/dist/trigger-source/services/trigger-source-service.d.ts.map +1 -1
- package/dist/trigger-source.cjs +20 -1
- package/dist/trigger-source.cjs.map +1 -1
- package/dist/trigger-source.js +20 -1
- package/dist/trigger-source.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/business-membership-service-B9ItWZ2_.cjs.map +0 -1
- package/dist/chunks/business-membership-service-CPcE-AW0.js.map +0 -1
- package/dist/chunks/pers-sdk-Dds2lB27.js.map +0 -1
- package/dist/chunks/pers-sdk-DemghJ3a.cjs.map +0 -1
- package/dist/chunks/token-service-BJqu5Xap.cjs.map +0 -1
- package/dist/chunks/token-service-qRSYG9uT.js.map +0 -1
|
@@ -4,10 +4,10 @@ var persShared = require('@explorins/pers-shared');
|
|
|
4
4
|
var index = require('./index-C4K-jkRO.cjs');
|
|
5
5
|
var user = require('../user.cjs');
|
|
6
6
|
var userStatus = require('../user-status.cjs');
|
|
7
|
-
var tokenService = require('./token-service-
|
|
8
|
-
var businessMembershipService = require('./business-membership-service-
|
|
7
|
+
var tokenService = require('./token-service-CnnrCOsg.cjs');
|
|
8
|
+
var businessMembershipService = require('./business-membership-service-Dkb780NX.cjs');
|
|
9
9
|
var campaign = require('../campaign.cjs');
|
|
10
|
-
var redemptionService = require('./redemption-service-
|
|
10
|
+
var redemptionService = require('./redemption-service-KamEndzB.cjs');
|
|
11
11
|
var transactionRequest_builder = require('./transaction-request.builder-D8pIzjYD.cjs');
|
|
12
12
|
var paymentService = require('./payment-service-Bkw7ZXev.cjs');
|
|
13
13
|
var tenantManager = require('./tenant-manager-DR5eSEJw.cjs');
|
|
@@ -504,6 +504,9 @@ class AuthService {
|
|
|
504
504
|
* Extracts context (tenantId/businessId) from the current refresh token to ensure
|
|
505
505
|
* the recovered session maintains the same context.
|
|
506
506
|
*
|
|
507
|
+
* This is a PUBLIC method that can be called by TokenRefreshManager when internal
|
|
508
|
+
* refresh fails, to try external (provider token) recovery before giving up.
|
|
509
|
+
*
|
|
507
510
|
* @returns true if session was successfully recovered
|
|
508
511
|
*/
|
|
509
512
|
async attemptProviderTokenRecovery() {
|
|
@@ -656,6 +659,8 @@ class TokenRefreshManager {
|
|
|
656
659
|
// Retry configuration for transient failures
|
|
657
660
|
this.MAX_RETRY_ATTEMPTS = 3;
|
|
658
661
|
this.RETRY_DELAY_MS = 1000;
|
|
662
|
+
// Active refresh promise for deduplication
|
|
663
|
+
this.activeRefreshPromise = null;
|
|
659
664
|
}
|
|
660
665
|
/**
|
|
661
666
|
* Ensures the access token is valid, refreshing if needed.
|
|
@@ -756,11 +761,27 @@ class TokenRefreshManager {
|
|
|
756
761
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
757
762
|
}
|
|
758
763
|
/**
|
|
759
|
-
*
|
|
764
|
+
* Attempt token refresh: internal first, then provider token fallback.
|
|
765
|
+
* DEDUPLICATES concurrent calls - all callers share the same promise.
|
|
760
766
|
*/
|
|
761
767
|
async attemptInternalRefresh() {
|
|
762
|
-
|
|
763
|
-
|
|
768
|
+
if (this.activeRefreshPromise) {
|
|
769
|
+
return this.activeRefreshPromise;
|
|
770
|
+
}
|
|
771
|
+
this.activeRefreshPromise = (async () => {
|
|
772
|
+
const result = await this.attemptRefreshWithRetry();
|
|
773
|
+
if (result.success)
|
|
774
|
+
return result;
|
|
775
|
+
// Internal failed - try provider token recovery
|
|
776
|
+
const recovered = await this.authService.attemptProviderTokenRecovery();
|
|
777
|
+
return recovered ? { success: true, retryable: false } : result;
|
|
778
|
+
})();
|
|
779
|
+
try {
|
|
780
|
+
return await this.activeRefreshPromise;
|
|
781
|
+
}
|
|
782
|
+
finally {
|
|
783
|
+
this.activeRefreshPromise = null;
|
|
784
|
+
}
|
|
764
785
|
}
|
|
765
786
|
}
|
|
766
787
|
|
|
@@ -1566,7 +1587,7 @@ class DefaultAuthProvider {
|
|
|
1566
1587
|
/** SDK package name */
|
|
1567
1588
|
const SDK_NAME = "@explorins/pers-sdk";
|
|
1568
1589
|
/** SDK version - injected from package.json at build time */
|
|
1569
|
-
const SDK_VERSION = "2.1.
|
|
1590
|
+
const SDK_VERSION = "2.1.39";
|
|
1570
1591
|
/** Full SDK identifier for headers */
|
|
1571
1592
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1572
1593
|
|
|
@@ -1676,12 +1697,16 @@ class PersApiClient {
|
|
|
1676
1697
|
}
|
|
1677
1698
|
const { retryCount = 0, responseType = 'json', bypassAuth = false } = options || {};
|
|
1678
1699
|
const url = `${this.apiRoot}${endpoint}`;
|
|
1679
|
-
//
|
|
1700
|
+
// TOKEN VALIDATION: Ensure token is valid before request
|
|
1701
|
+
// This blocks the request until token validation completes - prevents 401s from expired tokens
|
|
1680
1702
|
if (!bypassAuth && this.mergedConfig.authProvider && retryCount === 0) {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1703
|
+
try {
|
|
1704
|
+
await this.ensureValidToken();
|
|
1705
|
+
}
|
|
1706
|
+
catch (error) {
|
|
1707
|
+
console.debug('[PersApiClient] Token validation failed:', error);
|
|
1708
|
+
// Continue with request - it will fail with 401 and trigger retry logic
|
|
1709
|
+
}
|
|
1685
1710
|
}
|
|
1686
1711
|
const requestOptions = {
|
|
1687
1712
|
headers: await this.getHeaders(!bypassAuth, method, url),
|
|
@@ -1709,49 +1734,63 @@ class PersApiClient {
|
|
|
1709
1734
|
return result;
|
|
1710
1735
|
}
|
|
1711
1736
|
catch (error) {
|
|
1712
|
-
// Error handling - proactive token refresh should prevent most 401s
|
|
1713
1737
|
const status = index.ErrorUtils.getStatus(error);
|
|
1714
1738
|
const errorMessage = index.ErrorUtils.getMessage(error);
|
|
1715
|
-
// Handle 401 errors
|
|
1739
|
+
// Handle 401 Unauthorized errors
|
|
1716
1740
|
if (status === 401) {
|
|
1717
1741
|
const backendError = index.ErrorUtils.extractBackendErrorDetails(error);
|
|
1718
|
-
//
|
|
1719
|
-
//
|
|
1720
|
-
//
|
|
1742
|
+
// ===========================================
|
|
1743
|
+
// FATAL AUTH ERRORS → Immediate logout
|
|
1744
|
+
// ===========================================
|
|
1745
|
+
// Fatal codes: REFRESH_TOKEN_EXPIRED, TOKEN_REVOKED, INVALID_REFRESH_TOKEN, etc.
|
|
1721
1746
|
if (this.authService.isFatalAuthError(backendError.code)) {
|
|
1722
|
-
|
|
1747
|
+
console.warn(`[PersApiClient] Fatal auth error: ${backendError.code}`);
|
|
1723
1748
|
await this.authService.handleAuthFailure();
|
|
1724
1749
|
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1725
1750
|
throw new index.AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1726
1751
|
}
|
|
1727
|
-
//
|
|
1752
|
+
// ===========================================
|
|
1753
|
+
// REFRESH REQUEST FAILED → Logout (prevents infinite loop)
|
|
1754
|
+
// ===========================================
|
|
1728
1755
|
if (options?.isRefreshRequest) {
|
|
1729
|
-
|
|
1756
|
+
console.warn('[PersApiClient] Refresh request itself failed with 401');
|
|
1730
1757
|
await this.authService.handleAuthFailure();
|
|
1731
1758
|
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1732
1759
|
throw new index.AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1733
1760
|
}
|
|
1734
|
-
//
|
|
1761
|
+
// ===========================================
|
|
1762
|
+
// RETRYABLE 401 (TOKEN_EXPIRED) → Try refresh, then retry
|
|
1763
|
+
// ===========================================
|
|
1735
1764
|
if (retryCount === 0 && this.mergedConfig.authProvider) {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1765
|
+
const refreshResult = await this.refreshManager.attemptInternalRefresh();
|
|
1766
|
+
if (refreshResult.success) {
|
|
1767
|
+
// Refresh succeeded → retry request with new token
|
|
1768
|
+
this._events?.emitSuccess({
|
|
1769
|
+
type: 'token_refreshed',
|
|
1770
|
+
domain: 'authentication',
|
|
1771
|
+
userMessage: 'Authentication token refreshed',
|
|
1772
|
+
});
|
|
1773
|
+
return await this.request(method, endpoint, body, { ...options, retryCount: 1 });
|
|
1774
|
+
}
|
|
1775
|
+
// Refresh failed - check if it's a definitive failure
|
|
1776
|
+
if (!refreshResult.retryable) {
|
|
1777
|
+
// Non-retryable failure (e.g., refresh token expired) → logout
|
|
1778
|
+
console.warn('[PersApiClient] Refresh failed with non-retryable error, logging out');
|
|
1779
|
+
await this.authService.handleAuthFailure();
|
|
1748
1780
|
}
|
|
1749
|
-
|
|
1750
|
-
//
|
|
1781
|
+
else {
|
|
1782
|
+
// Retryable failure (network error, etc.) → DON'T logout, let app retry later
|
|
1783
|
+
console.warn('[PersApiClient] Refresh failed with retryable error, NOT logging out');
|
|
1751
1784
|
}
|
|
1785
|
+
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1786
|
+
throw new index.AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1752
1787
|
}
|
|
1753
|
-
//
|
|
1754
|
-
|
|
1788
|
+
// ===========================================
|
|
1789
|
+
// RETRY FAILED (retryCount > 0) → Something wrong, but DON'T logout
|
|
1790
|
+
// ===========================================
|
|
1791
|
+
// We already refreshed successfully, but retry still got 401
|
|
1792
|
+
// This is unexpected - don't logout, let app investigate
|
|
1793
|
+
console.warn('[PersApiClient] Retry with new token still got 401 - not logging out');
|
|
1755
1794
|
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1756
1795
|
throw new index.AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1757
1796
|
}
|
|
@@ -3416,16 +3455,17 @@ class TokenManager {
|
|
|
3416
3455
|
return this.tokenService.getTokenByContractAddress(contractAddress, contractTokenId);
|
|
3417
3456
|
}
|
|
3418
3457
|
/**
|
|
3419
|
-
* Get all token metadata with filtering and
|
|
3458
|
+
* Get all token metadata with filtering, pagination, and include relations
|
|
3420
3459
|
*
|
|
3421
|
-
* Retrieves token metadata (rewards/stamps) with server-side filtering
|
|
3460
|
+
* Retrieves token metadata (rewards/stamps) with server-side filtering, pagination,
|
|
3461
|
+
* and optional include relations for additional data.
|
|
3422
3462
|
* Useful for displaying rewards (ERC1155) or stamps (ERC721) in admin tables.
|
|
3423
3463
|
* Non-admin users always get active metadata only.
|
|
3424
3464
|
*
|
|
3425
|
-
* @param options - Filter and
|
|
3465
|
+
* @param options - Filter, pagination, and include options
|
|
3426
3466
|
* @returns Promise resolving to paginated token metadata
|
|
3427
3467
|
*
|
|
3428
|
-
* @example Get paginated rewards
|
|
3468
|
+
* @example Get paginated rewards with counts
|
|
3429
3469
|
* ```typescript
|
|
3430
3470
|
* const rewards = await sdk.tokens.getTokenMetadata({
|
|
3431
3471
|
* tokenType: 'ERC1155',
|
|
@@ -3433,19 +3473,26 @@ class TokenManager {
|
|
|
3433
3473
|
* page: 1,
|
|
3434
3474
|
* limit: 10,
|
|
3435
3475
|
* sortBy: 'name',
|
|
3436
|
-
* sortOrder: 'ASC'
|
|
3476
|
+
* sortOrder: 'ASC',
|
|
3477
|
+
* include: ['mintCount', 'burnCount', 'token']
|
|
3437
3478
|
* });
|
|
3438
3479
|
*
|
|
3439
|
-
*
|
|
3440
|
-
*
|
|
3480
|
+
* rewards.data.forEach(r => {
|
|
3481
|
+
* console.log(`${r.name}: ${r.mintCount} minted, ${r.burnCount} burned`);
|
|
3482
|
+
* console.log(`Contract: ${r.included?.token?.contractAddress}`);
|
|
3483
|
+
* });
|
|
3441
3484
|
* ```
|
|
3442
3485
|
*
|
|
3443
|
-
* @example Get stamps with
|
|
3486
|
+
* @example Get stamps with owner business
|
|
3444
3487
|
* ```typescript
|
|
3445
3488
|
* const stamps = await sdk.tokens.getTokenMetadata({
|
|
3446
3489
|
* tokenType: 'ERC721',
|
|
3447
3490
|
* search: 'gold',
|
|
3448
|
-
*
|
|
3491
|
+
* include: ['ownerBusiness', 'token']
|
|
3492
|
+
* });
|
|
3493
|
+
*
|
|
3494
|
+
* stamps.data.forEach(s => {
|
|
3495
|
+
* console.log(`${s.name} owned by ${s.included?.ownerBusiness?.displayName}`);
|
|
3449
3496
|
* });
|
|
3450
3497
|
* ```
|
|
3451
3498
|
*/
|
|
@@ -3453,31 +3500,27 @@ class TokenManager {
|
|
|
3453
3500
|
return this.tokenService.getTokenMetadata(options);
|
|
3454
3501
|
}
|
|
3455
3502
|
/**
|
|
3456
|
-
* Get rewards (ERC1155 token metadata) with filtering and
|
|
3503
|
+
* Get rewards (ERC1155 token metadata) with filtering, pagination, and include relations
|
|
3457
3504
|
*
|
|
3458
3505
|
* Convenience method for fetching reward metadata. Rewards are ERC1155 tokens
|
|
3459
3506
|
* that represent collectible items, vouchers, or other redeemable rewards.
|
|
3460
3507
|
*
|
|
3461
|
-
* @param options - Filter and
|
|
3508
|
+
* @param options - Filter, pagination, and include options (tokenType is set automatically)
|
|
3462
3509
|
* @returns Promise resolving to paginated reward metadata
|
|
3463
3510
|
*
|
|
3464
|
-
* @example Get active rewards
|
|
3511
|
+
* @example Get active rewards with mint counts
|
|
3465
3512
|
* ```typescript
|
|
3466
3513
|
* const rewards = await sdk.tokens.getRewards({
|
|
3467
3514
|
* active: true,
|
|
3468
|
-
* limit: 10
|
|
3515
|
+
* limit: 10,
|
|
3516
|
+
* include: ['mintCount', 'burnCount', 'token', 'ownerBusiness']
|
|
3469
3517
|
* });
|
|
3470
3518
|
*
|
|
3471
|
-
*
|
|
3472
|
-
*
|
|
3473
|
-
*
|
|
3474
|
-
*
|
|
3475
|
-
*
|
|
3476
|
-
* ```typescript
|
|
3477
|
-
* const discountRewards = await sdk.tokens.getRewards({
|
|
3478
|
-
* search: 'discount',
|
|
3479
|
-
* sortBy: 'name',
|
|
3480
|
-
* sortOrder: 'ASC'
|
|
3519
|
+
* rewards.data.forEach(r => {
|
|
3520
|
+
* console.log(`${r.name}: ${r.mintCount ?? 0} minted`);
|
|
3521
|
+
* if (r.included?.token) {
|
|
3522
|
+
* console.log(` Chain: ${r.included.token.chainId}, Contract: ${r.included.token.contractAddress}`);
|
|
3523
|
+
* }
|
|
3481
3524
|
* });
|
|
3482
3525
|
* ```
|
|
3483
3526
|
*/
|
|
@@ -3485,31 +3528,27 @@ class TokenManager {
|
|
|
3485
3528
|
return this.tokenService.getRewards(options);
|
|
3486
3529
|
}
|
|
3487
3530
|
/**
|
|
3488
|
-
* Get stamps (ERC721 token metadata) with filtering and
|
|
3531
|
+
* Get stamps (ERC721 token metadata) with filtering, pagination, and include relations
|
|
3489
3532
|
*
|
|
3490
3533
|
* Convenience method for fetching stamp metadata. Stamps are ERC721 tokens
|
|
3491
3534
|
* that represent achievements, badges, or collectible status markers.
|
|
3492
3535
|
*
|
|
3493
|
-
* @param options - Filter and
|
|
3536
|
+
* @param options - Filter, pagination, and include options (tokenType is set automatically)
|
|
3494
3537
|
* @returns Promise resolving to paginated stamp metadata
|
|
3495
3538
|
*
|
|
3496
|
-
* @example Get active stamps
|
|
3539
|
+
* @example Get active stamps with all includes
|
|
3497
3540
|
* ```typescript
|
|
3498
3541
|
* const stamps = await sdk.tokens.getStamps({
|
|
3499
3542
|
* active: true,
|
|
3500
|
-
* limit: 10
|
|
3543
|
+
* limit: 10,
|
|
3544
|
+
* include: ['mintCount', 'burnCount', 'token', 'ownerBusiness']
|
|
3501
3545
|
* });
|
|
3502
3546
|
*
|
|
3503
|
-
*
|
|
3504
|
-
*
|
|
3505
|
-
*
|
|
3506
|
-
*
|
|
3507
|
-
*
|
|
3508
|
-
* ```typescript
|
|
3509
|
-
* const goldStamps = await sdk.tokens.getStamps({
|
|
3510
|
-
* tags: ['gold', 'premium'],
|
|
3511
|
-
* sortBy: 'createdAt',
|
|
3512
|
-
* sortOrder: 'DESC'
|
|
3547
|
+
* stamps.data.forEach(s => {
|
|
3548
|
+
* console.log(`${s.name}: ${s.mintCount ?? 0} minted`);
|
|
3549
|
+
* if (s.included?.ownerBusiness) {
|
|
3550
|
+
* console.log(` Owner: ${s.included.ownerBusiness.displayName}`);
|
|
3551
|
+
* }
|
|
3513
3552
|
* });
|
|
3514
3553
|
* ```
|
|
3515
3554
|
*/
|
|
@@ -3607,6 +3646,32 @@ class TokenManager {
|
|
|
3607
3646
|
async toggleTokenActive(tokenId) {
|
|
3608
3647
|
return this.tokenService.toggleTokenActive(tokenId);
|
|
3609
3648
|
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Admin: Delete token metadata (soft delete)
|
|
3651
|
+
*
|
|
3652
|
+
* Soft deletes token metadata by setting deletedAt timestamp.
|
|
3653
|
+
* Requires administrator privileges. Will fail with 409 Conflict
|
|
3654
|
+
* if metadata is currently in use by active campaigns or redemptions.
|
|
3655
|
+
*
|
|
3656
|
+
* @param metadataId - ID of the token metadata to delete
|
|
3657
|
+
* @throws {PersApiError} When not authenticated as admin
|
|
3658
|
+
* @throws {PersApiError} 409 Conflict if metadata is in use
|
|
3659
|
+
*
|
|
3660
|
+
* @example
|
|
3661
|
+
* ```typescript
|
|
3662
|
+
* try {
|
|
3663
|
+
* await sdk.tokens.deleteTokenMetadata('metadata-123');
|
|
3664
|
+
* console.log('Token metadata deleted');
|
|
3665
|
+
* } catch (error) {
|
|
3666
|
+
* if (error.statusCode === 409) {
|
|
3667
|
+
* console.log('Cannot delete: metadata is used by campaigns/redemptions');
|
|
3668
|
+
* }
|
|
3669
|
+
* }
|
|
3670
|
+
* ```
|
|
3671
|
+
*/
|
|
3672
|
+
async deleteTokenMetadata(metadataId) {
|
|
3673
|
+
return this.tokenService.deleteTokenMetadata(metadataId);
|
|
3674
|
+
}
|
|
3610
3675
|
/**
|
|
3611
3676
|
* Get the full token SDK for advanced operations
|
|
3612
3677
|
*
|
|
@@ -6000,6 +6065,21 @@ class RedemptionManager {
|
|
|
6000
6065
|
async deleteRedemptionType(id) {
|
|
6001
6066
|
return this.redemptionService.deleteRedemptionType(id);
|
|
6002
6067
|
}
|
|
6068
|
+
/**
|
|
6069
|
+
* Delete a redemption (soft delete)
|
|
6070
|
+
*
|
|
6071
|
+
* @param id - Redemption ID to delete
|
|
6072
|
+
* @returns Promise resolving to true if deleted successfully
|
|
6073
|
+
*
|
|
6074
|
+
* @example
|
|
6075
|
+
* ```typescript
|
|
6076
|
+
* const success = await sdk.redemptions.deleteRedemption('redemption-123');
|
|
6077
|
+
* console.log('Deleted:', success);
|
|
6078
|
+
* ```
|
|
6079
|
+
*/
|
|
6080
|
+
async deleteRedemption(id) {
|
|
6081
|
+
return this.redemptionService.deleteRedemption(id);
|
|
6082
|
+
}
|
|
6003
6083
|
/**
|
|
6004
6084
|
* Get the full redemption service for advanced operations
|
|
6005
6085
|
*
|
|
@@ -10869,4 +10949,4 @@ exports.createPersEventsClient = createPersEventsClient;
|
|
|
10869
10949
|
exports.createPersSDK = createPersSDK;
|
|
10870
10950
|
exports.isFatalAuthErrorInMessage = isFatalAuthErrorInMessage;
|
|
10871
10951
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
10872
|
-
//# sourceMappingURL=pers-sdk-
|
|
10952
|
+
//# sourceMappingURL=pers-sdk-Cwlrl8jb.cjs.map
|